From c6b38fd8f0e5908e5593d33e66cae8980f560c1b Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 21 May 2023 13:46:36 -0400 Subject: move monitoring setup to modules --- modules/nixos/server/services/promtail.nix | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/nixos/server/services/promtail.nix (limited to 'modules/nixos/server/services/promtail.nix') diff --git a/modules/nixos/server/services/promtail.nix b/modules/nixos/server/services/promtail.nix new file mode 100644 index 0000000..73a8de2 --- /dev/null +++ b/modules/nixos/server/services/promtail.nix @@ -0,0 +1,56 @@ +{ + config, + lib, + ... +}: let + cfg = config.getchoo.server.services.promtail; + inherit (lib) mkEnableOption mkIf mkOption types; +in { + options.getchoo.server.services.promtail = { + enable = mkEnableOption "enable promtail"; + + port = mkOption { + type = types.port; + default = 3031; + description = "port for promtail"; + }; + + clients = mkOption { + type = types.listOf types.attrs; + default = [{}]; + description = "clients for promtail"; + }; + }; + + config.services.promtail = mkIf cfg.enable { + enable = true; + configuration = { + server = { + http_listen_port = cfg.port; + grpc_listen_port = 0; + }; + positions = { + filename = "/tmp/positions.yaml"; + }; + inherit (cfg) clients; + scrape_configs = [ + { + job_name = "journal"; + journal = { + max_age = "12h"; + labels = { + job = "systemd-journal"; + host = "${config.networking.hostName}"; + }; + }; + relabel_configs = [ + { + source_labels = ["__journal__systemd_unit"]; + target_label = "unit"; + } + ]; + } + ]; + }; + }; +} -- cgit v1.2.3