我在@timestamp字段中为elasticsearch / filebeat获取了错误的值。我的文件管道定义
curl -H 'Content-Type: application/json' -XPUT "logger:9200/_ingest/pipeline/app_log" -d'
{
"description" : "Ingest pipeline for Jetty server log",
"processors" : [
{
"grok": {
"field": "message",
"patterns": ["%{TIMESTAMP_ISO8601:timestamp} (%{UUID:accessid})? \\[(?<threadname>[^\\]]+)\\] %{LOGLEVEL:level} %{DATA:classname} - %{GREEDYDATA:message}"]
}
},
{
"date": {
"field": "timestamp",
"formats": [ "yyyy-mm-dd H:m:s,SSS" ]
}
}
],
"on_failure" : [{
"set" : {
"field" : "error.message",
"value" : "{{ _ingest.on_failure_message }}"
}
}]
}'
某些样本记录器线的仿真结果。 (使用logback配置)
curl -H 'Content-Type: application/json' -XPOST "logger:9200/_ingest/pipeline/app_log/_simulate?pretty" -d'
{
"docs": [
{
"_source": {
"message": "2018-03-17 22:38:39,079 bab3157d-a11c-4dba-a6d6-c47ae0de2b7f [qtp224100622-174782] INFO i.n.core.services.cache.CacheBuilder - Key : ChIJrTTTJkdsrjsRXkrYRKRRfd8-seo-localitiesv1 is returned from cache"
}
},
{
"_source": {
"message": "2017-12-12 01:14:12,079 [qtp224100622-185269] WARN i.n.m.cache.sdk.RedisCacheProvider - No matching policy: class in.nobroker.core.domain.Token"
}
}
]
}'
这个模拟的结果:
{“docs”:[{“doc”:{“_ index”:“_ index”,“_ type”:“_ type”,“_ id”:“_ id”,“_ source”:{“accessid”:“bab3157d-a11c- 4dba-a6d6-c47ae0de2b7f“,”@ timestamp“:”2018-01-17T22:38:39.079Z“,”classname“:”incore.services.cache.CacheBuilder“,”level“:”INFO“,”message “:”键:ChIJrTTTJkdsrjsRXkrYRKRRfd8-seo-localitiesv1从缓存中返回“,”timestamp“:”2018-03-17 22:38:39,079“,”threadname“:”qtp224100622-174782“},”_ ingest“:{” timestamp“:”2018-03-17T15:35:35.543Z“}}},{”doc“:{”_ index“:”_ index“,”_ type“:”_ type“,”_ id“:”_ id“,” _source“:{”@ timestamp“:”2017-01-12T01:14:12.079Z“,”classname“:”inmcache.sdk.RedisCacheProvider“,”level“:”WARN“,”message“:”不匹配policy:class in.nobroker.core.domain.Token“,”timestamp“:”2017-12-12 01:14:12,079“,”threadname“:”qtp224100622-185269“},”_ ingest“:{”timestamp“ :“2018-03-17T15:35:35.543Z”}}}]}
请注意,@ timestamp字段与timestamp字段完全不同。
似乎你提供了错误的日期格式
{
"date": {
"field": "timestamp",
"formats": [ "yyyy-mm-dd H:m:s,SSS" ]
}
}
由于doc显示“mm:两位数分钟,如果需要,则填充零填充”而不是您预期的月份。尝试
{
"date": {
"field": "timestamp",
"formats": [ "yyyy-MM-dd H:m:s,SSS" ]
}
}
Filebeat没有日期处理器。 Elasticsearch有处理器。要在filebeat中使用日志中的时间戳作为@timestamp,请使用Elasticsearch中的摄取管道。