任何与十进制时间戳匹配的 Elasticsearch 数据类型



>我有一个来自日志文件的时间戳,例如 {"ts" : "1486418325.948487"}我的基础设施是"filebeat" 5.2.0 --> "elasticsearch" 5.2

我尝试将"ts"映射到"date"-"epoch_second",但es在filebeat中写入失败。

PUT /auth_auditlog
{
  "mappings": {
    "auth-auditlogs": {
      "properties": {
        "ts": {
          "type":   "date",
          "format": "epoch_second"
        }
      }
    }
  }
}

文件节拍错误消息,例如

WARN Can not index event (status=400): {"type":"mapper_parsing_exception","reason":"failed to parse [ts]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: "1486418325.948487""}}

我尝试使用"1486418325"是可以的,所以我想 es 不接受十进制格式的时间戳。但是,python 默认输出时间戳是这种格式。

我的目的是在 elasticsearch 中正确键入。我想在弹性搜索中使用ts作为原始时间戳。除了更改原始日志数据外,欢迎任何解决方案!

Filebeat没有用于此类内容的处理器。您不能将@timestamp替换为日志在 Filebeat 中具有的。你可以做的,就是把这些东西发送到logstash,让date过滤器解析纪元。

date {
  match => ["timestamp","UNIX","UNIX_MS"]
}

另一种选择是使用采集节点。虽然我自己没有用过这个,但它似乎也能完成这项工作。在此处查看文档。

最新更新