RousselTMLEARNING

Observability

OpenTelemetry metrics in Elasticsearch

Collect host, Kubernetes and application metrics with OpenTelemetry, understand temporality and types, store them in time series data streams and query them.

1. Sources #

Hosts, Kubernetes, applications.

Receivers #

hostmetrics, kubeletstats, applications, Collector, Elasticsearch.
receivers:
  hostmetrics:
    collection_interval: 30s
    scrapers: { cpu: {}, memory: {}, load: {}, filesystem: {}, network: {} }
  kubeletstats:
    auth_type: serviceAccount
    endpoint: https://${env:K8S_NODE_NAME}:10250
    insecure_skip_verify: true
processors:
  resourcedetection: { detectors: [env, system] }

2. Types and temporality #

What changes storage.

Metric types #

TypeExampleNote
Gaugesystem.memory.utilizationinstantaneous value
Sum (counter)http.server.request.countcumulative or delta
Histogramhttp.server.request.durationstored as a histogram, percentiles computed

Temporality #

Elasticsearch stores cumulative counters as well as deltas; for rate calculations, prefer a consistent temporality per source. The cumulativetodelta processor converts when needed.

Good to know: OTel metrics are written to TSDS (time series data streams): compact storage, indexed dimensions, and downsampling for long retention.

3. Querying and alerting #

ES|QL, dashboards, rules.

Queries #

FROM metrics-*.otel-*
| WHERE metrics.system.cpu.utilization IS NOT NULL
| STATS cpu = AVG(metrics.system.cpu.utilization) BY host = resource.attributes.host.name, BUCKET(@timestamp, 5 minutes)
| SORT cpu DESC
Good practice: Limit attribute cardinality (no user ID or full URL as a dimension): each combination creates a time series.
Depending on the version: exact field names (metrics.*) depend on the exporter version and mapping mode: check them in Discover before building dashboards.

Related articles

Transforms and enrich: summarising and enriching data in Elasticsearch

Build entity-centric indices with pivot and latest transforms, and enrich documents at ingest time with enric…

OpenTelemetry and Elasticsearch: compatibility and architecture

Send OpenTelemetry to Elasticsearch: Collector and elasticsearch exporter, managed OTLP endpoint, APM Server,…

Ingesting OpenTelemetry logs into Elasticsearch

Collect and structure logs with the OpenTelemetry Collector (filelog receiver, operators, transform processor…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!