如何删除 filebeat 标签,如 id、主机名、版本grok_failure消息



我是麋鹿的新手,我的示例日志看起来像

2017-01-05T14:28:00 INFO zeppelin IDExtractionService transactionId abcdef1234 operation extractOCRData received request duration 12344 exception error occured

我的文件节拍配置如下

filebeat.prospectors:
- input_type: log
  paths:
    - /opt/apache-tomcat-7.0.82/logs/*.log
document_type: apache-access
fields_under_root: true
output.logstash:
  hosts: ["10.2.3.4:5044"]

还有我的 logstash filter.conf 文件:

filter {
  grok {
    match => [ "message", "transactionId %{WORD:transaction_id} operation %{WORD:otype} received request duration %{NUMBER:duration} exception %{WORD:error}" ]
  }
}
filter {
    if "beats_input_codec_plain_applied" in [tags] {
        mutate {
            remove_tag => ["beats_input_codec_plain_applied"]
        }
    }
}

;在 kibana 仪表板中,我可以看到日志输出如下

beat.name:
    ebb8a5ec413b
beat.hostname:
    ebb8a5ec413b
host:
    ebb8a5ec413b
tags:
beat.version:
    6.2.2
source:
    /opt/apache-tomcat-7.0.82/logs/IDExtraction.log
otype:
    extractOCRData
duration:
    12344
transaction_id:
    abcdef1234
@timestamp:
    April 9th 2018, 16:20:31.853
offset:
    805,655
@version:
    1
error:
    error
message:
    2017-01-05T14:28:00 INFO zeppelin IDExtractionService transactionId abcdef1234 operation extractOCRData received request duration 12344 exception error occured
_id:
    7X0HqmIBj3MEd9pqhTu9
_type:
    doc
_index:
    filebeat-2018.04.09
_score:
    6.315 

1第一个问题是如何删除文件节拍标签,如id,主机名,版本grok_failure消息

2 如何基于时间戳对日志进行排序,因为新生成的日志未显示在 Kibana 仪表板顶部

3 我的 grok 过滤器是否需要进行任何更改

您可以通过

在 filebeat 配置文件中设置 fields_under_root: false 的值来删除filebeat标签。您可以在此处阅读有关此选项的信息。

如果此选项设置为 true,则自定义域存储为 输出文档中的顶级字段,而不是分组在 字段子字典。如果自定义域名称与其他名称冲突 由 Filebeat 添加的字段名称,自定义字段将覆盖其他字段 领域。

您可以使用、if "_grokparsefailure" in [tags]检查_grokparsefailure是否在标签中,然后remove_tag => ["_grokparsefailure"]将其删除

您的 grok 过滤器似乎没问题。

希望对您有所帮助。

最新更新