grafana-agent: make bagel.monitoring.grafana-agent.exporters
an attrset
This allows us to use multiple jobs, one for each additional exporter, and set their `job_name` accordingly. `job_name` is exported as `job` label on the resulting metrics. This allows us to quickly get an understanding what metrics of an exporter are actually available by simply filtering all metrics by `{job="$jobname"}`
This commit is contained in:
parent
22f19ee550
commit
1693f644ee
|
@ -13,14 +13,20 @@ in
|
|||
enable = (mkEnableOption "Grafana Agent") // { default = true; };
|
||||
|
||||
exporters = mkOption {
|
||||
description = "List of all exporters to scrape";
|
||||
type = types.listOf (types.submodule {
|
||||
description = ''
|
||||
Set of additional exporters to scrape.
|
||||
|
||||
The attribute name will be used as `job_name`
|
||||
internally, which ends up exported as `job` label
|
||||
on all metrics of that exporter.
|
||||
'';
|
||||
type = types.attrsOf (types.submodule {
|
||||
options.port = mkOption {
|
||||
description = "Exporter port";
|
||||
type = types.int;
|
||||
};
|
||||
});
|
||||
default = [];
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -45,14 +51,12 @@ in
|
|||
configs = [
|
||||
{
|
||||
name = config.networking.hostName;
|
||||
scrape_configs = [
|
||||
{
|
||||
job_name = config.networking.hostName;
|
||||
static_configs = [
|
||||
{ targets = map (e: "localhost:" + (toString e.port)) config.bagel.monitoring.grafana-agent.exporters; }
|
||||
];
|
||||
}
|
||||
];
|
||||
scrape_configs = lib.mapAttrsToList (name: value: {
|
||||
job_name = name;
|
||||
static_configs = [
|
||||
{ targets = "localhost:" + (toString value.port); }
|
||||
];
|
||||
}) config.bagel.monitoring.grafana-agent.exporters;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
|
@ -17,6 +17,6 @@ in
|
|||
listenAddress = "0.0.0.0";
|
||||
};
|
||||
|
||||
bagel.monitoring.grafana-agent.exporters = [ { port = 9102; } ];
|
||||
bagel.monitoring.grafana-agent.exporters.cadvisor.port = 9102;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
bagel.monitoring.grafana-agent.exporters = [
|
||||
{ port = 9103; }
|
||||
];
|
||||
bagel.monitoring.grafana-agent.exporters.nginxlog.port = 9103;
|
||||
};
|
||||
}
|
|
@ -24,8 +24,6 @@ in
|
|||
|
||||
services.postgresql.settings.shared_preload_libraries = "pg_stat_statements";
|
||||
|
||||
bagel.monitoring.grafana-agent.exporters = [
|
||||
{ port = 9104; }
|
||||
];
|
||||
bagel.monitoring.grafana-agent.exporters.postgres.port = 9104;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue