2024-12-12 14:41:43 +01:00
|
|
|
# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
2024-04-14 01:06:22 +02:00
|
|
|
{
|
|
|
|
config,
|
2024-12-08 22:31:14 +01:00
|
|
|
serverNodes,
|
2024-04-14 01:06:22 +02:00
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-19 17:37:57 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
host = "prometheus.dgnum.eu";
|
|
|
|
port = 9091;
|
2024-04-14 01:06:22 +02:00
|
|
|
|
|
|
|
nodeExporterConfigs = lib.flatten (
|
|
|
|
lib.mapAttrsToList (
|
|
|
|
node:
|
|
|
|
{ config, ... }:
|
|
|
|
lib.optional config.dgn-node-monitoring.enable {
|
2024-12-15 20:46:54 +01:00
|
|
|
targets = map (p: "${node}.dgnum:${builtins.toString p}") (
|
|
|
|
builtins.attrValues config.dgn-node-monitoring.ports
|
|
|
|
);
|
2024-04-14 01:06:22 +02:00
|
|
|
labels = {
|
|
|
|
host = node;
|
|
|
|
};
|
|
|
|
}
|
2024-12-08 22:31:14 +01:00
|
|
|
) serverNodes
|
2024-04-14 01:06:22 +02:00
|
|
|
);
|
2024-02-19 17:37:57 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
services.prometheus = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
inherit port;
|
|
|
|
|
|
|
|
checkConfig = "syntax-only";
|
|
|
|
enableReload = true;
|
|
|
|
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
|
|
|
|
webConfigFile = config.age.secrets."prometheus-web_config_file".path;
|
|
|
|
|
|
|
|
webExternalUrl = "https://${host}";
|
|
|
|
|
2024-04-16 18:57:18 +02:00
|
|
|
retentionTime = "1y";
|
2024-04-14 01:08:49 +02:00
|
|
|
|
|
|
|
extraFlags = [ "--storage.tsdb.retention.size=20GB" ];
|
|
|
|
|
|
|
|
globalConfig = {
|
|
|
|
scrape_interval = "15s"; # if you change this settings, please do it in grafana also
|
|
|
|
};
|
|
|
|
|
2024-02-19 17:37:57 +01:00
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "prometheus";
|
|
|
|
static_configs = [ { targets = [ "localhost:9090" ]; } ];
|
|
|
|
}
|
2024-04-14 01:06:22 +02:00
|
|
|
{
|
|
|
|
job_name = "node_exporter";
|
|
|
|
static_configs = nodeExporterConfigs;
|
|
|
|
}
|
2024-04-14 01:09:28 +02:00
|
|
|
{
|
|
|
|
job_name = "uptime_kuma";
|
|
|
|
scheme = "https";
|
|
|
|
static_configs = [ { targets = [ "status.dgnum.eu" ]; } ];
|
|
|
|
basic_auth = {
|
|
|
|
username = "prometheus";
|
|
|
|
password_file = config.age.secrets."prometheus-uptime-kuma-apikey".path;
|
|
|
|
};
|
|
|
|
}
|
2024-04-19 23:30:26 +02:00
|
|
|
{
|
|
|
|
job_name = "hyp01_ups";
|
2024-04-22 08:28:40 +02:00
|
|
|
metrics_path = "/ups_metrics";
|
2024-04-19 23:30:26 +02:00
|
|
|
static_configs = [ { targets = [ "100.80.255.180:9199" ]; } ];
|
|
|
|
}
|
2024-04-23 23:22:28 +02:00
|
|
|
{
|
|
|
|
job_name = "garage";
|
|
|
|
static_configs = [ { targets = [ "localhost:3903" ]; } ];
|
|
|
|
bearer_token_file = config.age.secrets."prometheus-garage_api".path;
|
|
|
|
}
|
2024-02-19 17:37:57 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-10-12 18:40:03 +02:00
|
|
|
dgn-web.simpleProxies.prometheus = {
|
|
|
|
inherit host port;
|
|
|
|
proxyWebsockets = true;
|
2024-02-19 17:37:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
age-secrets.autoMatch = [ "prometheus" ];
|
|
|
|
}
|