简体   繁体   English

在 logstash 中过滤日志并保存到 Elastic Search

[英]Filter logs in logstash and save to Elastic Search

I am dumping all my logs into Elastic Search.我将所有日志都转储到 Elastic Search 中。 It looks like.看起来像。 在此处输入图像描述

Now I want:现在我想要:

  1. Only limited fields should be pushed to ES.只有有限的字段应该被推送到 ES。
  2. Parse message part and add another field log.level: and save the value INFO/DEBUG/ERROR from the message field.解析消息部分并添加另一个字段log.level:并保存消息字段中的值 INFO/DEBUG/ERROR。

Can anyone help me to do that.谁能帮我做到这一点。 I am new to Elastic.我是弹性新手。

My logstash.conf is我的 logstash.conf 是

 input {
      beats {
        port => 5044
       }
    }
 
output {
        if [agent][hostname]=="TEST-PC"{
                elasticsearch {
                        hosts => ["localhost:9200"]
                        manage_template => false
                        index => "INDEXNAME"
                        user => "elastic"
                        password => "password"
              }
          }     
      }

Add this filter section to your logstash config file.将此过滤器部分添加到您的 logstash 配置文件中。

filter {
      grok {
        match => { "message" => "%{TIMESTAMP_ISO8601}\s\[%{NOTSPACE:Meta}\]\s%{WORD:Logtype}\s%{GREEDYDATA:Log_Message}" }
      }
      if "INFO" in [Logtype] {
          drop{}
      }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM