self-hosting/modules/monitoring-exporters.nix

87 lines
2.4 KiB
Nix
Raw Normal View History

2022-09-15 21:42:58 +02:00
{ config, lib, ... }:
2024-12-11 05:02:44 +01:00
let
cfg = config.custom.services.monitoring-exporters;
in
{
2024-03-26 23:37:53 +01:00
options.custom.services.monitoring-exporters = {
enable = lib.mkEnableOption "monitoring-exporters";
2022-09-15 21:42:58 +02:00
};
2024-03-26 23:37:53 +01:00
config = lib.mkIf cfg.enable {
services.prometheus = {
exporters = {
node = {
enable = true;
2024-12-11 05:02:44 +01:00
enabledCollectors = [
"systemd"
"processes"
];
};
dmarc = {
enable = true;
debug = true;
imap = {
host = "mail.banditlair.com";
username = "paultrial@banditlair.com";
passwordFile = "/run/credentials/prometheus-dmarc-exporter.service/password";
};
folders = {
inbox = "dmarc_reports";
done = "Archives.dmarc_report_processed";
error = "Archives.dmarc_report_error";
};
2024-03-26 23:37:53 +01:00
};
2022-09-15 21:42:58 +02:00
};
2024-03-26 23:37:53 +01:00
};
2024-12-11 05:02:44 +01:00
systemd.services.prometheus-dmarc-exporter.serviceConfig.LoadCredential = "password:${config.sops.secrets.dmarcExporterPassword.path}";
2024-03-26 23:37:53 +01:00
services.promtail = {
enable = true;
configuration = {
server = {
http_listen_port = 3101;
grpc_listen_port = 0;
};
2024-12-11 05:02:44 +01:00
clients = [ { url = "http://127.0.0.1:3100/loki/api/v1/push"; } ];
2024-03-26 23:37:53 +01:00
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = "${config.networking.hostName}";
};
2022-09-15 21:42:58 +02:00
};
2024-12-11 05:02:44 +01:00
relabel_configs = [
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}
];
2024-03-26 23:37:53 +01:00
}
(lib.mkIf config.services.nginx.enable {
job_name = "nginx";
2024-12-11 05:02:44 +01:00
static_configs = [
{
targets = [ "localhost" ];
labels = {
job = "nginx";
host = "${config.networking.hostName}";
__path__ = "/var/log/nginx/*.log";
};
}
];
2024-03-26 23:37:53 +01:00
})
];
};
2022-09-15 21:42:58 +02:00
};
2024-03-26 23:37:53 +01:00
systemd.services.promtail.serviceConfig = {
ReadOnlyPaths = lib.mkIf config.services.nginx.enable "/var/log/nginx";
SupplementaryGroups = lib.mkIf config.services.nginx.enable [ "nginx" ];
};
2022-09-15 21:42:58 +02:00
};
}