I have been searching through the threads, but I haven't been able to fins a solution. Essentially, I have a log source that ships logs in UTC. I need to adjust them for my timezone, but changing the zone in the logstash config hasn't changed it. The logs show up in Kibana with a timestamp that is offset by the exact amount of my timezone. I'm sure it must be something simple.
OK, I misunderstood. If your syslog entries are arriving with a timestamp in UTC then that syslog input should be OK and you would not need a date filter. They would be stored in elasticsearch as UTC and kibana (with the default settings) would translate them into the timezone where kibana runs.
Maybe that's the problem - my device isn't actually sending in UTC. I will verify that again. If it is actually sending in a different time zone, say EST, would the following be what is required?
If the date is in the right format then the syslog filter will parse it and that is where you would set the timezone. There would be no need for a date filter in that case. However in the format you have you will need to use a date filter.
I re-read the docs on the syslog plugin and saw that logstash will only accept RFC3164, not RFC5424.
I modified my config file as shown below:
filter {
date {
match => ["GeneratedTime", "yyyy/MM/dd HH:mm:ss"]
timezone => "America/New_York"
}
{...}
}
I rebooted the VM to ensure all services were restarted after my config change, however, the timestamp remains unchanged when displayed in Kibana. I'm still missing something...
By default the date filter sets @timestamp and does not modify the parsed field, so we would expect GeneratedTime to remain a string.
If you use target to tell the date filter to overwrite GeneratedTime then the format in elasticsearch will change, however, since it has already been mapped as a string it will remain a string. But if you start over with an empty index it will be a date.
Ok. More progress. I have my filter config as shown:
filter {
date {
match => ["GeneratedTime", "yyyy/MM/dd HH:mm:ss"]
timezone => "America/New_York"
target => "GeneratedTime"
}
If I set the Time Filter field name to @timestamp on the index pattern, the logs show up in the correct time. However, if I use "GeneratedTime" they do not. Is there something wrong with they way I am using the target?
Also, I have deleted the indexes after each change.
Thank you for you suggestion. However, that doesn't help much in my case as I am not trying to name the files as such. I think what I need to do is overwrite my 'GeneratedTime' field with the corrected time from the same field.
Your case is not the same as the one in the other post, but I still think the ruby filter will do what you need.
Replace @timestamp with your GeneratedTime and filename with a variable of your choice, e.g. GeneratedTime, and you will get the time in your time zone. You'll have to play with the format in ...strftime('%Y-%m-%d/%H')), but that's 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.