【问题标题】:Logstash Duplicate DataLogstash 重复数据
【发布时间】:2021-07-19 19:53:09
【问题描述】:

我在 Logstash 中有重复数据

我怎样才能删除这个重复?

我的输入是:

输入

input {
  file {
    path => "/var/log/flask/access*"
    type => "flask_access"
    max_open_files => 409599
  }
  stdin{}
}

过滤器

文件过滤器是:

filter {
  mutate { replace => { "type" => "flask_access" } }
  grok {
    match => { "message" => "%{FLASKACCESS}" }
  }
  mutate {
    add_field => {
      "temp" => "%{uniqueid} %{method}"
    }
  }
   if "Entering" in [api_status] {
     aggregate {
       task_id => "%{temp}"
       code => "map['blockedprocess'] = 2"
       map_action => "create"
     }
   }
   if "Entering" in [api_status] or "Leaving" in [api_status]{
     aggregate {
       task_id => "%{temp}"
       code => "map['blockedprocess'] -= 1"
       map_action => "update"
     }
   }
   if "End Task" in [api_status] {
     aggregate {
       task_id => "%{temp}"
       code => "event['blockedprocess'] = map['blockedprocess']"
       map_action => "update"
       end_of_task => true
       timeout => 120
     }
   }
 }

看图,同样的数据日志,同时,我只是发送了一个日志请求。

【问题讨论】:

    标签: elasticsearch duplicates logstash kibana


    【解决方案1】:

    我解决了

    我在输出部分通过 ('document_id') 创建一个唯一 ID

    document_id 指向我的 temp,temp 是我在项目中的唯一 id

    我的输出变为:

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

    【讨论】:

    【解决方案2】:

    在我的本地实验室执行测试,我刚刚发现logstash 对保存在/etc/logstash/conf.d 目录中的配置文件的数量很敏感。 如果配置文件多于 1 个,那么我们可以看到同一记录的重复。

    因此,尝试从 /etc/logstash/conf.d 目录中删除所有备份配置并执行 logstash 重启。

    【讨论】:

      猜你喜欢
      • 2022-08-23
      • 2020-07-21
      • 1970-01-01
      • 2015-12-06
      • 1970-01-01
      • 2017-11-12
      • 2019-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多