Sha256: 83ca3d28da1b9feee5075c2f200c9904571646bc85b40439360d3c9c58750903

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

# fluent-plugin-unit-time-filter

Plug-in to aggregate by unit time

[![Gem Version](https://badge.fury.io/rb/fluent-plugin-unit-time-filter.png)](http://badge.fury.io/rb/fluent-plugin-unit-time-filter)
[![Build Status](https://drone.io/bitbucket.org/winebarrel/fluent-plugin-unit-time-filter/status.png)](https://drone.io/bitbucket.org/winebarrel/fluent-plugin-unit-time-filter/latest)

## Configuration

```
<match my.**>
  type unit_time_filter
  filter_path /foo/bar/my_filrer.rb
  unit_sec 10
  #prefix filtered
  #emit_each_tag false
  #pass_hash_row false
  #hash_row_time_key time
  #hash_row_tag_key tag
</match>

<match filtered.my.**>
  type stdout
</match>
```

## Filter

```ruby
# Count the number of records of every unit time

proc {|records|

  # `records` is an Array such as:
  #   [[tag, time, record], [tag, time, record], ...]
  #
  # e.g.)
  #   [["my.data", 1391820170, {"hoge"=>"fuga"}],
  #    ["my.data", 1391820170, {"hoge"=>"fuga"}],
  #    ["my.data", 1391820170, {"hoge"=>"fuga"}],
  #    ...

  {'count' => records.count}
  # or [{...},{...},{...}, ...]
}
```

## Usage

Run the following command:

```sh
while true; do
  echo '{"hoge":"fuga"}' | fluent-cat my.data
done
```

fluentd outputs the following:

```
2014-02-08 00:38:40 +0900 filtered.my.data: {"count":42}
2014-02-08 00:38:50 +0900 filtered.my.data: {"count":43}
2014-02-08 00:39:00 +0900 filtered.my.data: {"count":41}
...
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-unit-time-filter-0.1.1 README.md
fluent-plugin-unit-time-filter-0.1.0 README.md