Skip to Content
KubeSense
OpenTelemetry/Metrics

Metrics

Send OpenTelemetry metrics to KubeSense over OTLP/HTTP from SDKs, zero-code agents or a Collector, and query them with PromQL.

KubeSense receives OpenTelemetry metrics over OTLP/HTTP at the Metrics Scraper, and stores them in the KubeSense metrics store next to infrastructure and Prometheus metrics. Counters, gauges, up-down counters and histograms from any OpenTelemetry SDK, zero-code agent or Collector are supported. Query them in dashboards, alerts and the Metrics API with PromQL.

Endpoint

ProtocolOTLP/HTTP, protobuf encoding (http/protobuf). gzip compression is supported
Inside the KubeSense clusterhttp://kubesense-metrics-scraper.kubesense.svc.cluster.local:30060/opentelemetry/v1/metrics
From outside the clusterhttp://<METRICS_SCRAPER_HOST>:30060/opentelemetry/v1/metrics
Enable withmetrics-scraper.service.enabled: true

The path starts with /opentelemetry. Always configure the full URL; an exporter that appends /v1/metrics to a base URL will miss the prefix.

To send from outside the KubeSense cluster, expose the Metrics Scraper through an internal load balancer. See External Service Logs & Metrics.

Not accepted: OTLP/gRPC and OTLP/JSON are not accepted on this endpoint. If your applications export metrics over gRPC, send them to an OpenTelemetry Collector and forward from there.

Send from an application

Set these environment variables on the application. They work for the OpenTelemetry SDKs and zero-code agents in every language:

OTEL_SERVICE_NAME=checkout-api
OTEL_RESOURCE_ATTRIBUTES=kubesense.cluster=prod-eks,kubesense.env_type=k8s
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://kubesense-metrics-scraper.kubesense.svc.cluster.local:30060/opentelemetry/v1/metrics
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
OTEL_METRIC_EXPORT_INTERVAL=30000
  • OTEL_EXPORTER_OTLP_METRICS_ENDPOINT is used as-is, so it must include /opentelemetry/v1/metrics.
  • OTEL_METRIC_EXPORT_INTERVAL is in milliseconds. The SDK default is 60 seconds.
  • Traces go to a different port. Configure them with OTEL_EXPORTER_OTLP_TRACES_ENDPOINT as described in Instrumentation.

Zero-code agents such as the Java and .NET agents emit runtime and HTTP server metrics (for example http.server.request.duration) as soon as the metrics exporter is enabled; check your language's agent for what it emits. Custom metrics you create with the OpenTelemetry Metrics API are exported the same way.

Send through a Collector

Add an otlphttp exporter with metrics_endpoint to the Collector's metrics pipeline:

exporters:
  otlphttp/kubesense_metrics:
    metrics_endpoint: http://kubesense-metrics-scraper.kubesense.svc.cluster.local:30060/opentelemetry/v1/metrics
    tls:
      insecure: true

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, resource, batch]
      exporters: [otlphttp/kubesense_metrics]

Applications then export metrics to the Collector over OTLP/gRPC or OTLP/HTTP. See OpenTelemetry Collector for complete Kubernetes and VM configurations.

How metrics are stored

KubeSense keeps OpenTelemetry names and attributes as they are, so the names you see in your instrumentation are the names you query:

OpenTelemetryStored as
Metric name, for example http.server.request.durationThe same name, dots included
Counter, gauge, up-down counterOne series per attribute set, with the reported value
HistogramThree series: <name>_bucket (with an le label per bucket boundary), <name>_count and <name>_sum
Resource attributes (service.name, kubesense.cluster, k8s.pod.name …)Labels on every series, dots included
Data point attributes (http.route, http.response.status_code …)Labels, dots included
Instrumentation scopescope.name and scope.version labels
UnitNot added to the name

For example, a Python service's request-duration histogram is stored as:

http.server.request.duration_bucket{service.name="checkout-api", kubesense.cluster="prod-eks", http.route="/checkout", le="0.25", ...}
http.server.request.duration_count{...}
http.server.request.duration_sum{...}

Query OpenTelemetry metrics

Use metric and label names with dots directly in PromQL; no quoting is needed:

# Requests per second by service
sum by (service.name) (rate(http.server.request.duration_count[5m]))

# p95 latency by route
histogram_quantile(0.95, sum by (le, http.route) (rate(http.server.request.duration_bucket[5m])))

# A custom counter
sum by (payment.method) (increase(orders.placed[1h]))

Find metric names in the dashboard query builder or with the Metrics API, which lists every metric KubeSense has received.

Temporality

Send cumulative metrics (OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative). Cumulative is the default for most SDKs, and it's what rate() and increase() expect.

Delta metrics are accepted too, but each point is stored as that interval's value rather than a running total. rate() and increase() give wrong results on them. Query delta counters with sum_over_time() instead, or convert them to cumulative in a Collector with the deltatocumulative processor:

processors:
  deltatocumulative: {}

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [deltatocumulative, batch]
      exporters: [otlphttp/kubesense_metrics]

Prometheus-style names

If you'd rather have Prometheus-style names, for example to reuse existing Prometheus dashboards, turn on name conversion in the Metrics Scraper:

metrics-scraper:
  extraArgs:
    opentelemetry.usePrometheusNaming: "true"

With it, dots become underscores, units and _total are appended, and label names are converted too:

DefaultWith usePrometheusNaming
http.server.request.duration_buckethttp_server_request_duration_seconds_bucket
orders.placed (counter)orders_placed_total
service.name labelservice_name label

The setting applies to every OpenTelemetry metric KubeSense receives, so choose before you build dashboards and alerts. Changing it later changes the names they query.

Using prometheusremotewrite instead: Some guides send Collector metrics with the prometheusremotewrite exporter to http://<METRICS_SCRAPER_HOST>:30060/api/v1/write. That still works. It produces Prometheus-style names (http_server_request_duration_seconds_bucket), only accepts cumulative metrics, and silently drops delta sums and histograms unless you add deltatocumulative. Moving a source from remote write to OTLP changes its metric names unless usePrometheusNaming is on.

Troubleshooting

SymptomLikely cause
Connection refused on 30060The Metrics Scraper Service isn't enabled (metrics-scraper.service.enabled) or isn't reachable from the sender
400 Bad RequestThe path is wrong (it must be /opentelemetry/v1/metrics) or the payload is JSON. Use http/protobuf
Exporter errors mentioning gRPCThe metrics exporter uses gRPC. Set OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
Counter rates look wrong or flatThe source sends delta temporality. See Temporality
Metric not found under the expected nameCheck whether Prometheus-style naming is on, and look the metric up with the Metrics API
Data under the wrong clusterkubesense.cluster is missing from the resource attributes

On this page