Use the grok filter to parse the log lines and extract the timestamp to a separate field. Feed that field to the date filter. It'll parse and store the timestamp in the @timestamp field which always is UTC.
We have below pattern defined to parse the log message
CF_DIRECT_PULL_FORMAT %{TIMESTAMP_ISO8601:timestamp} [%{CF_LOG_TYPE}]%{SPACE}%{WORD}%{SPACE}([%{CF_WLP_LOG_LEVEL:loglevel}%{SPACE}])?%{GREEDYDATA:details}
We have two fields in the viewlet to display the logs in Kibana dashboard.
First field is @timestamp and second is message.
I want to modify the timestamp in message filed to UTC format.
Split original message field to timestamp and sub_message with grok:
grok {
match => [ "message", "%{TIMESTAMP_ISO8601:timestamp} %{GREEDYDATA:sub_message}" ]
remove_field => [ "message" ]
}
Parse timestamp field with date filter.
Create new field message from @timestamp and sub_message:
if [sub_message] {
mutate {
add_field => { "message" => "%{@timestamp} %{sub_message}" }
}
}
Can we have multiple grok statements in conf file, because I already have below
grok {
match => {"details" => "[DWPerf-%{WORD}][UN-%{GREEDYDATA:userid}][SI-%{GREEDYDATA:sessionid}]%{GREEDYDATA:details}%{NUMBER:elapsed_time}s"}
overwrite => [ "details" ]
}
mutate {
convert => { "elapsed_time" => "float" }
}
Where's your date filter? That's what converts your UTC-5 timestamp into UTC so that you can put it back into message.
CF_DIRECT_PULL_FORMAT2 is the name of a grok pattern but you're treating it like the name of a field.
Don't post screenshots from Kibana. Post the output from a stdout { codec => rubydebug } output. ES and Kibana will only distract you. Reintroduce them when you've verified that the events looks as expected.
When you use add_field on the message field you'll actually turn that field into an array that'll contain both the original value and the new value. Use replace instead.
Follow Kirill's example more closely. Except for the add_field thing his example looks perfectly correct.
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.