1

我知道我们可以在 metricbeat.yml 文件中添加自定义字段,

fields:
  customfield1: value1
  customfield2: value2

然后 JSON 输出将生成为,

{
  "@timestamp": "2018-03-15T17:00:04.392Z",
  "@metadata": {
    "beat": "metricbeat",
    "type": "doc",
    "version": "6.2.2"
  },
  "metricset": {
    "rtt": 801,
    "name": "status",
    "module": "kibana",
    "host": "localhost:5601"
  },
  "error": {
    "message": "error making http request: Get http://localhost:5601/api/status: dial tcp [::1]:5601: getsockopt: connection refused"
  },
  "fields": {
    "customfield1": "value1",
    "customfield2": "value2"
  },
  "beat": {
    "name": "TheNameOfBeat",
    "hostname": "localhost",
    "version": "6.2.2"
  }
}

但我想将自定义字段添加到 JSON 消息的源中,而不是在“字段”对象中。这可能吗?

就像是,

{
      "@timestamp": "2018-03-15T17:00:04.392Z",
      "customfield1": "value1",
      "customfield2": "value2",
      "@metadata": {
        "beat": "metricbeat",
        "type": "doc",
        "version": "6.2.2"
      },
      "metricset": {
        "rtt": 801,
        "name": "status",
        "module": "kibana",
        "host": "localhost:5601"
      },
      "error": {
        "message": "error making http request: Get http://localhost:5601/api/status: dial tcp [::1]:5601: getsockopt: connection refused"
      },
      "beat": {
        "name": "TheNameOfBeat",
        "hostname": "localhost",
        "version": "6.2.2"
      }
    }
4

1 回答 1

1

在如何解析 Kibana 的自定义 Metricbeat 字典中找到解决方案? 需要将fields_under_root选项设置为true

于 2018-03-15T17:21:46.250 回答