mirror of
https://github.com/vale981/phoebe
synced 2025-03-05 09:51:37 -05:00
monitoring: Switch to Prometheus, add client vs. server
This commit is contained in:
parent
ea9e99d760
commit
2f89d37b29
2 changed files with 35 additions and 55 deletions
31
modules/services/monitoring/client.nix
Normal file
31
modules/services/monitoring/client.nix
Normal 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"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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…
Add table
Reference in a new issue