Commit graph

99 commits

Author SHA1 Message Date
Hector
f2cd6ebb7b Merge branch 'refactor-project-makefile' into 'main'
Refactor project makefile

See merge request hectorjsmith/fail2ban-prometheus-exporter!45
2021-10-17 17:39:03 +00:00
Hector
695447a4c2 refactor: update project makefile
Rename steps in the project makefile to follow a more consistent naming
scheme.
Add new gitlab CI step to check for unused dependencies.
2021-10-17 17:39:02 +00:00
Hector
5363cad4ce Merge branch 'update-changelog' into 'main'
Update changelog

See merge request hectorjsmith/fail2ban-prometheus-exporter!44
2021-10-16 21:04:20 +00:00
Hector
1a660ab046 docs: update project changelog 2021-10-16 22:01:09 +01:00
Hector
4c122609b8 Merge branch 'remove-fail2ban-database-based-metrics' into 'main'
Remove fail2ban database based metrics

See merge request hectorjsmith/fail2ban-prometheus-exporter!43
2021-10-15 18:02:26 +00:00
Hector
b268f8654c remove: database-based metrics
Remove all database-based metrics from the metrics endpoint.
Remove all code related to pulling metrics from the fail2ban database.
Remove all configuration variables related to the fail2ban database.
The CLI parameter for the database path was not removed to avoid breaking
compatibility.
Update docker entrypoint to remove references to the fail2ban database.
Remove all references to the old database metrics from the README.
2021-10-15 18:02:26 +00:00
Hector
025347b7ca Merge branch 'add-metrics-on-basic-jail-configuration' into 'main'
Add metrics on basic jail configuration

See merge request hectorjsmith/fail2ban-prometheus-exporter!42
2021-10-14 20:52:25 +00:00
Hector
56730c8774 feat: add new jail config metrics
Add new metrics around basic jail configuration. The new metrics expose the
max retries, ban time, and find time for each jail.
Update project README with the new metrics.
2021-10-14 20:52:25 +00:00
Hector
bb5c15de1b Merge branch 'refactor-metric-collector-file-structure' into 'main'
Refactor metric collector file structure

See merge request hectorjsmith/fail2ban-prometheus-exporter!41
2021-10-13 20:40:10 +00:00
Hector
60e6365e1f refactor: create new collector folder
Create a new `collector` folder to store the code for the different
collectors. Move the existing f2b and textfile collectors to this folder.
Minor refactors to the f2b collector to better match the code style of the
newer textfile collector.
2021-10-13 21:33:49 +01:00
Hector
7cdaf1ebd1 Merge branch 'update-readme-with-missing-version-metric' into 'main'
Update readme with missing version metric

See merge request hectorjsmith/fail2ban-prometheus-exporter!40
2021-10-13 16:35:25 +00:00
Hector
9ccad42342 docs: add details on version metric to readme
Update the README file to include info on the new version metrics.
2021-10-13 17:21:33 +01:00
Hector
3591582b61 Merge branch 'remove-windows-support' into 'main'
Remove windows support

See merge request hectorjsmith/fail2ban-prometheus-exporter!39
2021-10-13 06:57:59 +00:00
Hector
0b6a941b38 remove: windows builds
Update the goreleaser config to remove windows builds. It doesn't make
sense to build binaries for windows because fail2ban does not provide any
binary for windows. If windows support is required, docker can be used.
2021-10-13 07:53:27 +01:00
Hector
d8ce799223 Merge branch 'add-support-for-exposing-metrics-from-text-file' into 'main'
Add support for exposing metrics from text file

See merge request hectorjsmith/fail2ban-prometheus-exporter!38
2021-10-12 20:38:26 +00:00
Hector
5a107cc547 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.
2021-10-12 20:38:26 +00:00
Hector
351d3344f7 Merge branch 'release/0.3.0' into 'main'
Release/0.3.0

See merge request hectorjsmith/fail2ban-prometheus-exporter!37
2021-09-27 19:00:02 +00:00
Hector
1e29f6bfbf docs: update changelog for release 2021-09-27 19:55:58 +01:00
Hector
038aeaaafd Merge branch 'update-changelog' into 'main'
Update changelog

