This plugin is designed to count occurrences of unique values in a specified key and pass them through as counts either as a re-emit or by directly incrementing a specified redis hash. As it's a buffered plugin it will write or re-emit at a (tunable) sane pace.
Given a set of input like
important.thing.12086 { 'time': 1413544800, 'event': 'seen', 'user_id': 12345 }
important.thing.1337 { 'time': 1413544890, 'event': 'seen', 'user_id': 1337 }
important.thing.12086 { 'time': 1413544830, 'event': 'liked', 'user_id': 33864 }
important.thing.12086 { 'time': 1413544860, 'event': 'clicked', 'user_id': 12345, url: 'http://example.com/promote?someParam=something' }
important.thing.12086 { 'time': 1413544890, 'event': 'seen', 'user_id': 40555 }
important.thing.12086 { 'time': 1413544860, 'event': 'clicked', 'user_id': 12345, url: 'http://example.com/promote?someParam=somethingElse' }
With a conf like
<match important.thing.*>
type eventcounter
count_key event
input_tag_exclude important.thing.
capture_extra_if url
capture_extra_replace \?.*$
emit_only true
emit_tag event.counts
</match>
You would get
event.counts { 12086: { 'seen': 2, 'liked': 1, 'clicked:http://example.com/promote': 2 } }
event.counts { 1337: { 'seen': 1 } }
If the plugin is not set to emit only, and redis is properly configured each of those counts increment a key in a hash specified by redis_output_key
:tag
count_key
##Installation
OSX
/opt/td-agent/embedded/bin/gem install fluent-plugin-eventcounter
or
fluent-gem install fluent-plugin-eventcounter
-
count_key (required)
- The key within the record to count unique instances of
- eg. event
- The key within the record to count unique instances of
-
input_tag_exclude (optional)
- A pattern to exclude from the incoming tag
- default: ''
- A pattern to exclude from the incoming tag
-
emit_only (optional) - boolean
- Skip redis and re-emit using emit_to
- default: false
- Skip redis and re-emit using emit_to
-
emit_to (optional) - string
- Tag to re-emit with
- default: debug.events
- Tag to re-emit with
-
capture_extra_if (optional)
- An additional field to attach to the captured key
- default: nil
- An additional field to attach to the captured key
-
capture_extra_replace (optional)
- A regular expression to replace a portion of the extra capture. (note: this is passed as a string and parsed as a regex so be aware that you may need to escape reserved characters to preserve their meaning.)
- default: ''
- A regular expression to replace a portion of the extra capture. (note: this is passed as a string and parsed as a regex so be aware that you may need to escape reserved characters to preserve their meaning.)
-
redis_host (optional) - string
- Host address of the redis server
- default: localhost
- Host address of the redis server
-
redis_port (optional)
- Port of the redis server ()
- default: 6379
- Port of the redis server ()
-
redis_password (optional)
- Password for the redis server
- default: nil
- Password for the redis server
-
redis_sentinels (optional) - array
- A list of sentinel hosts for failover
- default:
[]
- default:
- A list of sentinel hosts for failover
-
redis_master_group_name (optional) - string
- Sentinel master group name
- default: mymaster
- Sentinel master group name
-
redis_db_number (optional)
- Redis DB (not used if
redis_sentinels
is set)- default: 0
- Redis DB (not used if
-
redis_output_key (optional)
- The key to prefix against the tag
- default: ''
- The key to prefix against the tag
- flush_interval (optional)
- Provided from Fluent::BufferedOutput time in seconds between flushes
- default: 60
- Provided from Fluent::BufferedOutput time in seconds between flushes