From 2f89d37b298f19b27066245152d1bfbe241cd711 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 5 Jul 2019 15:20:55 -0700 Subject: [PATCH] monitoring: Switch to Prometheus, add client vs. server --- modules/services/monitoring/client.nix | 31 +++++++++++++ modules/services/monitoring/default.nix | 59 ++----------------------- 2 files changed, 35 insertions(+), 55 deletions(-) create mode 100644 modules/services/monitoring/client.nix diff --git a/modules/services/monitoring/client.nix b/modules/services/monitoring/client.nix new file mode 100644 index 0000000..6f5d8f9 --- /dev/null +++ b/modules/services/monitoring/client.nix @@ -0,0 +1,31 @@ +# Configure monitoring and reporting services. +{ config, lib, pkgs, ...}: + +# Bring in library functions: +with lib; + +let + cfg = config.phoebe.services.monitoring.client; + +in +{ + #### Interface + options.phoebe.services.monitoring.client = { + enable = mkEnableOption "Export Metrics for Prometheus."; + }; + + #### Implementation + config = mkIf cfg.enable { + # Enable systemd accounting: + systemd.enableCgroupAccounting = true; + + # Prometheus node exporter: + services.prometheus.exporters.node = { + enable = true; + enabledCollectors = [ + "systemd" + "logind" + ]; + }; + }; +} diff --git a/modules/services/monitoring/default.nix b/modules/services/monitoring/default.nix index b208d53..707607b 100644 --- a/modules/services/monitoring/default.nix +++ b/modules/services/monitoring/default.nix @@ -1,58 +1,7 @@ -# Configure monitoring and reporting services. -{ config, lib, pkgs, ...}: +{ ... }: -# Bring in library functions: -with lib; - -let - cfg = config.phoebe.services.monitoring; - - alarmNotifyConf = pkgs.writeText "health_alarm_notify.conf" - (optionalString cfg.pushover.enable '' - SEND_PUSHOVER=YES - PUSHOVER_APP_TOKEN="${cfg.pushover.apiKey}" - DEFAULT_RECIPIENT_PUSHOVER="${concatStringsSep "," cfg.pushover.userKeys}" - ''); -in { - #### Interface - options.phoebe.services.monitoring = { - enable = mkEnableOption "Monitoring and Reporting."; - - pushover = { - enable = mkEnableOption "Alerts via Pushover."; - apiKey = mkOption { - type = types.str; - example = "1234567890abcdefghijklmnopqrst"; - description = "Pushover API key for netdata"; - }; - userKeys = mkOption { - type = types.listOf types.str; - example = [ "1234567890abcdefghijklmnopqrst" ]; - description = "List of user keys."; - }; - }; - }; - - #### Implementation - config = mkIf cfg.enable { - # Enable systemd accounting: - systemd.enableCgroupAccounting = true; - - # Use netdata to collect metrics: - services.netdata = { - enable = true; - - config.global = { - "debug log" = "syslog"; - "access log" = "syslog"; - "error log" = "syslog"; - }; - }; - - environment.etc."netdata/health_alarm_notify.conf" = { - source = "${alarmNotifyConf}"; - mode = "0444"; - }; - }; + imports = [ + ./client.nix + ]; }