Convert timestamp timezone in Logstash for output index name

后端 未结 4 1412
一个人的身影
一个人的身影 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:23

    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"
    }
    

提交回复
热议问题