Skip to content

fix/otel-collector: Scrape the collector's own metrics, and restart it on config changes - #1030

Open
marcleblanc2 wants to merge 6 commits into
marc/executor-k8s-remove-debug-portfrom
marc/otel-collector-metrics
Open

marcleblanc2 wants to merge 6 commits into
marc/executor-k8s-remove-debug-portfrom
marc/otel-collector-metrics

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • The OpenTelemetry Collector dashboard's "pods available" panel has no data, so the alerts can't fire

    • The otel-collector Service has no app label, unlike every other scraped Service, so its metrics have no app or job label

    • With that label added, the target is down and the alert fires: the collector serves its own metrics on 127.0.0.1 only, unless jaeger.enabled is set, so Prometheus can't scrape them

  • The collector doesn't restart when openTelemetry.gateway.config.traces changes, so a new exporter takes effect only at the next pod restart

Solution

  • The otel-collector Service gets app: otel-collector

  • The chart always passes the collector one last argument, after openTelemetry.gateway.args, that serves its metrics on all interfaces, port 8888. It's an argument, not part of the default command, so a custom openTelemetry.gateway.command gets it too

  • The chart-rendered collector ConfigMap, used with openTelemetry.gateway.config.traces.exporters, gets the same setting

  • New checksum/otel-collector-config pod annotation restarts the collector when its ConfigMap changes. It's set only when the chart renders that ConfigMap, so the default install doesn't change

Tested

  • Deployed on my test instance:

    • The otel-collector Service gained app: otel-collector, and the Deployment gained the --config argument

    • Prometheus scrapes otel-collector with health up, through a custom openTelemetry.gateway.command, which passes "$@"

    • The otel-collector targets went from down to up, and the "pods available" alert from firing to inactive

  • New and updated tests in otelCollectorJaeger_test.yaml, command_test.yaml, and allObjectLabels_test.yaml

  • helm unittest, helm lint, and helm-docs pass

Amp threads

Changelog

  • Fixed the OpenTelemetry Collector "pods available" panel and alert having no data

  • otel-collector restarts when openTelemetry.gateway.config.traces changes

  • A custom openTelemetry.gateway.command must pass the chart's last argument on to the collector

@marcleblanc2
marcleblanc2 requested a review from a team November 24, 2026 22:52
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

@marcleblanc2
marcleblanc2 force-pushed the marc/otel-collector-metrics branch from 49f22a6 to f82f082 Compare November 24, 2026 22:58
@marcleblanc2
marcleblanc2 changed the base branch from marc/labels-every-object to marc/executor-k8s-remove-debug-port November 24, 2026 22:58
@marcleblanc2
marcleblanc2 added this pull request to stack #1009 November 24, 2026 22:58
marcleblanc2 and others added 6 commits November 24, 2026 22:12
The otel-collector Service had no app label, unlike every other scraped
Service, so its metrics had no app and job labels and the dashboard's
up{app=~".*otel-collector"} panel and alert had no data.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1effc-8aa2-756b-b724-e1218ffff085
The image's logging.yaml, and the ConfigMap the chart renders for custom
exporters, left the collector's metrics on 127.0.0.1:8888, where Prometheus
cannot scrape them. With the app label the Service gained, up was 0 and the
pods available alert fired instead of showing no data.

Pass the telemetry readers setting as a second --config to the default
command, and add it to the rendered ConfigMap. jaeger.yaml already has it.

Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050
Co-authored-by: Amp <amp@ampcode.com>
…rics to be scraped

openTelemetry.gateway.command replaces the default command, so it does not get
the argument that serves the collector's metrics on all interfaces.

Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050
Co-authored-by: Amp <amp@ampcode.com>
The setting that serves the collector's own metrics on all interfaces was
part of the default command, so a command set in
`openTelemetry.gateway.command` did not get it, and Prometheus could not
scrape the collector. It is now always the last container argument, after
`openTelemetry.gateway.args`, so a replacement command gets it too. Last,
so that it is `$0` of a `sh -c` command whose script is the first argument.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf
Co-authored-by: Amp <amp@ampcode.com>
The collector does not reload a changed ConfigMap by itself, so a change to openTelemetry.gateway.config.traces took effect only at the pod's next restart. The pod template now has a checksum/otel-collector-config annotation over those values, which are all the ConfigMap's data is rendered from. It is set only when the chart renders the ConfigMap, so the default install does not change.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf
Co-authored-by: Amp <amp@ampcode.com>
…gument on

With the script as the first of openTelemetry.gateway.args after
command: ["/bin/sh", "-c"], the chart's argument is $0 and "$@" is empty,
so a wrapper that passes only "$@" drops it and the collector keeps serving
its metrics on 127.0.0.1. Document "$0" "$@" for that form and "$@" for a
script in command followed by a placeholder, and use the first in the test.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
@marcleblanc2
marcleblanc2 force-pushed the marc/otel-collector-metrics branch from f82f082 to ae63325 Compare November 25, 2026 03:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant