关于时间戳:如何在Elasticsearch 5.x和Filebeat中解析日期

How to parse date in elasticsearch 5.x and Filebeat

我正在使用elasticsearch 5.x和Filebeat,想知道是否有一种直接在filebeat中解析日期(时间戳)的方法(不想使用Logstash)。我正在使用json.keys_under_root: true,并且效果很好,但是问题是(我们上的)时间戳被识别为字符串。其他所有字段都会自动识别为正确的类型,只有这不是。 enter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
PUT _ingest/pipeline/my-pipeline
{
 "description" :"parse timestamp and update @timestamp",
 "processors" : [
    {
     "date" : {
       "field" :"timestamp",
       "target_field" :"@timestamp"
      }
    },
    {
     "remove": {
       "field":"timestamp"
      }
    }
  ],
 "on_failure": [
    {
     "set": {
       "field":"error.message",
       "value":"{{ _ingest.on_failure_message }}"
      }
    }
  ]
}

然后在Filebeat中配置elasticsearch输出以将数据推送到新管道。

1
2
3
output.elasticsearch:
  hosts: ["http://localhost:9200"]
  pipeline: my-pipeline