Skip to content

fix/opentelemetry: Fix OpenTelemetry Collector's custom exporters config to expose metrics - #1039

Merged
michaellzc merged 1 commit into
michael/opt-in-labelsfrom
marc/otel-collector-configmap-metrics
Nov 30, 2026
Merged

michaellzc merged 1 commit into
michael/opt-in-labelsfrom
marc/otel-collector-configmap-metrics

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge into #1038 (michael/opt-in-labels), which adds the app: otel-collector label to the collector's Service, which makes the otel-collector "pods available" critical alert fire

The same fix for the collector's default config is in sourcegraph/sourcegraph#20038, which should merge, and the chart's image tags move past it, before #1038 is released

Context

  • charts/sourcegraph/templates/otel-collector/otel-collector.ConfigMap.yaml is the collector's config when openTelemetry.gateway.config.traces.exporters is set

  • Prometheus copies the otel-collector Service's labels to the metrics it scrapes, so with sourcegraph: render opt-in labels on every object, each key once #1038's app label, the "pods available" alert, up{app=~".*otel-collector"}, sees the scrape for the first time

Problem

Collector config Metrics reachable by Prometheus Alert with #1038
Default: the image's logging.yaml no fires
openTelemetry.gateway.config.traces.exporters: the chart's ConfigMap no fires
jaeger.enabled: the image's jaeger.yaml yes quiet

Solution

  • Add the service.telemetry.metrics.readers block the image's jaeger.yaml already has to the chart's ConfigMap, so metrics are served on 0.0.0.0:8888

  • sourcegraph/sourcegraph#20038 adds the same block to the image's default logging.yaml

Testing

#1038's head This branch
Rendered config.yaml no telemetry block adds the readers block, nothing else changes
Spans sent from another pod 3 of 3 accepted 3 of 3 accepted
:8888/metrics from inside the pod metrics returned metrics returned
:8888/metrics from the Prometheus pod nothing returned metrics returned, otelcol_receiver_accepted_spans 3
Collector config #1038's head This branch
openTelemetry.gateway.config.traces.exporters set (debug), behind an openTelemetry.gateway.command shell wrapper target down, connection refused on 8888, alert pending at once, firing after 15 minutes, emailed target up, alert never pending or firing, no email
Default (logging.yaml), with the image from sourcegraph/sourcegraph#20038 target down, alert firing after 15 minutes, emailed, with the previous image target up, alert never pending or firing

Each alert result above was watched for 17 minutes after the collector pod was ready; the rule's for is 15 minutes

Not tested alongside prometheus.existingConfig

Amp threads

Changelog

Fixed the OpenTelemetry Collector's config for openTelemetry.gateway.config.traces.exporters, so Prometheus can scrape its metrics again

…stom exporters

The config the chart renders for openTelemetry.gateway.config.traces.exporters
left the collector's own metrics on 127.0.0.1:8888, so Prometheus could not
scrape them. With the app: otel-collector label on the Service, that failed
scrape fires the otel-collector "pods available" critical alert.

Add the service.telemetry.metrics.readers block the image's jaeger.yaml has.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a21663-f060-7148-8fdc-8eed219fa092
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

@marcleblanc2
marcleblanc2 requested review from michaellzc and removed request for michaellzc November 27, 2026 20:20
@marcleblanc2 marcleblanc2 changed the title fix/otel-collector: Serve the collector's metrics on all interfaces with custom exporters fix/opentelemetry: Fix OpenTelemetry Collector's custom exporters config to expose metrics Nov 27, 2026
@michaellzc
michaellzc merged commit a544717 into michael/opt-in-labels Nov 30, 2026
10 checks passed
@michaellzc
michaellzc deleted the marc/otel-collector-configmap-metrics branch November 30, 2026 20:59
marcleblanc2 added a commit that referenced this pull request Dec 1, 2026
…bel from the node-exporter Service (#1040)

Stacked on #1039, which merges into #1038 (`michael/opt-in-labels`)

## Context

- The old deprecated Kustomize deployment method
(sourcegraph/deploy-sourcegraph) labeled each resource with
`sourcegraph-resource-requires: cluster-admin | no-cluster-admin`

- This chart started as a copy of those manifests

- #7 removed the label from all 69 objects in the Helm chart

- #194 brought one copy back on the `node-exporter` Service

- Nothing in the sourcegraph org selects on it: no selector, script,
code, or docs page

## Problem

- With #1038, `sourcegraph.serviceLabels` and
`nodeExporter.serviceLabels` reach the `node-exporter` Service, and the
hard-coded `sourcegraph-resource-requires` line comes after them, so
setting that key in either value renders it twice

- Helm and kubectl accept it; Kustomize and `kubeconform -strict` reject
the duplicate key

- #1038's changelog says each key renders once

- Customers who have previously deployed on the old Kustomize repo may
be carrying this label forward with them, which would fail deployment
via Kustomize

## Solution

- Remove the hard-coded label from the `node-exporter` Service, the last
object in this chart that set it

- Users who want it set it in `sourcegraph.labels`,
`sourcegraph.serviceLabels`, or `nodeExporter.serviceLabels`, and it
renders once

- `node-exporter` metrics lose the `sourcegraph_resource_requires`
label, which no bundled dashboard or alert queries, so their series are
replaced once on upgrade

## Testing

- Two new tests in `nodeExporter_test.yaml` fail on #1039's head (one
with `mapping key "sourcegraph-resource-requires" already defined`) and
pass here; `helm unittest` (313 tests, 120 snapshots) and `helm lint`
pass

- On EKS with #1038's head, the duplicate rendered as described above:
client-side and server-side apply accepted it, `kubeconform -strict` and
Kustomize did not

## Amp threads

- https://ampcode.com/threads/T-01a21663-f060-7148-8fdc-8eed219fa092

## Changelog

Removed the deprecated `sourcegraph-resource-requires: no-cluster-admin`
label from the `node-exporter` Service; set it in
`sourcegraph.serviceLabels` or `nodeExporter.serviceLabels` if needed to
keep it

Co-authored-by: Amp <amp@ampcode.com>
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.

2 participants