monitoring: Switch to Prometheus, add client vs. server

This commit is contained in:
Peter Jones 2019-07-05 15:20:55 -07:00
parent ea9e99d760
commit 2f89d37b29
No known key found for this signature in database
GPG key ID: 9DAFAA8D01941E49
2 changed files with 35 additions and 55 deletions

View file

@ -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"
];
};
};
}

View file

@ -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
];
}