Convert timestamp timezone in Logstash for output index name

后端 未结 4 1320
一个人的身影
一个人的身影 2021-01-01 02:47

In my scenario, the \"timestamp\" of the syslog lines Logstash receives is in UTC and we use the event \"timestamp\" in the Elasticsearch output:

output {
           


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 03:24

    In version 1.5.0, we can convert timestamp by local timezone for the index name. Here is my configuration:

    filter {
        ruby {
            code => "event['index_day'] = event.timestamp.time.localtime.strftime('%Y.%m.%d')"
        }
    }
    output {
        elasticsearch {
            host => localhost
            index => "thrall-%{index_day}"
        }
    }
    

提交回复
热议问题