0

通过 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对象的内容被解码。

非常感谢

4

1 回答 1

0

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

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

于 2016-07-01T18:37:47.487 回答