service/prometheus: enable systemd target and make datasource default

This commit is contained in:
Felix Buehler 2023-04-13 23:50:21 +02:00
parent e9852f6c58
commit ba615f1b29

View file

@ -45,6 +45,10 @@ in
port = 9100; port = 9100;
listenAddress = "127.0.0.1"; listenAddress = "127.0.0.1";
}; };
systemd = {
enable = true;
listenAddress = "127.0.0.1";
};
}; };
globalConfig = { globalConfig = {
@ -53,9 +57,30 @@ in
scrapeConfigs = [ scrapeConfigs = [
{ {
job_name = config.networking.hostName; job_name = "prometheus";
static_configs = [{
targets = [ "127.0.0.1:${toString cfg.port}" ];
labels = {
instance = config.networking.hostName;
};
}];
}
{
job_name = "node";
static_configs = [{ static_configs = [{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
labels = {
instance = config.networking.hostName;
};
}];
}
{
job_name = "systemd";
static_configs = [{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ];
labels = {
instance = config.networking.hostName;
};
}]; }];
} }
]; ];
@ -66,8 +91,11 @@ in
{ {
name = "Prometheus"; name = "Prometheus";
type = "prometheus"; type = "prometheus";
isDefault = true;
url = "http://127.0.0.1:${toString config.services.prometheus.port}"; url = "http://127.0.0.1:${toString config.services.prometheus.port}";
jsonData = { jsonData = {
prometheusType = "Prometheus";
prometheusVersion = toString pkgs.prometheus.version;
timeInterval = config.services.prometheus.globalConfig.scrape_interval; timeInterval = config.services.prometheus.globalConfig.scrape_interval;
}; };
} }