You've already forked prometheus-fail2ban-exporter
							
							This commit is contained in:
		
							
								
								
									
										68
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,11 +1,7 @@ | ||||
| # prometheus-fail2ban-exporter | ||||
|  | ||||
| [](https://drone.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter) | ||||
|  | ||||
| This is a fork of Hector's fail2ban | ||||
| [exporter](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter). This | ||||
| fork contains some changes to get the application running in a kubernetes | ||||
| cluster. | ||||
| This is a fork of Hector's fail2ban [exporter](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter). This fork | ||||
| contains some changes to get the application running in a kubernetes cluster. | ||||
|  | ||||
| ## Table of Contents | ||||
|  | ||||
| @@ -21,8 +17,8 @@ The exporter can be run as a standalone binary or a docker container. | ||||
|  | ||||
| ### 1.1. Standalone | ||||
|  | ||||
| The following command will start collecting metrics from the | ||||
| `/var/run/fail2ban/fail2ban.sock` file and expose them on port `9191`. | ||||
| 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" | ||||
| @@ -35,12 +31,10 @@ $ fail2ban_exporter --collector.f2b.socket=/var/run/fail2ban/fail2ban.sock --web | ||||
| ``` | ||||
|  | ||||
| Binary files for each release can be found on the | ||||
| [releases](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/releases) | ||||
| page. | ||||
| [releases](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/releases) page. | ||||
|  | ||||
| There is also an [example systemd service | ||||
| file](/_examples/systemd/fail2ban_exporter.service) included in the repository. | ||||
| This is a starting point to run the exporter as a service. | ||||
| There is also an [example systemd service file](/_examples/systemd/fail2ban_exporter.service) included in the | ||||
| repository. This is a starting point to run the exporter as a service. | ||||
|  | ||||
| ### 1.2. Docker | ||||
|  | ||||
| @@ -68,14 +62,11 @@ services: | ||||
| ``` | ||||
|  | ||||
| Use the `:latest` tag to get the latest stable release. See the [registry | ||||
| page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/container_registry) | ||||
| for all available tags. | ||||
| page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/container_registry) for all available tags. | ||||
|  | ||||
| **NOTE:** While it is possible to mount the `fail2ban.sock` file directly, it is | ||||
| recommended to mount the parent folder instead. The `.sock` file is deleted by | ||||
| fail2ban on shutdown and re-created on startup and this causes problems for the | ||||
| docker mount. See [this | ||||
| reply](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/issues/11#note_665003499) | ||||
| **NOTE:** While it is possible to mount the `fail2ban.sock` file directly, it is recommended to mount the parent folder | ||||
| instead. The `.sock` file is deleted by fail2ban on shutdown and re-created on startup and this causes problems for the | ||||
| docker mount. See [this reply](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/issues/11#note_665003499) | ||||
| for more details. | ||||
|  | ||||
| ## 2. Metrics | ||||
| @@ -117,20 +108,18 @@ Status for the jail: sshd | ||||
|  | ||||
| ### 2.1. Grafana | ||||
|  | ||||
| The metrics exported by this tool are compatible with Prometheus and Grafana. A | ||||
| sample grafana dashboard can be found in the | ||||
| [grafana.json](/_examples/grafana/dashboard.json) file. Just import the contents | ||||
| of this file into a new Grafana dashboard to get started. | ||||
| The metrics exported by this tool are compatible with Prometheus and Grafana. A sample grafana dashboard can be found in | ||||
| the [grafana.json](/_examples/grafana/dashboard.json) file. Just import the contents of this file into a new Grafana | ||||
| dashboard to get started. | ||||
|  | ||||
| The dashboard supports displaying data from multiple exporters. Use the | ||||
| `instance` dashboard variable to select which ones to display. | ||||
| The dashboard supports displaying data from multiple exporters. Use the `instance` dashboard variable to select which | ||||
| ones to display. | ||||
|  | ||||
| *(Sample dashboard is compatible with Grafana `9.1.8` and above)* | ||||
|  | ||||
| ## 3. Configuration | ||||
|  | ||||
| The exporter is configured with CLI flags and environment variables. | ||||
| There are no configuration files. | ||||
| The exporter is configured with CLI flags and environment variables. There are no configuration files. | ||||
|  | ||||
| ### CLI flags | ||||
|  | ||||
| @@ -164,8 +153,7 @@ Flags: | ||||
|  | ||||
| ### Environment variables | ||||
|  | ||||
| Each environment variable corresponds to a CLI flag. | ||||
| If both are specified, the CLI flag takes precedence. | ||||
| Each environment variable corresponds to a CLI flag. If both are specified, the CLI flag takes precedence. | ||||
|  | ||||
| | Environment variable            | Corresponding CLI flag                            | | ||||
| |---------------------------------|---------------------------------------------------| | ||||
| @@ -185,23 +173,18 @@ Building from source has the following dependencies: | ||||
|  | ||||
| From there, simply run `make build` | ||||
|  | ||||
| This will download the necessary dependencies and build a `fail2ban_exporter` | ||||
| binary in the root of the project. | ||||
| This will download the necessary dependencies and build a `fail2ban_exporter` binary in the root of the project. | ||||
|  | ||||
| ## 5. Textfile metrics | ||||
|  | ||||
| For more flexibility the exporter also allows exporting metrics collected from a | ||||
| text file. | ||||
| For more flexibility the exporter also allows exporting metrics collected from a text file. | ||||
|  | ||||
| To enable textfile metrics provide the directory to read files from with the | ||||
| `--collector.textfile.directory` flag. | ||||
| To enable textfile metrics 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. | ||||
| 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: | ||||
| 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 | ||||
| @@ -213,8 +196,7 @@ textfile_error{path="file.prom"} 0 | ||||
|  | ||||
| ### Running in Docker | ||||
|  | ||||
| To collect textfile metrics inside a docker container, a couple of things need | ||||
| to be done: | ||||
| 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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user