See merge request hectorjsmith/fail2ban-prometheus-exporter!36
2021-09-26 11:39:49 +00:00
Hector
94ee6cac4e docs: update changelog 2021-09-26 12:32:48 +01:00
Hector
51c1157d21 Merge branch 'render-basic-root-html-page-with-link-to-metrics' into 'main'
Render basic root html page with link to metrics

See merge request hectorjsmith/fail2ban-prometheus-exporter!35
2021-09-25 21:23:29 +00:00
Hector
84b9d02068 feat: render basic html page at root url
Add a new request handler for the root URL (`/`) to render a simple HTML
page with a link to the metrics page. This follows the convention of other
metric exporters.
2021-09-25 21:23:28 +00:00
Hector
a1a0aa03a4 Merge branch 'print-ready-message-with-host-and-port-on-startup' into 'main'
Print ready message with host and port on startup

See merge request hectorjsmith/fail2ban-prometheus-exporter!34
2021-09-22 12:34:39 +00:00
Hector
22a165da3e feat: improve startup logging
Update the exporter startup to add more log messages. The server address,
port, and metrics path are now logged on startup.
A "ready" log message is printed when the server is up and running.
2021-09-21 09:34:23 +01:00
Hector
964fbfd0f8 Merge branch 'split-export-functions-into-separate-package' into 'main'
Split export functions into separate package

See merge request hectorjsmith/fail2ban-prometheus-exporter!33
2021-09-14 20:28:15 +00:00
Hector
03f5084020 refactor: move exporter code to new package
Split out all the code to define exporter functions and collect data into
a new package. The new package is responsible for all exporter related
activity. This makes the code easier to read.
Split the code for collecting metrics from the database and from the socket
into different files to make the separation more obvious.
2021-09-13 20:25:54 +01:00
Hector
911736cee4 Merge branch '12-export-metric-with-fail2ban-server-and-exporter-versions' into 'main'
Resolve "Export metric with fail2ban server and exporter versions"

Closes #12

