diff --git a/README.md b/README.md index c70b4b1..fe4c7bc 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Collect metrics from a running fail2ban instance. ## Table of Contents + 1. Quick Start 2. Metrics 3. Configuration @@ -20,7 +21,7 @@ The exporter can be run as a standalone binary or a docker container. The following command will start collecting metrics from the `/var/run/fail2ban/fail2ban.sock` file and expose them on port `9191`. -``` +```bash $ fail2ban_exporter --collector.f2b.socket=/var/run/fail2ban/fail2ban.sock --web.listen-address=":9191" 2022/02/20 09:54:06 fail2ban exporter version 0.8.1 @@ -37,18 +38,19 @@ This is a starting point to run the exporter as a service. ### 1.2. Docker -**Docker run** -``` -docker run -d \ +#### Docker run + +```bash +$ docker run -d \ --name "fail2ban-exporter" \ -v /var/run/fail2ban:/var/run/fail2ban:ro \ -p "9191:9191" \ registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest ``` -**Docker compose** +#### Docker compose -``` +```yaml version: "2" services: exporter: @@ -89,7 +91,8 @@ The exporter exposes the following metrics: | `version` | Version string of the exporter and fail2ban | `f2b_version{exporter="0.5.0",fail2ban="0.11.1"} 1` | The metrics above correspond to the matching fields in the `fail2ban-client status ` command: -``` + +```text Status for the jail: sshd |- Filter | |- Currently failed: 6 @@ -116,8 +119,9 @@ The dashboard supports displaying data from multiple exporters. Use the `instanc The exporter is configured with CLI flags and environment variables. There are no configuration files. -**CLI flags** -``` +### CLI flags + +```text 🚀 Collect prometheus metrics from a running Fail2Ban instance Flags: @@ -145,7 +149,7 @@ Flags: ($F2B_WEB_BASICAUTH_PASS) ``` -**Environment variables** +### Environment variables Each environment variable corresponds to a CLI flag. If both are specified, the CLI flag takes precedence. @@ -162,6 +166,7 @@ If both are specified, the CLI flag takes precedence. ## 4. Building from source Building from source has the following dependencies: + - Go v1.20 - Make @@ -180,7 +185,7 @@ This means that it is the responsibility of the file creator to ensure the forma By exporting textfile metrics an extra metric is also exported with an error count for each file: -``` +```text # HELP textfile_error Checks for errors while reading text files # TYPE textfile_error gauge textfile_error{path="file.prom"} 0 @@ -188,15 +193,17 @@ textfile_error{path="file.prom"} 0 **NOTE:** Any file not ending with `.prom` will be ignored. -**Running in Docker** +### Running in Docker To collect textfile metrics inside a docker container, a couple of things need to be done: + 1. Mount the folder with the metrics files 2. Set the `F2B_COLLECTOR_TEXT_PATH` environment variable *For example:* -``` -docker run -d \ + +```bash +$ docker run -d \ --name "fail2ban-exporter" \ -v /var/run/fail2ban:/var/run/fail2ban:ro \ -v /path/to/metrics:/app/metrics/:ro \