# FluentD - Log



# FluentD v2.0

## **Installation Procedure**

#### **Code**

[FluentD.zip](https://docu.issentialsolutions.com/attachments/5)

```
docker compose up -d
```

**Reference**

```
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-elasticsearch-fluentd-and-kibana-efk-logging-stack-on-kubernetes
```

####   


```
pip install fluent-logger
```

```
from fluent import sender
from fluent import event
```

#### **Function to call and Insert Record in to FluentD**

```
#Error Log for fluent
@app.route('/ApplicationErrorLog', methods=['GET', 'POST'])
def ApplicationErrorLog():

	
	try:
	
		req_data = request.get_json() 
		serrortype = req_data['serrortype']
		sprogram = req_data['sprogram']
		sfnname = req_data['sfnname']
		smsg = req_data['smsg']
		sAppicationName = req_data['sAppicationName']
		
		if(DBKEY == "PROD"):
			sender.setup(sAppicationName, host='192.168.50.36', port=24224)
			event.Event('PROD', {
			'error_Type': serrortype,
			'program': sprogram,
			'function name':  sfnname,
			'error message': smsg
			})
			return "PROD"
		else:
			sender.setup(sAppicationName, host='192.168.50.36', port=24224)
			event.Event('DEVL', {
			'error_Type': serrortype,
			'program': sprogram,
			'function name': sfnname,
			'error message': smsg
			})
			return "DEVL"
	except :
		#raise werkzeug.exceptions.HTTPException("Error: %s" % str("ERROR") ) 
		errmsg = str(sys.exc_info()[1]) + ' Line: ' + str(sys.exc_info()[2].tb_lineno)
		print(errmsg)
		raise    
		return errmsg
```

```
docker build -t fluentdapp:latest .
```

```
docker run -it -d -p5015:5015 --name name_flientd  fluentdapp –restart always
```

<table border="1" id="bkmrk-sno.-fields-remarks-" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 6.67491%;"></col><col style="width: 39.4314%;"></col><col style="width: 53.8937%;"></col></colgroup><tbody><tr><td>SNo.</td><td>Fields</td><td>Remarks</td></tr><tr><td>1</td><td>serrortype</td><td>INFO , WARNNING , ERROR</td></tr><tr><td>2</td><td>sprogram</td><td>(\*) Program Name of application for example FileName of the code that we have written</td></tr><tr><td>3</td><td>sfnname</td><td>Function Name that is causing the event ( Optional )</td></tr><tr><td>4</td><td>smsg</td><td>Error Message </td></tr><tr><td>5</td><td>sAppicationName</td><td>(\*) Application name - Example LMS., JOURNEY etc</td></tr></tbody></table>

##### **Scope of the project.**

1. Run the EFK using docker compose.
2. Run the middle ware and make sure it connects with EFK
3. Create Sample Index in elastic search.
4. Integrate Copy LE and Delete LE functionality with EFK.

# FluentD v1.0

## Introduction

FluentD is the centralized Log collector and format that in to standard format and send it to elastic search &amp; kibana for visualization.

### Video URL for introduction

```
https://www.youtube.com/watch?v=5ofsNyHZwWE
```


### Installation ( EFK stack using Docker and kubernet )

```
https://www.youtube.com/watch?v=MNId4HG0wV8
```

#### EFK ( Elastic Search / Kibana / FluentD )

```
https://github.com/justmeandopensource/elk/tree/master/docker-efk
```

#### EFK ( Elastic Serach / Kibana / FluentD / http )

```
https://www.youtube.com/watch?v=Gp0-7oVOtPw
```