Class: LogStash::Filters::Mixpanel

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/mixpanel.rb

Overview

This example filter will replace the contents of the default message field with whatever you specify in the configuration.

It is only intended to be used as an example.

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/logstash/filters/mixpanel.rb', line 41

def filter(event)

  result = fetch_data
  if !result.nil?
    event[@target] = result

    # filter_matched should go in the last line of our successful code
    filter_matched(event)
  else
    @tag_on_failure.each do |tag|
      event['tags'] ||= []
      event['tags'] << tag unless event["tags"].include?(tag)
    end
  end
end

#registerObject



33
34
35
36
37
38
# File 'lib/logstash/filters/mixpanel.rb', line 33

def register
  @mp = Mixpanel::Client.new(
    api_key: @api_key,
    api_secret: @api_secret
  )
end