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