2024-05-14 22:36:08 +02:00
|
|
|
{ pkgs, config, ... }:
|
2024-05-14 17:06:38 +02:00
|
|
|
{
|
2024-05-14 22:36:08 +02:00
|
|
|
|
|
|
|
networking.firewall.interfaces.wg0.allowedTCPPorts = [ 4317 ];
|
|
|
|
networking.firewall.interfaces.wg0.allowedUDPPorts = [ 4317 ];
|
|
|
|
|
2024-05-14 17:06:38 +02:00
|
|
|
services.opentelemetry-collector = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.unstable.opentelemetry-collector-contrib;
|
|
|
|
settings = {
|
|
|
|
receivers = {
|
2024-05-14 20:02:37 +02:00
|
|
|
|
|
|
|
# receive metrics from other open telemetry collectors
|
|
|
|
otlp.protocols.grpc.endpoint = "0.0.0.0:4317";
|
|
|
|
|
2024-05-14 17:06:38 +02:00
|
|
|
# provide a influxdb sink
|
|
|
|
influxdb = {
|
|
|
|
endpoint = "127.0.0.1:8088";
|
|
|
|
};
|
2024-05-14 20:02:37 +02:00
|
|
|
|
2024-05-14 17:06:38 +02:00
|
|
|
# scrape opentelemetry-colectors metrics
|
|
|
|
prometheus.config.scrape_configs = [
|
|
|
|
{
|
|
|
|
job_name = "netdata";
|
|
|
|
scrape_interval = "10s";
|
|
|
|
metrics_path = "/api/v1/allmetrics";
|
|
|
|
params.format = [ "prometheus" ];
|
2024-05-14 22:36:08 +02:00
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:19999" ];
|
|
|
|
labels = {
|
|
|
|
service = "netdata";
|
|
|
|
server = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}];
|
2024-05-14 17:06:38 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
job_name = "otelcol";
|
|
|
|
scrape_interval = "10s";
|
2024-05-14 22:36:08 +02:00
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:8100" ];
|
|
|
|
labels = {
|
|
|
|
service = "otelcol";
|
|
|
|
server = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}];
|
2024-05-14 17:06:38 +02:00
|
|
|
metric_relabel_configs = [
|
|
|
|
{
|
|
|
|
source_labels = [ "__name__" ];
|
|
|
|
regex = ".*grpc_io.*";
|
|
|
|
action = "drop";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2024-05-14 22:36:08 +02:00
|
|
|
{
|
|
|
|
job_name = "node";
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
|
|
|
|
labels = {
|
2024-05-14 23:02:13 +02:00
|
|
|
# todo : this is not really needed (right?)
|
2024-05-14 22:36:08 +02:00
|
|
|
service = "node-exporter";
|
2024-05-14 23:02:13 +02:00
|
|
|
# todo : use a processor for this
|
2024-05-14 22:36:08 +02:00
|
|
|
server = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# see https://www.home-assistant.io/integrations/prometheus/
|
|
|
|
job_name = "home-assistant";
|
|
|
|
scrape_interval = "60s";
|
|
|
|
metrics_path = "/api/prometheus";
|
|
|
|
bearer_token_file = toString config.sops.secrets.hass_long_term_token.path;
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "localhost:8123" ];
|
|
|
|
labels = {
|
|
|
|
service = "hass";
|
|
|
|
server = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
}
|
2024-05-14 17:06:38 +02:00
|
|
|
];
|
|
|
|
};
|
2024-05-14 20:02:37 +02:00
|
|
|
|
2024-05-14 17:06:38 +02:00
|
|
|
exporters = {
|
|
|
|
# provide prometheus sink under `/metrics` to
|
|
|
|
prometheus = {
|
|
|
|
endpoint = "127.0.0.1:8090";
|
|
|
|
};
|
|
|
|
};
|
2024-05-14 20:02:37 +02:00
|
|
|
|
2024-05-14 17:06:38 +02:00
|
|
|
service = {
|
|
|
|
pipelines.metrics = {
|
2024-05-14 22:36:08 +02:00
|
|
|
#receivers = [ "otlp" "influxdb" "prometheus" ];
|
|
|
|
receivers = [ "otlp" "influxdb" ];
|
2024-05-14 17:06:38 +02:00
|
|
|
exporters = [ "prometheus" ];
|
|
|
|
};
|
|
|
|
# open telemetries own metrics?
|
|
|
|
telemetry.metrics.address = "0.0.0.0:8100";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|