{ config, pkgs, lib, ... }: let cfg = config.vhack.monitoring.scrutiny; in { options.vhack.monitoring.scrutiny = { enable = lib.mkEnableOption "scrutiny service"; fqdn = lib.mkOption { type = lib.types.nullOr lib.types.str; description = '' If a string, this will be the domain under which the scrutiny web interface will be servced. If null, the web interface will not be served and only the prometheus metrics will be accessible. ''; }; }; config = lib.mkIf cfg.enable { vhack.monitoring = { prometheus.sources = [ { name = "scrutiny"; extra.metrics_path = "/api/metrics"; target = "127.0.0.1:${toString config.services.scrutiny.settings.web.listen.port}"; } ]; grafana.dashboards = [ ../dashboards/Health.json ]; }; services = { scrutiny = { enable = true; openFirewall = false; # This src includes Prometheus metrics exporter. package = pkgs.scrutiny.overrideAttrs { src = pkgs.fetchFromGitHub { owner = "ibizaman"; repo = "scrutiny"; rev = "74faf06f77df83f29e7e1806cd88b2fafc0bbb82"; hash = "sha256-r0AVWL+E046xHxitwMPfRNTOpjuOk+W6tB41YgmLTPg="; }; vendorHash = "sha256-kAlnlWnBMFCdgdak5L5hRquRtyLi5MTmDa/kxwqPs4E="; }; settings = { web = { metrics.enabled = true; # Enables Prometheus exporter listenHost = "127.0.0.1"; }; }; collector = { enable = true; }; }; # nginx.statusPage = lib.mkDefault config.services.nginx.enable; nginx = lib.mkIf (cfg.fqdn != null) { virtualHosts."${cfg.fqdn}" = { locations."/".proxyPass = "http://127.0.0.1:${toString config.services.scrutiny.settings.web.listen.port}"; enableACME = true; forceSSL = true; }; }; netdata = { enable = true; config = { # web.mode = "none"; # web."bind to" = "127.0.0.1:19999"; global = { "debug log" = "syslog"; "access log" = "syslog"; "error log" = "syslog"; }; }; }; }; # nixpkgs.overlays = [ # (final: prev: { # prometheus-systemd-exporter = prev.prometheus-systemd-exporter.overrideAttrs { # src = final.fetchFromGitHub { # owner = "ibizaman"; # repo = prev.prometheus-systemd-exporter.pname; # # rev = "v${prev.prometheus-systemd-exporter.version}"; # rev = "next_timer"; # sha256 = "sha256-jzkh/616tsJbNxFtZ0xbdBQc16TMIYr9QOkPaeQw8xA="; # }; # # vendorHash = "sha256-4hsQ1417jLNOAqGkfCkzrmEtYR4YLLW2j0CiJtPg6GI="; # }; # }) # ]; }; }