container collectors scrape their own telemetry and push it up their hop
This commit is contained in:
parent
2095bb2d0f
commit
73c966a7eb
1 changed files with 163 additions and 49 deletions
52
nix/collector-self-scrape.nix
Normal file
52
nix/collector-self-scrape.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# Collector settings that make a container's OpenTelemetry collector report its
|
||||
# own health (refused and failed records, exporter queue, memory), imported by
|
||||
# every container collector: the agent forwarder, the service journal
|
||||
# forwarder and the secret store's collector. The two host-side tiers scrape
|
||||
# themselves through their `scrapeTargets` instead.
|
||||
#
|
||||
# One function renders both halves, so the endpoint and the job that reads it
|
||||
# cannot name different ports. The endpoint binds loopback: the collector
|
||||
# scrapes itself, and nothing outside the container has a reason to.
|
||||
#
|
||||
# The job runs in its own pipeline. A container's other metrics pipeline may
|
||||
# carry a `resource` processor that upserts `service.name`, which would
|
||||
# relabel these series away from the `otelcol-contrib` the collector dashboard
|
||||
# selects on. The attributes stamped here tell the container's collectors
|
||||
# apart.
|
||||
#
|
||||
# `readers`, not `metrics.address`: this collector version rejects `address`
|
||||
# at startup.
|
||||
{
|
||||
lib,
|
||||
port,
|
||||
exporter,
|
||||
attributes,
|
||||
}:
|
||||
{
|
||||
service.telemetry.metrics.readers = [
|
||||
{
|
||||
pull.exporter.prometheus = {
|
||||
host = "127.0.0.1";
|
||||
inherit port;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
receivers."prometheus/self".config.scrape_configs = [
|
||||
{
|
||||
job_name = "collector";
|
||||
static_configs = [ { targets = [ "127.0.0.1:${toString port}" ]; } ];
|
||||
}
|
||||
];
|
||||
|
||||
processors."resource/self".attributes = lib.mapAttrsToList (key: value: {
|
||||
inherit key value;
|
||||
action = "upsert";
|
||||
}) attributes;
|
||||
|
||||
service.pipelines."metrics/self" = {
|
||||
receivers = [ "prometheus/self" ];
|
||||
processors = [ "resource/self" ];
|
||||
exporters = [ exporter ];
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue