{ config, lib, this, ... }: with lib; let cfg = config.nixfiles.modules.promtail; in { options.nixfiles.modules.promtail = { enable = mkEnableOption "Promtail"; loki = { url = mkOption { description = "Address of a listening Loki service."; type = with types; str; default = "https://${config.nixfiles.modules.loki.domain}"; }; }; }; config = mkIf cfg.enable { services.promtail = { enable = true; configuration = { server = rec { http_listen_address = this.wireguard.ipv4.address; http_listen_port = 30181; grpc_listen_address = this.wireguard.ipv4.address; grpc_listen_port = http_listen_port + 1; log_level = "warn"; }; clients = [{url = "${cfg.loki.url}/loki/api/v1/push";}]; positions.filename = "/tmp/positions.yaml"; scrape_configs = [ { job_name = "journal"; journal = { max_age = "24h"; labels.job = "systemd-journal"; }; } ]; }; }; }; }