Commit Graph

177 Commits

Author SHA1 Message Date
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
Hector
a5e1ae4495 Merge branch 'feat/db-error-count-metric' into 'main'
Feat/db error count metric

See merge request hectorjsmith/fail2ban-prometheus-exporter!20
2021-04-07 20:50:23 +00:00
Hector
8726afcd6b feat: new metric to track error counts
Add a new metric to count the number of database errors that have been
found since startup. This complements the `up` metric to have better
visibility into occasional database errors.
2021-04-07 21:46:41 +01:00
Hector
a406e019e2 Merge branch 'feat/base-up-metric-on-errors' into 'main'
Feat/base up metric on errors

See merge request hectorjsmith/fail2ban-prometheus-exporter!19
2021-04-07 20:35:39 +00:00
Hector
bd841c3a35 feat: set up metric to 0 if errors found
The `up` metric is now based on whether an error was found while reading
data from the database to build other metrics. Note that there is a chance
the `up` metric will not be correctly set if the last metric to be built
before the `up` metric does not throw an error.
2021-04-07 21:32:49 +01:00
Hector
a9e41188f6 Merge branch '1-export-metrics-on-enabled-disabled-jails' into 'main'
Resolve "Export metrics on enabled/disabled jails"

Closes #1

See merge request hectorjsmith/fail2ban-prometheus-exporter!18
2021-04-07 18:00:26 +00:00
Hector
1282d635eb feat: new metric for enabled jails (#1)
Add a new prometheus metric to track which jails are currently enabled.
Add a new database query to read the jail name and enabled status from the
database.
Add new metric to readme file.
2021-04-07 18:55:34 +01:00
Hector
5f9085aa5a Merge branch 'release/0.1.0' into 'main'
Release/0.1.0

See merge request hectorjsmith/fail2ban-prometheus-exporter!17
2021-03-28 16:26:45 +00:00
Hector
da7943bf90 docs: update changelog for release 2021-03-28 17:14:48 +01:00
Hector
1682dac4af docs: fix branch name in chglog configuration
Fix the main branch name in the template CHANGELOG  file for the git
chglog tool.
2021-03-28 17:09:53 +01:00
Hector
7b1ff91ede Merge branch '9-reduce-docker-image-size' into 'main'
Resolve "Reduce docker image size"

Closes #9

See merge request hectorjsmith/fail2ban-prometheus-exporter!15
2021-03-27 17:34:41 +00:00
Hector
0751f3fca6 Merge branch 'main' into 9-reduce-docker-image-size 2021-03-27 17:31:41 +00:00
Hector
3c4a8f5495 build: split docker build into two images (#9)
Update the docker build file to use two images - one for building, and one
for running/deployment. This helps reduce the size of the final image.
2021-03-27 17:29:28 +00:00
Hector
0493c4dcb1 Merge branch 'ci/remove-dependency-step' into 'main'
Ci/remove dependency step

See merge request hectorjsmith/fail2ban-prometheus-exporter!16
2021-03-27 17:27:47 +00:00
Hector
1ac9f5a551 ci: remove dependency step from ci/cd pipeline
Remove the dependency check step to avoid breaking builds.
2021-03-27 17:19:45 +00:00
Hector
3de54b0b71 Merge branch 'docs/fix-readme-toc' into 'main'
docs: fix item in readme table of contents

See merge request hectorjsmith/fail2ban-prometheus-exporter!14
2021-02-11 09:06:44 +00:00
Hector
2ee63cca7d docs: fix item in readme table of contents 2021-02-11 09:04:38 +00:00
Hector
95f8026f7c Merge branch 'docs/fix-typo-in-readme-docker-compose' into 'main'
docs: fix typo in readme docker-compose

See merge request hectorjsmith/fail2ban-prometheus-exporter!13
2021-02-10 18:58:26 +00:00
Hector
c9ad2e826f docs: fix typo in readme docker-compose 2021-02-10 18:56:25 +00:00
Hector
26da913294 Merge branch 'docs/add-usage-instructions-to-readme-file' into 'main'
Docs/add usage instructions to readme file

See merge request hectorjsmith/fail2ban-prometheus-exporter!12
2021-02-10 13:09:25 +00:00
Hector
d6ad09341b docs: populate readme file with project information
Update the project README file to include information on what the project
does and how to run it.
2021-02-10 11:48:04 +00:00
Hector
51fa607c28 Merge branch '3-publish-docker-image' into 'main'
Resolve "Publish docker image"

Closes #3

See merge request hectorjsmith/fail2ban-prometheus-exporter!11
2021-02-08 20:10:01 +00:00
Hector
ac8ecfb1aa ci: restrict docker build to main branch and tags (#3) 2021-02-08 20:07:56 +00:00