From 21d405ab09a6f79a0eabab8e62d940e0704a57b6 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 12 May 2023 14:48:50 -0700 Subject: profiles/monitoring: move promtail to a profile --- profiles/monitoring/promtail.nix | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 profiles/monitoring/promtail.nix (limited to 'profiles/monitoring') diff --git a/profiles/monitoring/promtail.nix b/profiles/monitoring/promtail.nix new file mode 100644 index 0000000..23b6669 --- /dev/null +++ b/profiles/monitoring/promtail.nix @@ -0,0 +1,54 @@ +{ config, lib, pkgs, ... }: +{ + services.promtail.enable = true; + services.promtail.configuration = { + clients = [{ url = "https://loki.${config.homelab.domain}:3100/loki/api/v1/push"; }]; + scrape_configs = [ + { + job_name = "journal"; + journal = { + json = true; + path = "/var/log/journal"; + max_age = "12h"; + labels = { + host = config.networking.hostName; + job = "journal"; + "__path__" = "/var/log/journal"; + }; + }; + + relabel_configs = [ + { + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + } + { + source_labels = [ "__journal_priority" ]; + target_label = "priority"; + } + { + source_labels = [ "__journal_syslog_identifier" ]; + target_label = "syslog_id"; + } + ]; + } + + { + job_name = "nginx"; + static_configs = [{ + labels = { + host = config.networking.hostName; + job = "nginx"; + __path__ = "/var/log/nginx/*"; + }; + }]; + } + ]; + + server = { + http_listen_port = 9832; + http_path_prefix = "/promtail"; + grpc_listen_port = 0; + }; + }; +} -- cgit 1.4.1