美文网首页
FileBeat向elasticsearch传入数据,并使用GR

FileBeat向elasticsearch传入数据,并使用GR

作者: 早点起床晒太阳 | 来源:发表于2020-12-11 19:29 被阅读0次

背景

最近在捣鼓Filebeat监听springboot的日志然后将其传入到es中。这个时候日志肯定要切分单独字段存储。这个时候用到了es自带的ingest node pipeline 功能,使用grok 使用正则将log进行切分

具体实现

参考资料:https://www.elastic.co/guide/en/beats/filebeat/current/configuring-ingest-node.html

这篇文档很详细了说明了Filebeat怎么去传入数据

1、配置filebeat.yml

添加如下配置

output.elasticsearch:
  pipeline: "test-pipeline"  //这里这个名称和es上注册pipeline的名称相同

2、在es上注册pipeline

根据对应的json文件注册pipeline,使用命令

curl -H "Content-Type: application/json" -XPUT 'http://10.130.7.207:9200/_ingest/pipeline/test-pipeline' -d@/home/hadoop/zgh/log/pipeline.json

这样的话就可以了,在对应的pipeline.json写上相应的grok就可以了。

对应的json文件阳历(会在grok相关文章详细解释)

{
  "description" : "test-pipeline",
  "processors": [
      {
        "grok": {
           "field": "message",
           "patterns": ["%{TIMESTAMP_ISO8601:client}    %{GREEDYDATA:method}    %{LOGLEVEL:request}    %{GREEDYDATA:demo}    %{ALL_CODE:messageaaa}" ],
           "pattern_definitions" : {
                "ALL_CODE" : "(.|\n)*"
        }
      }
    }
  ]
}

相关文章

网友评论

      本文标题:FileBeat向elasticsearch传入数据,并使用GR

      本文链接:https://www.haomeiwen.com/subject/smhsgktx.html