Logstash Load Data with Docker

Today, we will pass our logs to elasticsearch in Json and Csv format with the help of logstash.

Project Structure should be created as in the image.

elasticsearch

logstash.conf

data-json.log

docker-compose

Run the command and move the “data-json.log” data to elasticsearch.

You can provide controls with Elasticsearch Rest API.

To view your index data;

Under the source section, we see the data you type into elasticsearch via logstash. We see that “message”, “timestamp”, “version” fields have been added even though it is not in our log file.

While examining Logstash Filter Plugins, we will examine the removal of these fields by using “remove_field”.

Logstash Filter Plugin

Drop

Used in conjunction with if. When this condition is fulfilled, this document is not attached. For example; Payment Type Sodexo ones are not added.

Mutate

It allows us to make general changes on the fields.We can name, change or remove fields.

Rename:

Update: If there is no field, no action is taken.

Coerce: Gives a default value to an empty field.

Add_Field:

Remove_Field:

We have removed the fields that are not in the log file with remove_field.

Logstash-CSV

If we want to add data in CSV format, we need to make the following updates on “logstash.conf” and “docker-compose.yml”.

logstash.conf:

docker-compose (logstash volume update):

Software Developer