【问题标题】:logstash json filter sourcelogstash json过滤器源
【发布时间】:2016-07-02 02:37:47
【问题描述】:

当通过 filebeat 接收时,我无法从我的 json 日志行中获取要解码的消息字段。

这是我日志中的一行:

{"levelname": "WARNING", "asctime": "2016-07-01 18:06:37", "message": "One or more gateways are offline", "name": "ep.management.commands.import", "funcName": "check_gateway_online", "lineno": 103, "process": 44551, "processName": "MainProcess", "thread": 140735198597120, "threadName": "MainThread", "server": "default"}

这里是logstash 配置。我尝试使用和不使用codec。唯一不同的是,当我使用编解码器时,消息被转义了。

 input {
  beats {
    port => 5044   
    codec => "json"
  }
}

filter {
 json{
 source => "message"
 }
}

这是到达 elasticsearch 的 json:

    {
  "_index": "filebeat-2016.07.01",
  "_type": "json",
  "_id": "AVWnpK519vJkh3Ry-Q9B",
  "_score": null,
  "_source": {
    "@timestamp": "2016-07-01T18:07:13.522Z",
    "beat": {
      "hostname": "59b378d40b2e",
      "name": "59b378d40b2e"
    },
    "count": 1,
    "fields": null,
    "input_type": "log",
    "message": "{\"levelname\": \"WARNING\", \"asctime\": \"2016-07-01 18:07:12\", \"message\": \"One or more gateways are offline on server default\", \"name\": \"ep.controllers.secure_client\", \"funcName\": \"check_gateways_online\", \"lineno\": 80, \"process\": 44675, \"processName\": \"MainProcess\", \"thread\": 140735198597120, \"threadName\": \"MainThread\"}",
    "offset": 251189,
    "source": "/mnt/ep_logs/ep_.json",
    "type": "json"
  },
  "fields": {
    "@timestamp": [
      1467396433522
    ]
  },
  "sort": [
    1467396433522
  ]
}

我想要的是 message 对象的内容被解码。

非常感谢

【问题讨论】:

  • 您确定您的 filebeat 实例没有直接向 ES 发送文档吗?您的 filebeat 配置如何?您的 Filebeat 配置文件中是否启用了 elasticsearch 输出?
  • 你是个天才。你怎么会知道?非常感谢。有没有办法结束这个问题?

标签: elasticsearch logstash filebeat


【解决方案1】:

发生这种情况时,通常是因为您的 Filebeat 实例被配置为直接将文档发送到 ES。

在您的 filebeat 配置文件中,确保注释掉 elasticsearch 输出。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多