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
Installing Libyaml for Ruby on a MAC Osx (Lion)
Specifying Content Type in Rspec
What Do 'Def +@' and 'Def -@' Mean
What Are Symbols and How Do We Use Them
Get, or Calculate the Entropy of an Image with Ruby and Imagemagick
Multi Level Block Method Is Generating Issue
Ruby Keyword Arguments of Method
Rails Generate Error: No Such File or Directory - Getcwd
Unicode Characters in a Ruby Script
Ruby on Rails: Search Form - Multiple Search Fields
How to Require a Block in Ruby
How to Loop Through Months in Ruby on Rails
Spacing Around Parentheses in Ruby
Change String in a Date Format to Another Format
Rails: Get Values of Http Response
Automatic Associations in Ruby on Rails Fixtures
Your Ruby Version Is 2.2.4, But Your Gemfile Specified 2.3.0