Browse Source

monitoring: Switch to Prometheus, add client vs. server

master
Peter J. Jones 7 months ago
parent
commit
2f89d37b29
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
2 changed files with 35 additions and 55 deletions
  1. 31
    0
      modules/services/monitoring/client.nix
  2. 4
    55
      modules/services/monitoring/default.nix

+ 31
- 0
modules/services/monitoring/client.nix 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"
];
};
};
}

+ 4
- 55
modules/services/monitoring/default.nix 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
];
}

Loading…
Cancel
Save