diff --git a/morph/lib/monitoring.nix b/morph/lib/monitoring.nix index 066f554c7a996ee1efcfdfa695c2e10b66b7ac68..32454abd6853490c15d0ca41f858bb95aac44d58 100644 --- a/morph/lib/monitoring.nix +++ b/morph/lib/monitoring.nix @@ -24,8 +24,9 @@ ../../nixos/modules/monitoring/vpn/server.nix ../../nixos/modules/monitoring/server/grafana.nix ../../nixos/modules/monitoring/server/prometheus.nix + ../../nixos/modules/monitoring/server/loki.nix ../../nixos/modules/monitoring/exporters/node.nix ../../nixos/modules/monitoring/exporters/blackbox.nix - ../../nixos/modules/monitoring/server/loki.nix + ../../nixos/modules/monitoring/exporters/promtail.nix ]; } diff --git a/nixos/modules/monitoring/exporters/promtail.nix b/nixos/modules/monitoring/exporters/promtail.nix new file mode 100644 index 0000000000000000000000000000000000000000..8b5e45aca1a94da6568058fc037e8fb503254e14 --- /dev/null +++ b/nixos/modules/monitoring/exporters/promtail.nix @@ -0,0 +1,34 @@ +# Promtail log forwarder configuration +# +# Scope: Tail logs on the local system and send them to Loki +# +# Description: This is not strictly an "exporter" like the Prometheus +# exporters, but it is very similar in what it is doing - +# preparing local data and sending it off to a TSDB. + +{ + config.services.promtail.enable = true; + config.services.promtail.configuration = { + server = { + http_listen_port = 9080; + grpc_listen_port = 0; + }; + + clients = [{ + url = "http://monitoring:3100/loki/api/v1/push"; + }]; + + scrape_configs = [{ + job_name = "systemd-journal"; + journal = { + labels = { + job = "systemd-journal"; + }; + }; + relabel_configs = [{ + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + }]; + }]; + }; +}