Giter Site home page Giter Site logo

logstash-deduplication's Introduction

Link do wpisu: https://wiadrodanych.pl/big-data/deduplikacja-zdarzen-logstash-redis/

本来想借鉴此方法,后面发现用logstash内置filter:fingerprint + memcached,可以实现去重功能


  ### fingerprint 和 memcached 实现去重(dedupe)功能begin
  fingerprint {
    source => [ "cjdate", "gddm", "zqdm", "wtid", "cjid" ]
    target => "[fingerprint]"
    concatenate_sources => true
    method => "SHA1"
  }

  memcached {
      id => "memcached-getfp"
      hosts => ["127.0.0.1:11211"]
      namespace => "dedupe"
      get => {"%{fingerprint}" => "[cjexists]"}
  }

  if [cjexists] {
    mutate { add_tag => [ "dedupe" ] }
    # memcached 根据 fingerprint 如果查回来cjexists字段,表明为重复记录,加tag,也可以直接drop{}
  } else {
    memcached {
      hosts => ["127.0.0.1:11211"]
      namespace => "dedupe"
      ttl => 28800                          # ttl一定要配否则内存爆,28800秒=8小时
      set => { "gddm" => "%{fingerprint}" } # 存什么字段不重要,这里是存的股东代码
      id => "memcached-setfp"
   }
  }
  ### fingerprint 和 memcached 实现去重(dedupe)功能end
  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.