See merge request hectorjsmith/fail2ban-prometheus-exporter!32
2021-09-10 06:13:56 +00:00
Hector
fba9ee2809 feat: export new version metric (#12)
Add a new `f2b_version` metric that includes the version of the fail2ban
server and the exporter.
Add a new socket command to get back the fail2ban server version.
2021-09-10 06:13:56 +00:00
Hector
d9f1ee33c8 Merge branch 'docs/update-changelog-for-release' into 'main'
Docs/update changelog for release

See merge request hectorjsmith/fail2ban-prometheus-exporter!31
2021-08-31 13:07:54 +00:00
Hector
e4aa5edaa0 docs: update changelog for release
Update the CHANGELOG file for the v0.2.0 release.
2021-08-31 13:04:51 +00:00
Hector
e4cf21fdf1 Merge branch 'docs/update-readme' into 'main'
Docs/update readme

See merge request hectorjsmith/fail2ban-prometheus-exporter!30
2021-08-31 12:44:59 +00:00
Hector
062abe561c docs: update project readme file
Re-write the project README file based on the new features available in the
exporter and the new socket-based metric collection.
2021-08-31 12:44:58 +00:00
Hector
920cf08619 Merge branch 'docs/update-changelog' into 'main'
Docs/update changelog

See merge request hectorjsmith/fail2ban-prometheus-exporter!29
2021-08-30 17:15:08 +00:00
Hector
742019a025 docs: update changelog
Update the project changelog.
Refactor the changelog structure to no longer be fully automated. It now
includes some manual tweaks.
Update the Makefile command to generate a new `CHANGELOG_gen.md` file
instead of overwriting the existing Changelog file.
2021-08-30 18:07:20 +01:00
Hector
92fcae5cda Merge branch 'refactor/deprecate-old-db-based-metrics' into 'main'
Refactor/deprecate old db based metrics

See merge request hectorjsmith/fail2ban-prometheus-exporter!28
2021-08-30 16:38:33 +00:00
Hector
5b62670e9d refactor: deprecate database metrics
Update all old database-based metrics to include the `deprecated` text.
Add a warning on startup if connecting to the fail2ban database to state
that this functionality will be removed in a future release.
Rename deprecated methods and variables.
2021-08-30 16:38:33 +00:00
Hector
737a86b6fd Merge branch 'feat/export-metric-with-connection-errors' into 'main'
Feat/export-metric-with-connection-errors

See merge request hectorjsmith/fail2ban-prometheus-exporter!27
2021-08-30 07:19:11 +00:00
Hector
4da46f3c4a feat: export metrics with socket errors
Add new metric to collect the number of errors found when connecting to the
fail2ban server socket. Errors are split into two categories: connection
errors (e.g. socket file not found), and request errors (e.g. invalid
response received from server).
Update the `up` metric to return `0` if the socket connection fails.
Improve error logging.
2021-08-30 07:19:11 +00:00
Hector
828b67cdd9 Merge branch 'fix/recover-from-fail2ban-restarts' into 'main'
Fix/recover from fail2ban restarts

See merge request hectorjsmith/fail2ban-prometheus-exporter!26
2021-08-30 06:39:06 +00:00
Hector
acb40a94bd fix: recover from fail2ban server restarts
Update the code collecting metrics to open a new socket connection each
time metrics are collected. This ensures that a new socket connection is
used each time and avoids errors caused by fail2ban being restarted.
2021-08-30 07:36:15 +01:00
Hector
aef73df3fa Merge branch 'feat/update-docker-container-for-socket-based-metrics' into 'main'
Feat/update docker container for socket based metrics

See merge request hectorjsmith/fail2ban-prometheus-exporter!25
2021-08-29 17:42:47 +00:00
Hector
2ab1f7dc52 feat: support reading fail2ban socket in docker
Update the docker container to support mounting the fail2ban server socket
and pointing the exporter at it. This allows the exporter to interact with
the socket from within the container.
The entire `/var/run` folder is mounted instead of just the socket file to
correctly handle fail2ban restarts (where the file will be deleted).
2021-08-29 18:36:27 +01:00
Hector
82a7bbe1e0 Merge branch 'feat/read-metrics-from-fail2ban-server-socket' into 'main'
Feat/read metrics from fail2ban server socket

See merge request hectorjsmith/fail2ban-prometheus-exporter!22
2021-08-29 16:54:20 +00:00
Hector
1964dde273 feat: export metrics for failed/banned counts
Add new metric to track the total number of jails configured in fail2ban.
Add new metrics for the current and total number of filter failures for
each jail, as well as the current/total number of banned IPs per jail.
The new metrics are collected by sending the `status [jail]` command to the
fail2ban server and parsing the response data.
2021-08-29 16:54:20 +00:00
Hector
617d711ecf Merge branch 'fix/read-socket-response-in-chunks' into 'main'
Fix/read socket response in chunks

See merge request hectorjsmith/fail2ban-prometheus-exporter!24
2021-08-29 15:05:39 +00:00
Hector
e5714b7485 fix: read socket response data in chunks
Read the response data from the socket in chunks to prevent errors when
processing large payloads. The initial implementation solved large payloads
by just defining a very large buffer, but this is not a solution. The new
code reads the socket data in a loop until a terminator is found and
appends all the data into a single byte array.
Reduce the buffer size to `1024` bytes.
2021-08-29 16:02:31 +01:00
Hector
e083b48461 Merge branch 'feat/ping-fail2ban-server-over-socket' into 'main'
Feat/ping fail2ban server over socket

See merge request hectorjsmith/fail2ban-prometheus-exporter!23
2021-08-29 11:50:53 +00:00
Hector
39133d0a76 feat: collect new up metric from fail2ban socket
Add support for connecting the exporter directly to the fail2ban server's
socket to send requests and receive data. The path to the socket file is
optional and specified on startup.
Export a new metric based on the response of the `ping` command sent to the
fail2ban server. The metric is set to 1 if the server responds with `pong`
and 0 in any other case. This metric is only shown if the path to the
socket file was provided on startup.
2021-08-29 11:50:53 +00:00
Hector
9d6b35c59a Merge branch 'fix/update-banned-metric-to-exclude-expired-bans' into 'main'
Fix/update banned metric to exclude expired bans

See merge request hectorjsmith/fail2ban-prometheus-exporter!21
2021-08-27 15:34:21 +00:00
Hector
526b1c7272 fix: update banned metrics to exclude expired bans
Update the database query counting the number of banned IPs to filter out
any bans that have already expired. An expired ban is defined as a ban
where the "time of ban" plus the "duration of ban" is less than the
current time.
This is necessary because bans that have expired are not automatically
removed from the database and will cause metrics to diverge from the counts
reported by `fail2ban-client`.
2021-08-27 16:29:01 +01:00