monitoring: switch to fluent-bit

This commit is contained in:
ibizaman 2026-05-10 17:39:36 +02:00 committed by Pierre Penninckx
parent ec3406039d
commit acee18e7a3
3 changed files with 71 additions and 24 deletions

View file

@ -971,6 +971,9 @@
"blocks-monitoring-error-dashboard": [ "blocks-monitoring-error-dashboard": [
"blocks-monitoring.html#blocks-monitoring-error-dashboard" "blocks-monitoring.html#blocks-monitoring-error-dashboard"
], ],
"blocks-monitoring-impermanence": [
"blocks-monitoring.html#blocks-monitoring-impermanence"
],
"blocks-monitoring-nextcloud-dashboard": [ "blocks-monitoring-nextcloud-dashboard": [
"blocks-monitoring.html#blocks-monitoring-nextcloud-dashboard" "blocks-monitoring.html#blocks-monitoring-nextcloud-dashboard"
], ],
@ -1034,6 +1037,9 @@
"blocks-monitoring-options-shb.monitoring.grafanaPort": [ "blocks-monitoring-options-shb.monitoring.grafanaPort": [
"blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.grafanaPort" "blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.grafanaPort"
], ],
"blocks-monitoring-options-shb.monitoring.impermanence": [
"blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.impermanence"
],
"blocks-monitoring-options-shb.monitoring.ldap": [ "blocks-monitoring-options-shb.monitoring.ldap": [
"blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.ldap" "blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.ldap"
], ],

View file

@ -293,6 +293,16 @@ in
}; };
}; };
}; };
impermanence = lib.mkOption {
description = ''
Paths to save when using impermanence setup.
'';
type = lib.types.attrsOf lib.types.str;
default = {
fluent-bit = "/var/fluent-bit";
};
};
}; };
config = lib.mkMerge [ config = lib.mkMerge [
@ -575,41 +585,62 @@ in
}; };
}; };
services.promtail = { # I decided to switch to fluent-bit because it can be tested locally https://docs.fluentbit.io/manual/local-testing/logging-pipeline
services.fluent-bit = {
enable = true; enable = true;
configuration = { settings = {
server = { service = {
http_listen_port = 9080; flush = 1;
grpc_listen_port = 0; log_level = "info";
http_server = "true";
http_listen = "127.0.0.1";
http_port = 9080;
grace = 30;
}; };
positions.filename = "/tmp/positions.yaml"; pipeline = {
inputs = [
{
name = "systemd";
client.url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}/api/prom/push"; # The asterisk appends the _SYSTEMD_UNIT to the prefix.
tag = "systemd.*";
scrape_configs = [ # Read logs from this systemd journal directory.
{
job_name = "systemd";
journal = {
json = false;
max_age = "12h";
path = "/var/log/journal"; path = "/var/log/journal";
# matches = "_TRANSPORT=kernel";
# Database file to keep track of the journald cursor.
db = "/var/fluent-bit/systemd.db";
# Start reading new entries. Skip entries already stored in journald.
read_from_tail = true;
# Max entries to lookback on start.
max_entries = 10000;
}
];
outputs = [
{
name = "loki";
match = "systemd.*";
host = "localhost";
port = config.services.loki.configuration.server.http_listen_port;
labels = { labels = {
job = "systemd-journal";
domain = cfg.domain; domain = cfg.domain;
hostname = config.networking.hostName; hostname = config.networking.hostName;
job = "systemd-journal";
}; };
};
relabel_configs = [ label_keys = "unit";
{ }
source_labels = [ "__journal__systemd_unit" ]; ];
target_label = "unit"; };
}
];
}
];
}; };
graceLimit = "1m";
}; };
services.nginx = { services.nginx = {

View file

@ -284,6 +284,16 @@ Graphs:
![Late SSL Jobs Alert Firing](./assets/alert_rules_LateSSL_1.png) ![Late SSL Jobs Alert Firing](./assets/alert_rules_LateSSL_1.png)
## Impermanence {#blocks-monitoring-impermanence}
To save the fluent-bit folder in an impermanence setup, add:
```nix
{
shb.zfs.datasets."safe/monitoring-fluent-bit".path = config.shb.jellyfin.impermanence.fluent-bit;
}
```
## Options Reference {#blocks-monitoring-options} ## Options Reference {#blocks-monitoring-options}
```{=include=} options ```{=include=} options