From 0d362a17fc70adb6b46254ad3bf6c05678ab391b Mon Sep 17 00:00:00 2001 From: hexchen Date: Thu, 14 Jan 2021 17:37:24 +0000 Subject: [PATCH] hainich/monitoring: init prometheus --- hosts/hainich/configuration.nix | 1 + hosts/hainich/services/monitoring.nix | 42 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 hosts/hainich/services/monitoring.nix diff --git a/hosts/hainich/configuration.nix b/hosts/hainich/configuration.nix index d5145fb..716816d 100644 --- a/hosts/hainich/configuration.nix +++ b/hosts/hainich/configuration.nix @@ -17,6 +17,7 @@ ./services/gitlab-runner.nix ./services/lantifa.nix ./services/syncthing.nix + ./services/monitoring.nix ]; boot.loader.grub.enable = true; boot.loader.grub.version = 2; diff --git a/hosts/hainich/services/monitoring.nix b/hosts/hainich/services/monitoring.nix new file mode 100644 index 0000000..c1c60d6 --- /dev/null +++ b/hosts/hainich/services/monitoring.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +{ + services.prometheus = { + enable = true; + webExternalUrl = "https://stats.hacc.space"; + exporters = { + dovecot = { + enable = true; + scopes = [ "user" "global" ]; + socketPath = "/var/run/dovecot2/old-stats"; + }; + nginx.enable = true; + node.enable = true; + postfix = { + enable = true; + systemd.enable = true; + }; + rspamd.enable = true; + }; + scrapeConfigs = (lib.mapAttrsToList (name: val: + { + job_name = "${name}-${config.networking.hostName}"; + static_configs = [{ + targets = [ "localhost:${toString val.port}" ]; + labels.host = config.networking.hostName; + }]; + } + ) (lib.filterAttrs (_: val: val.enable) config.services.prometheus.exporters)); + }; + + services.dovecot2.extraConfig = '' + mail_plugins = $mail_plugins old_stats + service old-stats { + unix_listener old-stats { + user = dovecot-exporter + group = dovecot-exporter + } + } + ''; + services.nginx.statusPage = true; +}