From 2f90fe09524736edeb430afb90388fe55bc64dc7 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 21 Jul 2024 19:10:11 +0530 Subject: [PATCH] all: setup promtail --- hosts/layne/services/apps/default.nix | 1 + hosts/rico0/services/apps/default.nix | 1 + hosts/rico1/services/apps/default.nix | 1 + hosts/rico2/services/apps/default.nix | 1 + hosts/shared/promtail.nix | 46 +++++++++++++++++++++++++++ hosts/wynne/services/apps/default.nix | 1 + 6 files changed, 51 insertions(+) create mode 100644 hosts/shared/promtail.nix diff --git a/hosts/layne/services/apps/default.nix b/hosts/layne/services/apps/default.nix index 61f7a58..7e0599e 100644 --- a/hosts/layne/services/apps/default.nix +++ b/hosts/layne/services/apps/default.nix @@ -2,5 +2,6 @@ _: { imports = [ ./transmission.nix ../../../shared/prometheus-exporters.nix + ../../../shared/promtail.nix ]; } diff --git a/hosts/rico0/services/apps/default.nix b/hosts/rico0/services/apps/default.nix index df18b22..e90c990 100644 --- a/hosts/rico0/services/apps/default.nix +++ b/hosts/rico0/services/apps/default.nix @@ -5,5 +5,6 @@ _: { ./loki.nix ./prometheus.nix ../../../shared/prometheus-exporters.nix + ../../../shared/promtail.nix ]; } diff --git a/hosts/rico1/services/apps/default.nix b/hosts/rico1/services/apps/default.nix index b262054..fcab3d5 100644 --- a/hosts/rico1/services/apps/default.nix +++ b/hosts/rico1/services/apps/default.nix @@ -4,5 +4,6 @@ _: { ./proofs.nix ./wiki.nix ../../../shared/prometheus-exporters.nix + ../../../shared/promtail.nix ]; } diff --git a/hosts/rico2/services/apps/default.nix b/hosts/rico2/services/apps/default.nix index cf17cbe..b3afbb0 100644 --- a/hosts/rico2/services/apps/default.nix +++ b/hosts/rico2/services/apps/default.nix @@ -1,5 +1,6 @@ _: { imports = [ ../../../shared/prometheus-exporters.nix + ../../../shared/promtail.nix ]; } diff --git a/hosts/shared/promtail.nix b/hosts/shared/promtail.nix new file mode 100644 index 0000000..d76714e --- /dev/null +++ b/hosts/shared/promtail.nix @@ -0,0 +1,46 @@ +{ config, ... }: { + services = { + caddy = { + virtualHosts."promtail.${config.networking.hostName}.labs.adtya.xyz" = { + extraConfig = '' + reverse_proxy 127.0.0.1:9080 + tls /persist/secrets/caddy/certs/default.crt /persist/secrets/caddy/certs/default.key + ''; + }; + }; + promtail = { + enable = true; + configuration = { + server = { + http_listen_address = "127.0.0.1"; + http_listen_port = 9080; + }; + clients = [ + { + url = "https://loki.labs.adtya.xyz/api/v1/push"; + tenant_id = 1; + } + ]; + positions = { filename = "/tmp/promtail-positions.yaml"; }; + scrape_configs = [ + { + job_name = "journal"; + journal = { + json = false; + max_age = "12h"; + path = "/var/log/journal"; + matches = "_TRANSPORT=kernel"; + labels = { job = "systemd-journal"; host = "${config.networking.hostName}"; }; + }; + relabel_config = [ + { + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + } + ]; + } + ]; + }; + }; + }; +} diff --git a/hosts/wynne/services/apps/default.nix b/hosts/wynne/services/apps/default.nix index aab1813..d0b5a39 100644 --- a/hosts/wynne/services/apps/default.nix +++ b/hosts/wynne/services/apps/default.nix @@ -4,5 +4,6 @@ _: { ./acomputer.lol.nix ./postgresql.nix ../../../shared/prometheus-exporters.nix + ../../../shared/promtail.nix ]; }