services/monitoring: Drop unneeded helpers
Attempting to reduce the complexity of the service as a whole.
This commit is contained in:
parent
ef147a0e22
commit
8696e2cbef
1 changed files with 9 additions and 15 deletions
|
@ -4,7 +4,7 @@
|
||||||
outputs,
|
outputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) concatStringsSep mapAttrsToList hasAttrByPath getAttrFromPath filterAttrs singleton optional;
|
inherit (lib) concatStringsSep mapAttrsToList getAttrFromPath filterAttrs singleton optional;
|
||||||
inherit (lib) escapeRegex;
|
inherit (lib) escapeRegex;
|
||||||
inherit (config.networking) fqdn hostName;
|
inherit (config.networking) fqdn hostName;
|
||||||
|
|
||||||
|
@ -52,15 +52,13 @@
|
||||||
# allTargets = filterAttrs (_: c: (isMe c) || !(isDev_ c)) allHosts;
|
# allTargets = filterAttrs (_: c: (isMe c) || !(isDev_ c)) allHosts;
|
||||||
allTargets = allHosts;
|
allTargets = allHosts;
|
||||||
|
|
||||||
# monFqdn = config: "${config.networking.hostName}.${monDomain}";
|
monTarget = service: config: "${config.networking.hostName}.${monDomain}:${toString service.port}";
|
||||||
hasEnabled = servicePath: config: let
|
targetAllHosts = servicePath: let
|
||||||
path = servicePath ++ ["enable"];
|
service = cfg: getAttrFromPath servicePath cfg.config;
|
||||||
in
|
in
|
||||||
(hasAttrByPath path config) && (getAttrFromPath path config);
|
mapAttrsToList
|
||||||
|
(_: c: monTarget (service c) c.config)
|
||||||
monTarget = servicePath: config: let
|
(filterAttrs (_: c: (service c).enable or false) allTargets);
|
||||||
port = toString (getAttrFromPath (servicePath ++ ["port"]) config);
|
|
||||||
in "${config.networking.hostName}.${monDomain}:${port}";
|
|
||||||
|
|
||||||
dropMetrics = extraRegexen: let
|
dropMetrics = extraRegexen: let
|
||||||
dropRegexen = [ "go_" "promhttp_metric_handler_requests_" ] ++ extraRegexen;
|
dropRegexen = [ "go_" "promhttp_metric_handler_requests_" ] ++ extraRegexen;
|
||||||
|
@ -80,10 +78,6 @@
|
||||||
|
|
||||||
prometheusPath = ["services" "prometheus"];
|
prometheusPath = ["services" "prometheus"];
|
||||||
alertmanagerPath = ["services" "prometheus" "alertmanager"];
|
alertmanagerPath = ["services" "prometheus" "alertmanager"];
|
||||||
targetAllHosts = servicePath:
|
|
||||||
mapAttrsToList
|
|
||||||
(_: config: monTarget servicePath config.config)
|
|
||||||
(filterAttrs (_: c: (hasEnabled servicePath c.config)) allTargets);
|
|
||||||
in {
|
in {
|
||||||
/*
|
/*
|
||||||
Steps to edit the monitoring.htpasswd (aka. adding yourself / updating you password):
|
Steps to edit the monitoring.htpasswd (aka. adding yourself / updating you password):
|
||||||
|
@ -160,7 +154,7 @@ in {
|
||||||
|
|
||||||
alertmanagers = [{
|
alertmanagers = [{
|
||||||
static_configs = [{
|
static_configs = [{
|
||||||
targets = [(monTarget alertmanagerPath config)];
|
targets = [(monTarget config.services.prometheus.alertmanager config)];
|
||||||
}];
|
}];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -170,7 +164,7 @@ in {
|
||||||
static_configs = [{
|
static_configs = [{
|
||||||
targets = [
|
targets = [
|
||||||
# Only scraping to own node-exporter
|
# Only scraping to own node-exporter
|
||||||
(monTarget ["services" "prometheus" "exporters" "node"] config)
|
(monTarget config.services.prometheus.exporters.node config)
|
||||||
];
|
];
|
||||||
}];
|
}];
|
||||||
relabel_configs = [relabelInstance];
|
relabel_configs = [relabelInstance];
|
||||||
|
|
Loading…
Reference in a new issue