【问题标题】:Un-breaking an analyzed field in kibana在 kibana 中解开已分析的字段
【发布时间】:2016-02-03 17:36:41
【问题描述】:

我有一个 ELK 堆栈,它接收来自 filebeat 结构化 JSON 日志,如下所示:

{"what": "Connected to proxy service", "who": "proxy.service", "when": "03.02.2016 13:29:51", "severity": "DEBUG", "more": {"host": "127.0.0.1", "port": 2004}}
{"what": "Service registered with discovery", "who": "proxy.discovery", "when": "03.02.2016 13:29:51", "severity": "DEBUG", "more": {"ctx": {"node": "igz0", "ip": "127.0.0.1:5301", "irn": "proxy"}, "irn": "igz0.proxy.827378e7-3b67-49ef-853c-242de033e645"}}
{"what": "Exception raised while setting service value", "who": "proxy.discovery", "when": "03.02.2016 13:46:34", "severity": "WARNING", "more": {"exc": "ConnectionRefusedError('Connection refused',)", "service": "igz0.proxy.827378e7-3b67-49ef-853c-242de033e645"}}

作为嵌套 JSON 的“more”字段在 kibana 中被分解(不确定堆栈的哪一部分)为不同的字段(“more.host”、“more.ctx”等)。

这是我的节拍输入:

input {
  beats {
    port => 5044
  }
}
filter {
  if [type] == "node" {
    json {
      source => "message"
      add_field => {
        "who" => "%{name}"
        "what" => "%{msg}"
        "severity" => "%{level}"
        "when" => "%{time}"
      }
    }
  } else {
    json {
      source => "message"
    }
  }
  date {
    match => [ "when" , "dd.MM.yyyy HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"]
  }
}

这是我的输出:

output {
  elasticsearch {
    hosts => ["localhost"]
    sniffing => true
    manage_template => false
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
  stdout { codec => rubydebug }
}

有什么方法可以创建一个包含整个“更多”字段而不将其分开的字段?

【问题讨论】:

    标签: json elasticsearch logstash kibana elastic-stack


    【解决方案1】:

    您应该能够使用 ruby​​ 过滤器获取哈希并将其转换回字符串。

    filter {
       ruby {
          code => "event['more'] = event['more'].to_s"
       }
    }
    

    您可能希望用if 将其括起来以确保该字段首先存在。

    【讨论】:

    • 我应该在哪里添加这个过滤器?
    • 介于input{}output{} 之间...很难说没有看到你的配置文件。
    猜你喜欢
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-15
    • 1970-01-01
    相关资源
    最近更新 更多