Filebeat: Outputting to different outputs depending on the document type - elasticsearch

So I'm reading in several different file types using Filebeat. I set the document_type for each kind of file I am harvesting. My problem is that I want to send most of these file types to Logstash, but there are certain types I wish to send directly to Elasticsearch.
Is it possible to select the output depending on file type? I know multiple outputs are allowed, but this sends all the data into both elasticsearch and logstash so it's going to get inserted into Elasticsearch twice, which will take up too much space. Thanks!

Filebeat ships events to one endpoint, all routing should be done in Logstash.

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.

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

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.

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.

Track data from multiple log files using Logstash and Elasticsearch and mapping in kibana

I am using filebeat to send multiple files to Logstash but I am not able to map which file has which status So what are the possible ways to track mapped data for each log file.
You can use source field which is coming from filebeat to filter your logs. Please check the documentation for more information.
The file from which the line was read. This field contains the full path to the file. For example: /var/log/system.log.
You can give not_analyzed property for this field to filter more effectively.

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.

Resources