style(REAMDE): break lines at 80chars
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e6abacc330
commit
535cbe329d
143
.markdownlint.yaml
Normal file
143
.markdownlint.yaml
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
# markdownlint YAML configuration
|
||||||
|
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
|
||||||
|
|
||||||
|
# Default state for all rules
|
||||||
|
default: true
|
||||||
|
|
||||||
|
# Path to configuration file to extend
|
||||||
|
extends: null
|
||||||
|
|
||||||
|
# MD003/heading-style/header-style - Heading style
|
||||||
|
MD003:
|
||||||
|
# Heading style
|
||||||
|
style: "atx"
|
||||||
|
|
||||||
|
# MD004/ul-style - Unordered list style
|
||||||
|
MD004:
|
||||||
|
style: "dash"
|
||||||
|
|
||||||
|
# MD007/ul-indent - Unordered list indentation
|
||||||
|
MD007:
|
||||||
|
# Spaces for indent
|
||||||
|
indent: 2
|
||||||
|
# Whether to indent the first level of the list
|
||||||
|
start_indented: false
|
||||||
|
|
||||||
|
# MD009/no-trailing-spaces - Trailing spaces
|
||||||
|
MD009:
|
||||||
|
# Spaces for line break
|
||||||
|
br_spaces: 2
|
||||||
|
# Allow spaces for empty lines in list items
|
||||||
|
list_item_empty_lines: false
|
||||||
|
# Include unnecessary breaks
|
||||||
|
strict: false
|
||||||
|
|
||||||
|
# MD010/no-hard-tabs - Hard tabs
|
||||||
|
MD010:
|
||||||
|
# Include code blocks
|
||||||
|
code_blocks: true
|
||||||
|
|
||||||
|
# MD012/no-multiple-blanks - Multiple consecutive blank lines
|
||||||
|
MD012:
|
||||||
|
# Consecutive blank lines
|
||||||
|
maximum: 1
|
||||||
|
|
||||||
|
# MD013/line-length - Line length
|
||||||
|
MD013:
|
||||||
|
# Number of characters
|
||||||
|
line_length: 80
|
||||||
|
# Number of characters for headings
|
||||||
|
heading_line_length: 80
|
||||||
|
# Number of characters for code blocks
|
||||||
|
code_block_line_length: 80
|
||||||
|
# Include code blocks
|
||||||
|
code_blocks: false
|
||||||
|
# Include tables
|
||||||
|
tables: false
|
||||||
|
# Include headings
|
||||||
|
headings: true
|
||||||
|
# Include headings
|
||||||
|
headers: true
|
||||||
|
# Strict length checking
|
||||||
|
strict: false
|
||||||
|
# Stern length checking
|
||||||
|
stern: false
|
||||||
|
|
||||||
|
# MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
|
||||||
|
MD022:
|
||||||
|
# Blank lines above heading
|
||||||
|
lines_above: 1
|
||||||
|
# Blank lines below heading
|
||||||
|
lines_below: 1
|
||||||
|
|
||||||
|
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
|
||||||
|
MD024:
|
||||||
|
# Only check sibling headings
|
||||||
|
allow_different_nesting: true
|
||||||
|
|
||||||
|
# MD025/single-title/single-h1 - Multiple top-level headings in the same document
|
||||||
|
MD025:
|
||||||
|
# Heading level
|
||||||
|
level: 1
|
||||||
|
# RegExp for matching title in front matter
|
||||||
|
front_matter_title: "^\\s*title\\s*[:=]"
|
||||||
|
|
||||||
|
# MD026/no-trailing-punctuation - Trailing punctuation in heading
|
||||||
|
MD026:
|
||||||
|
# Punctuation characters
|
||||||
|
punctuation: ".,;:!。,;:!"
|
||||||
|
|
||||||
|
# MD029/ol-prefix - Ordered list item prefix
|
||||||
|
MD029:
|
||||||
|
# List style
|
||||||
|
style: "one_or_ordered"
|
||||||
|
|
||||||
|
# MD030/list-marker-space - Spaces after list markers
|
||||||
|
MD030:
|
||||||
|
# Spaces for single-line unordered list items
|
||||||
|
ul_single: 1
|
||||||
|
# Spaces for single-line ordered list items
|
||||||
|
ol_single: 1
|
||||||
|
# Spaces for multi-line unordered list items
|
||||||
|
ul_multi: 1
|
||||||
|
# Spaces for multi-line ordered list items
|
||||||
|
ol_multi: 1
|
||||||
|
|
||||||
|
# MD033/no-inline-html - Inline HTML
|
||||||
|
MD033:
|
||||||
|
# Allowed elements
|
||||||
|
allowed_elements: []
|
||||||
|
|
||||||
|
# MD035/hr-style - Horizontal rule style
|
||||||
|
MD035:
|
||||||
|
# Horizontal rule style
|
||||||
|
style: "---"
|
||||||
|
|
||||||
|
# MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
|
||||||
|
MD036:
|
||||||
|
# Punctuation characters
|
||||||
|
punctuation: ".,;:!?。,;:!?"
|
||||||
|
|
||||||
|
# MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
|
||||||
|
MD041:
|
||||||
|
# Heading level
|
||||||
|
level: 1
|
||||||
|
# RegExp for matching title in front matter
|
||||||
|
front_matter_title: "^\\s*title\\s*[:=]"
|
||||||
|
|
||||||
|
# MD044/proper-names - Proper names should have the correct capitalization
|
||||||
|
MD044:
|
||||||
|
# List of proper names
|
||||||
|
names: []
|
||||||
|
# Include code blocks
|
||||||
|
code_blocks: false
|
||||||
|
|
||||||
|
# MD046/code-block-style - Code block style
|
||||||
|
MD046:
|
||||||
|
# Block style
|
||||||
|
style: "fenced"
|
||||||
|
|
||||||
|
# MD048/code-fence-style - Code fence style
|
||||||
|
MD048:
|
||||||
|
# Code fence syle
|
||||||
|
style: "backtick"
|
57
README.md
57
README.md
@ -19,7 +19,8 @@ The exporter can be run as a standalone binary or a docker container.
|
|||||||
|
|
||||||
### 1.1. Standalone
|
### 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
|
```bash
|
||||||
$ fail2ban_exporter --collector.f2b.socket=/var/run/fail2ban/fail2ban.sock --web.listen-address=":9191"
|
$ fail2ban_exporter --collector.f2b.socket=/var/run/fail2ban/fail2ban.sock --web.listen-address=":9191"
|
||||||
@ -31,9 +32,12 @@ $ fail2ban_exporter --collector.f2b.socket=/var/run/fail2ban/fail2ban.sock --web
|
|||||||
2022/02/20 09:54:06 ready
|
2022/02/20 09:54:06 ready
|
||||||
```
|
```
|
||||||
|
|
||||||
Binary files for each release can be found on the [releases](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/releases) page.
|
Binary files for each release can be found on the
|
||||||
|
[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.
|
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.
|
This is a starting point to run the exporter as a service.
|
||||||
|
|
||||||
### 1.2. Docker
|
### 1.2. Docker
|
||||||
@ -61,12 +65,16 @@ services:
|
|||||||
- "9191:9191"
|
- "9191:9191"
|
||||||
```
|
```
|
||||||
|
|
||||||
Use the `:latest` tag to get the latest stable release.
|
Use the `:latest` tag to get the latest stable release. See the [registry
|
||||||
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.
|
**NOTE:** While it is possible to mount the `fail2ban.sock` file directly, it is
|
||||||
The `.sock` file is deleted by fail2ban on shutdown and re-created on startup and this causes problems for the docker mount.
|
recommended to mount the parent folder instead. The `.sock` file is deleted by
|
||||||
See [this reply](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/issues/11#note_665003499) for more details.
|
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
|
## 2. Metrics
|
||||||
|
|
||||||
@ -90,7 +98,8 @@ The exporter exposes the following metrics:
|
|||||||
| `jail_config_max_retry` | The max number of failures allowed before banning an IP in this jail | `f2b_config_jail_max_retries{jail="sshd"} 5` |
|
| `jail_config_max_retry` | The max number of failures allowed before banning an IP in this jail | `f2b_config_jail_max_retries{jail="sshd"} 5` |
|
||||||
| `version` | Version string of the exporter and fail2ban | `f2b_version{exporter="0.5.0",fail2ban="0.11.1"} 1` |
|
| `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 <jail>` command:
|
The metrics above correspond to the matching fields in the `fail2ban-client
|
||||||
|
status <jail>` command:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Status for the jail: sshd
|
Status for the jail: sshd
|
||||||
@ -106,11 +115,13 @@ Status for the jail: sshd
|
|||||||
|
|
||||||
### 2.1. Grafana
|
### 2.1. Grafana
|
||||||
|
|
||||||
The metrics exported by this tool are compatible with Prometheus and Grafana.
|
The metrics exported by this tool are compatible with Prometheus and Grafana. A
|
||||||
A sample grafana dashboard can be found in the [grafana.json](/_examples/grafana/dashboard.json) file.
|
sample grafana dashboard can be found in the
|
||||||
Just import the contents of this file into a new Grafana dashboard to get started.
|
[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)*
|
*(Sample dashboard is compatible with Grafana `9.1.8` and above)*
|
||||||
|
|
||||||
@ -172,18 +183,23 @@ Building from source has the following dependencies:
|
|||||||
|
|
||||||
From there, simply run `make build`
|
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
|
## 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.
|
Metrics collected from these files will be exposed directly alongside the other
|
||||||
This means that it is the responsibility of the file creator to ensure the format is correct.
|
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
|
```text
|
||||||
# HELP textfile_error Checks for errors while reading text files
|
# HELP textfile_error Checks for errors while reading text files
|
||||||
@ -195,7 +211,8 @@ textfile_error{path="file.prom"} 0
|
|||||||
|
|
||||||
### Running in Docker
|
### 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
|
1. Mount the folder with the metrics files
|
||||||
2. Set the `F2B_COLLECTOR_TEXT_PATH` environment variable
|
2. Set the `F2B_COLLECTOR_TEXT_PATH` environment variable
|
||||||
|
Loading…
Reference in New Issue
Block a user