How to extract fields from existing logs (fluent-bit in ECS) - elasticsearch

I have configured Fluent-bit on my ECS cluster . I can see the logs in Kibana. But all the log data are sent to a single field "log". How can I extract each field into a separate field. There is a solution for fluentd already in this question.
But how can I achieve the same with fluent-bit?
There is a solution in Kuberntetes with fluent-bit: https://docs.fluentbit.io/manual/filter/kubernetes
How do I achieve the same thing in ECS?

Generally fluent-bit send exactly docker log file that taking from /var/lib/docker/containers/*/*.log
You can browse this path on your machine and see that it contains JSON strings with exactly two fields you mentioned.
From here you have number ways, I'll discover two that I know well:
Use logstash:
You should know well the log structure. This helps you to create the right filters pipeline for the parse log field. Usually, people use filter plugins for this. If you add log examples I will be able to make an example of a filter like this
Use the elasticsearch ingest node.
You should know well the log structure. For be able easy to create processors pipeline for parse log field. More one time, specific log examples help's us to help you.
The most used filter/processor is grok filter/processor. This tool have a lot of options for parse structured text from any log.

Related

How can I read a input file in kibana?

I have to do some operation on a vtt file in kibana. But I am unable to read it in kibana. please suggest me some ways to read it.
First of all, Kibana is just a visualization tool that lets you search data in elasticsearch in a graphical manner. So primarily you want to index the data from your file into elasticsearch in order to see them in kibana.
You may want to take a look at Logstash in general and especially at its File Input Plugin. With this, you can read lines of a file and apply multiple so-called filters on the events to process them. To index the events (= line of file) you would need to use the Elasticsearch Output Plugin.
As an alternative to Logstash's File Input Plugin you could install and configure Filebeat on the particular host to read the certain file. Since you need to do some processing I recommend to send the data from Filebeat to Logstash. In this scenario, you would need to use Logstash's Beats Input Plugin.

fluentd re-tag events based on log containing a string

We collect json logs with fluentd (to ES) from a source that has multiple types of logs that are all json but have different structure.
I would like to re-tag logs that contain certain strings in any of the keys.
If the keys that would contain this string would be limited, rewrite tag filter would do the job but since the structure of the logs is so different (and in the future new logs structures might appear) would be nice if there was a way to scan every key or better yet just check the whole content of the log rather key based (if that would improve performance).
Is there any way to achieve this at the moment?

Can Beats update existing documents in Elasticsearch?

Consider the following use case:
I want the information from one particular log line to be indexed into Elasticsearch, as a document X.
I want the information from some log line further down the log file to be indexed into the same document X (not overriding the original, just adding more data).
The first part, I can obviously achieve with filebeat.
For the second, does anyone have any idea about how to approach it? Could I still use filebeat + some pipeline on an ingest node for example?
Clearly, I can use the ES API to update the said document, but I was looking for some solution that doesn't require changes to my application - rather, it is all possible to achieve using the log files.
Thanks in advance!
No, this is not something that Beats were intended to accomplish. Enrichment like you describe is one of the things that Logstash can help with.
Logstash has an Elasticsearch input that would allow you to retrieve data from ES and use it in the pipeline for enrichment. And the Elasticsearch output supports upsert operations (update if exists, insert new if not). Using both those features you can enrich and update documents as new data comes in.
You might want to consider ingesting the log lines as is to Elasticearch. Then using Logstash, build a separate index that is entity specific and driven based on data from the logs.

Can I use Kibana to parse the message field

We are using ELK and shoving all syslogs into Elasticsearch.
I have a log type like whose message field looks like:
"message":"11/04/2016 12:04:09 PM|There are now 8 active connections#015"
I would like to use Kibana to parse the message to get the number of active connections over time and then graph that in Kibana.
Am I thinking of how to do this correctly?
The reading I've done seems to be telling me to set up a filter in Logstash...but that seems like the wrong place to parse the message field for this single log line type, given the amount of messages/logs and message/log types getting sent through Logstash.
Is there a way to parse the message field for this number and then graph that count over time in Kibana?
Kibana is not meant to do this kind of parsing. There are a few options you can use:
You could write an analyser that analyses this string. It can be
done, but I would not do it like this.
Use logstash, but you already suggested that yourself. If you feel
log stash is to heavy and you have a choice for the version to use,
go for option three.
Use ingest, this is a new feature of elasticsearch. This is kind of
a lightweight logstash that comes pre-packaged with elastic, it
support patterns with grok that can do this.

Elastic search document storing

Basic usecase that we are trying to solve is for users to be able to search from the contents of the log file .
Lets say a simple situation where user searches for a keyword and this is present in a log file which i want to render it back to the user.
We plan to use ElasticSearch for handling this. The idea that i have in mind is to use elastic search as a mechanism to store the indexed log files.
Having this concept in mind, i went through https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
Couple of questions i have,
1) I understand the input provided to elastic search is a JSON doc. It is going to scan this JSON provided and create/update indexes. So i need a mechanism to convert my input log files to JSON??
2) Elastic search would scan this input document and create/update inverted indexes. These inverted indexes actually point to the exact document. So does that mean, ES would store these documents somewhere?? Would it store them as JSON docs? Is it purely in memory or on file sytem/database?
3) No when user searches for a keyword , ES returns back the document which contains the searched keyword. Now do i need to have the ability to convert back this JSON doc to the original log document that user expects??
Clearly im missing something.. Sorry for asking questions this silly , but im trying to improve my skills and its WIP.
Also , i understand that there is ELK stack out there. For some reasons we just want to use ES and not the LogStash and Kibana part of the stack..
Thanks
Logs needs to be parsed to JSON before they can be inserted into Elasticsearch
All documents are stored on the filesystem and some data is kept in memory but all data is persistent.
When you search Elasticsearch you get back matching JSON documents. If you want to display the original error message, you can store that original message in one of the JSON fields and display just that.
So if you just want to store log messages and not break them into fields or anything, you can simply take each row and send it to Elasticsearch like so:
{ "message": "This is my log message" }
To parse logs, break them into fields and add some logic, you will need to use some sort of app, like Logstash for example.

Resources