So the thing is I have filebeat that ship the log file to logstash then to the elasticsearch cluster. And I created the data view the get the messages on the discover page. I wonder where this @timestamp field comes from? Is the time elasticsearch received the message? or the time logstash received the message? or filebeat scanned the message?
@timestamp is from LS, they explained how is generated.
I assume you are confused why you have time difference. If you like to update @timestamp to correct value-from a log, you have to parse the message, extract date from the begging, 2nd field is IP of something, etc.
So, you need grok or dissect to split the message in the fields.
After that convert 1. field to date format and overwrite @timestamp. This is how you will have @timestamp from the log file.
date {
match => [ "timestamp", "MMM d HH:mm:ss.SSS", "MMM dd HH:mm:ss.SSS" ]
timezone => "Asia/Dubai" # optionally
target=> "@timestamp" # this is default
}
Hi @rios, Actually if he is using Filebeat -> Logstash -> Elasticsearch the @timestamp is from Filebeat
But I agree ... the user probably wants to use the timestamp from withing the message as you showed, then the @timestamp will most accurately match the data in the log.
The reason I am doing this is I want to find a way to show the logs in the Kibana in order. So I am thinking it could help if the @timestamp comes from Filebeat since Filebeat reads the file line by line.
I wonder if the @timestamp comes from Filebeat, then the message shown on the Kibana should be ordered if I sort by @timestamp
So I have created a file named b.log and this is its content:
Did you set the number of workers to 1 ? Logstash per default will process filters and outputs in parallel and does not guarantee event order.
You need to set pipeline.workers to 1 in your pipelines.yml for the pipeline you want to keep the order.
But even doing this, I'm not sure that the order is guaranteed in Kibana since you may have events with the same @timestamp value and they may be shown out of order.
I did not set the workers to 1. I remembered that it will affect the performance if set to 1?
But even doing this, I'm not sure that the order is guaranteed in Kibana since you may have events with the same @timestamp value and they may be shown out of order.
I did not release the fact the messages will be out of order if the @timestamp values are the same! This is actually the reason and explains my previous post's issues.
But how should I guarantee the order? Or, this is not recommended to do in Elasticsearch?
Yes, it could affect the performance, the processing will be done by 1 worker only and sequentially, not in parallel.
It really depends on your data, you would need to be able to have another field to sort on, for example, you could parse your message and put the value after connection reset on a field and sort using this field as well.
For elastic it makes no difference, it really depends on your data and what you want to do with it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.