# fluent-plugin-cat-sweep
[![Build Status](https://secure.travis-ci.org/civitaspo/fluent-plugin-cat-sweep.png?branch=master)](http://travis-ci.org/civitaspo/fluent-plugin-cat-sweep)
Fluentd plugin to read data from files and to remove or move after processing.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'fluent-plugin-cat-sweep'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install fluent-plugin-cat-sweep
## Basic Behavior
Assume that an application outputs logs into `/tmp/test` directory as
```
tmp/test
├── accesss.log.201509151611
├── accesss.log.201509151612
└── accesss.log.201509151613
```
in every one minute interval.
This plugin watches the directory (`file_path_with_glob tmp/test/access.log.*`), and reads the contents and sweep (deafault: remove) for files whose mtime are passed in 60 seconds (can be configured with `waiting_seconds`).
Our assumption is that this mechanism should provide more durability than `in_tail` (batch read overcomes than streaming read).
## Potential problem of in_tail
Assume that an application outputs logs into `/tmp/test/access.log` and rotates it in every one minute interval as
(initial state)
```
tmp/test
└── accesss.log (i-node 4478316)
```
(one minute later)
```
tmp/test
├── accesss.log (i-node 4478319)
└── accesss.log.1 (i-node 4478316)
```
(two minutes later)
```
tmp/test
├── accesss.log (i-node 4478322)
├── accesss.log.1 (i-node 4478319)
└── accesss.log.2 (i-node 4478316)
```
Your configuration of `in_tail` may become as followings:
```apache
```
Now, imagine that the fluentd process dies (or manually stops for maintenance) just before the 2nd file of i-node 4478319 is generated, and you restart the fluentd process after two minutes passed. Then, you miss the 2nd file of i-node 4478319.
(initial state)
```
tmp/test
└── accesss.log (i-node 4478316) <= catch
```
(fluentd dies)
(one minute later)
```
tmp/test
├── accesss.log (i-node 4478319) <= miss
└── accesss.log.1 (i-node 4478316)
```
(two minutes later)
(fluentd restarts)
```
tmp/test
├── accesss.log (i-node 4478322) <= catch
├── accesss.log.1 (i-node 4478319) <= miss
└── accesss.log.2 (i-node 4478316)
```
## Configuration
```
```
## ChangeLog
[CHANGELOG.md](CHANGELOG.md)
## Warning
* This plugin supports fluentd from v0.10.45
* The support for fluentd v0.10 will end near future
## Contributing
1. Fork it ( https://github.com/civitaspo/fluent-plugin-cat-sweep/fork )
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 a new Pull Request