Skip to content
Snippets Groups Projects
promtail.nix 1.07 KiB
Newer Older
# 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.networking.firewall.interfaces.monitoringvpn.allowedTCPPorts = [ 9080 ];
  config.services.promtail.configuration = {
    server = {
      http_listen_port = 9080; # Using /metrics for health check
      grpc_listen_address = "127.0.0.1"; # unused, but no option to turn it off.
      grpc_listen_port = 9094; # unused, but no option to turn it off.
    };

    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";
      }];
    }];
  };
}