traefik_otel: aggregate counter metrics with the ES|QL TS command and scope cumulativetodelta to histograms - #21044
Draft
giorgi-imerlishvili-elastic wants to merge 3 commits into
Conversation
Prometheus counters scraped by the OTel collector (traefik_*_total, process_cpu_seconds_total) are mapped as counter_double/counter_long by the OTel-native metrics mapping. ES|QL rejects regular aggregate functions on the counter field family, so every panel and rule that ran SUM()/MAX() on one of these fields via a plain FROM source command failed with verification_exception as soon as it loaded, leaving most of the Overview, Services, TLS & Config and Process dashboards blank. Move those queries to the TS source command with counter-aware functions: RATE() where the panel reported a per-second rate (it previously divided a SUM by a DATE_DIFF window), INCREASE() where the panel reported a total count over the selected range, and MAX(LAST_OVER_TIME()) for the cumulative "Total Reloads" metric. Output column names, bucketing and result shapes are unchanged so the Lens configurations keep working. This also fixes the three 5xx-rate alerting rule templates, which already carried a comment saying counters require TS + INCREASE but still used FROM + SUM. Gauge-backed panels and rules are untouched, and the SLO templates aggregate through the DSL rather than ES|QL, so they were never affected.
The documented collector config applied cumulativetodelta to traefik_.*, go_.* and process_.*, which is wide enough to catch every Prometheus counter. Converting a monotonic sum to delta temporality makes the Elasticsearch exporter map it as a gauge rather than a counter, so the counter-aware RATE() and INCREASE() functions the dashboards and alerting rules now use are rejected on those fields. The processor is only actually required for the request-duration histograms, which the Prometheus receiver emits as cumulative and the exporter drops in otel mapping mode. Narrow the include filter to those metrics so counters arrive cumulative and are mapped as counters, and say why widening it breaks the panels. Verified with opentelemetry-collector-contrib 0.160.0 against Elasticsearch 9.5.0: with the broad filter node_cpu_seconds_total is mapped time_series_metric=gauge, with the narrowed filter it is mapped time_series_metric=counter. Also add a troubleshooting section, since a field's time-series type is fixed when the backing index is created. Recovering needs a rollover, and because documents are routed by @timestamp the previous backing index keeps accepting writes until its index.time_series.end_time has passed.
The 0.3.2 entries were staged with a placeholder PR number before the pull request existed.
Contributor
Elastic Docs Style Checker (Vale)Summary: 1 warning, 1 suggestion found
|
| File | Line | Rule | Message |
|---|---|---|---|
| packages/traefik_otel/docs/README.md | 79 | Elastic.QuotesPunctuation | Place punctuation inside closing quotation marks. |
💡 Suggestions (1): Optional style improvements. Apply when helpful.
| File | Line | Rule | Message |
|---|---|---|---|
| packages/traefik_otel/docs/README.md | 79 | Elastic.Ellipses | Use ellipses sparingly. Remove the ellipsis unless it appears in UI text. |
The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.
Contributor
|
✅ All changelog entries have the correct PR link. |
💚 Build Succeeded
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
WHY
traefik_otel0.3.1 and its documented collector configuration disagree about the aggregationtemporality of Traefik's Prometheus counters, and ES|QL will not let both be right at once:
time_series_metric: counterTS+RATE()/INCREASE()SUM()/MAX()time_series_metric: gaugeSUM()/MAX()RATE()/INCREASE()The mapping is decided by the collector. The Elasticsearch exporter maps a monotonic sum as a
counter only while its temporality is still cumulative:
The README applied
cumulativetodeltawithmetrics: ['traefik_.*', 'go_.*', 'process_.*'], whichis wide enough to catch every counter and convert it to a delta sum, so it lands as a gauge. The
dashboards'
FROM+SUM()queries only work in that state. Any user who omits or narrows theprocessor gets
counter_doublefields and 27 assets that fail on load with:That the counter contract was the original intent is visible in the shipped alert rules, which carry
this comment directly above a query doing the opposite:
WHAT
This standardises on the counter contract, which is the idiomatic representation for Prometheus
counters and handles counter resets correctly.
TSsourcecommand with counter-aware functions:
RATE()where the panel reported a per-second rate (itpreviously divided a
SUM()by aDATE_DIFFwindow),INCREASE()where it reported a totalover the selected range, and
MAX(LAST_OVER_TIME())for the cumulative "Total Reloads" metric.Output column names, bucketing and result shapes are unchanged so the Lens configurations keep
working. Both the
_dev/shared/kibana/*.yamlauthoring sources and the generatedkibana/dashboard/*.jsonare updated so regeneration cannot reintroduce the old queries.cumulativetodeltafilter to['traefik_.*_request_duration_seconds']. Theprocessor is genuinely required, but only for the request-duration histograms, which the
Prometheus receiver emits as cumulative and the exporter drops in
otelmapping mode. Applyingit to the counters was collateral damage.
created. Recovery needs a rollover, and because documents are routed by
@timestampthe previousbacking index keeps accepting writes until its
index.time_series.end_timehas passed.Gauge-backed panels and rules are untouched. The SLO templates aggregate through the DSL rather than
ES|QL and were never affected.
TS,RATE,INCREASEandLAST_OVER_TIMEare GA since 9.4, matching the package's existingkibana.version: ^9.4.0constraint, so no constraint change is required.Checklist
changelog.ymlfile.Author's Checklist
['traefik_.*_request_duration_seconds']covers every histogram metric that the latency SLO template depends on (traefik_service_request_duration_seconds).RATE()vs the previousSUM()/DATE_DIFF()produces the intended values on the "Over Time" panels.How to test this PR locally
Executed on this branch (Elasticsearch 9.5.0-SNAPSHOT via
elastic-package stack up, OTel-nativemetrics-traefik.otel-*fixture with counter-mapped fields):Every dashboard panel and alerting rule query was run against the stack, on the base commit and on this branch:
Rewritten panels return values consistent with the analytically known rates in the fixture:
The YAML authoring sources reconstruct the JSON queries byte for byte, so regeneration is safe:
Package validation:
The mapping claim behind the README change was verified with a real
otel/opentelemetry-collector-contrib:0.160.0scraping a Prometheus endpoint into the same cluster,varying only the
cumulativetodeltafilter:time_series_metricSUM(field)SUM(RATE(field))gauge.*_request_duration_seconds(new README)counterFor the reviewer (not yet run in this session):
metrics.prometheusenabled.GET /metrics-traefik.otel-default/_mapping/field/*requests_total*reportstime_series_metric: counter.verification_exceptionand that rate panels show plausible values.Related issues
Screenshots
Pending — the four affected dashboards should be captured against a counter-mapped data stream before this leaves draft.