feat: support for textfile metrics (#13)

Add support for collecting arbitrary metrics from a textfile as well as
metrics collected from fail2ban. This allows other data to be exported
along with the fail2ban metrics (e.g. instance metadata).
Update the docker image to allow mounting a folder with a collection of
metric files to be exported. Only files ending in `.prom` with be read.
Update project README with the new functionality.
This commit is contained in:
Hector
2021-10-12 20:38:26 +00:00
parent 351d3344f7
commit 5a107cc547
7 changed files with 180 additions and 6 deletions

View File

@ -52,6 +52,10 @@ $ fail2ban-prometheus-exporter -h
path to the fail2ban server socket
-version
show version info and exit
-collector.textfile
enable the textfile collector
-collector.textfile.directory string
directory to read text files with metrics from
```
**Example**
@ -240,3 +244,24 @@ fail2ban_errors{type="db"} 0
# TYPE fail2ban_up gauge
fail2ban_up 1
```
### 4.3. Textfile Metrics
For more flexibility the exporter also allows exporting metrics collected from a text file.
To enable textfile metrics:
1. Enable the collector with `-collector.textfile=true`
2. Provide the directory to read files from with the `-collector.textfile.directory` flag
Metrics collected from these files will be exposed directly alongside the other metrics without any additional processing.
This means that it is the responsibility of the file creator to ensure the format is correct.
By exporting textfile metrics an extra metric is also exported with an error count for each file:
```
# HELP textfile_error Checks for errors while reading text files
# TYPE textfile_error gauge
textfile_error{path="file.prom"} 0
```
**NOTE:** Any file not ending with `.prom` will be ignored.