Convert Timestamp Timezone in Logstash for Output Index Name

Convert timestamp timezone in Logstash for output index name

This is the optimize config, please have a try and test for the performance.

You no need to use mutate and date plugin. Use ruby plugin directly.

input {
stdin {
}
}

filter {
ruby {
code => "
event['index_day'] = event['@timestamp'].localtime.strftime('%Y.%m.%d')
"
}
}

output {
stdout { codec => rubydebug }
}

Example output:

{
"message" => "test",
"@version" => "1",
"@timestamp" => "2015-03-30T05:27:06.310Z",
"host" => "BEN_LIM",
"index_day" => "2015.03.29"
}

how to define timezone in logstash timestamp

I have tried to change timezone as Istanbul but not working fine. Instead of giving Timezone area we can also define time difference like below

timezone => "-0000"

That solved my question.

Timezone offset with logstash / redis / ES

You can use this filter to change timezone.
Change

"@timestamp": "2014-04-23T13:40:29.000Z"

to

"@timestamp": "2014-04-23T15:40:29.000+0200"

Try to use this filter

filter {
ruby {
code => "
event['@timestamp'] = event['@timestamp'].localtime('+02:00')
"
}
}

Hope this can help you.



Related Topics



Leave a reply



Submit