From 32425807fcd2b96d4f1fc53cdca93ba90626300e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 1 Dec 2024 03:00:07 +0100 Subject: [PATCH] Add promtail for journal --- system/default.nix | 2 +- system/monitoring/default.nix | 7 ++++ system/monitoring/logs.nix | 37 +++++++++++++++++++ .../metrics.nix} | 0 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 system/monitoring/default.nix create mode 100644 system/monitoring/logs.nix rename system/{monitoring.nix => monitoring/metrics.nix} (100%) diff --git a/system/default.nix b/system/default.nix index 41b5955..353f251 100644 --- a/system/default.nix +++ b/system/default.nix @@ -1,7 +1,7 @@ { ... }: { imports = [ - ./monitoring.nix + ./monitoring ./packages.nix ./root-user.nix ./root-ca.nix diff --git a/system/monitoring/default.nix b/system/monitoring/default.nix new file mode 100644 index 0000000..351331d --- /dev/null +++ b/system/monitoring/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ./metrics.nix + ./logs.nix + ]; +} diff --git a/system/monitoring/logs.nix b/system/monitoring/logs.nix new file mode 100644 index 0000000..a3376c7 --- /dev/null +++ b/system/monitoring/logs.nix @@ -0,0 +1,37 @@ +{ ... }: +{ + services.promtail = { + enable = true; + configuration = { + server = { + http_listen_address = "0.0.0.0"; + http_listen_port = 9099; + }; + + clients = [ + { + url = "http://monitoring01.home.2rjus.net:3100/loki/api/v1/push"; + } + ]; + + scrape_configs = [ + { + job_name = "journal"; + journal = { + json = true; + }; + relabel_configs = [ + { + source_labels = [ "__journal__systemd_unit" ]; + target_label = "systemd_unit"; + } + { + source_labels = [ "__journal__hostname" ]; + target_label = "host"; + } + ]; + } + ]; + }; + }; +} diff --git a/system/monitoring.nix b/system/monitoring/metrics.nix similarity index 100% rename from system/monitoring.nix rename to system/monitoring/metrics.nix