https://github.com/devops-works/telegraf-tailcount
Counts new lines in growing file and return InfluxDB metrics on STDOUT.
https://github.com/devops-works/telegraf-tailcount
Last synced: 6 months ago
JSON representation
Counts new lines in growing file and return InfluxDB metrics on STDOUT.
- Host: GitHub
- URL: https://github.com/devops-works/telegraf-tailcount
- Owner: devops-works
- Created: 2022-10-23T18:59:43.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-23T20:23:55.000Z (over 3 years ago)
- Last Synced: 2024-06-21T08:24:47.721Z (almost 2 years ago)
- Language: Go
- Size: 25.4 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# telegraf tailcount
Counts lines in growing file and return metrics on STDOUT.
Use with [`execd`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/execd) plugin.
## Why ?
Mainly because apache ReqPerSec from mod_status is totally [useless](https://stackoverflow.com/questions/4630654/apache2-server-status-reported-value-for-requests-sec-is-wrong-what-am-i-doi).
## Usage
### Invocation
```
Usage: telegraf-tailcount [options] file
Options:
-i int Interval in seconds (default 10)
-p int Peak interval in seconds (default 1)
-m string Measurement name (default 'tailcount')
-t string Comma-separated k=p pairs for tags (default 'file=')
```
e.g.:
```
$ telegraf-tailcount -t foo=bar -i 10 -p 1 /tmp/log
tailcount,file=/tmp/log,foo=bar sum=31,max=5,min=1
tailcount,file=/tmp/log,foo=bar sum=35,max=6,min=1
...
```
- _Interval_ is the metric output interval on STDOUT.
- _Peak interval_ is the interval for which telegraf-tailcount will compute min,
mean, median and max
So if you're looking at computing requests per second from an http log file,
you'll want _Peak interval_ to be 1.
Note that _Interval_ must be a multiple of _Peak interval_, and both must be
integers.
### Telegraf config
This tool is intended to be used with the
[`execd` telegraf plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/execd).
```toml
[[inputs.execd]]
command = ["telegraf-tailcount", "-t", "foo=bar", "-i", "10", "-p", "1", "/tmp/log"]
# the values below are the defaults and can be omitted
signal = "none"
restart_delay = "10s"
data_format = "influx"
```
### Metrics
`telegraf-tailcount` outputs the following metrics:
- `sum`: number of lines read during `interval`
- `max`: maximum of lines read during a `peakInterval`
- `min`: minimum of lines read during a `peakInterval`
- `median`: median of lines read during a `peakInterval`
- `mean`: mean of lines read during a `peakInterval`