# OpenTelemetry scaler

The `kedify-otel` scaler evaluates application metrics in a short-term in-memory store. Use it in a ScaledObject or ScaledJob with a query and target value. Metrics can arrive directly over OTLP or through an OpenTelemetry Collector.

## Set up a metric source

Start with [a working OTel example](https://docs.kedify.io/how-to/scale-with-otel/). Choose [direct OTLP, sidecar, discovery or collector ingestion](https://docs.kedify.io/how-to/otel-scaler-integrations/) for your deployment. Existing recipes cover [Prometheus migration](https://docs.kedify.io/how-to/otel-scaler-migrate/), [Ingress NGINX metrics](https://docs.kedify.io/how-to/otel-scaler-ingress-nginx/) and [vLLM metrics](https://docs.kedify.io/how-to/otel-scaler-general/).

For HTTP proxy and interceptor request traces, see [OpenTelemetry tracing](https://docs.kedify.io/how-to/otel-tracing-proxy-and-interceptor/).

## Architecture

[![OTel Scaler Architecture](https://docs.kedify.io/assets/images/docs/otel-scaler.svg)](https://docs.kedify.io/assets/images/docs/otel-scaler.svg)

Scroll to exploreDiagram description

Pull sources and workload endpoints are scraped by an OpenTelemetry Collector; push sources emit OTLP directly. The OTel scaler's OTLP receiver writes a short-term in-memory metric store. Its external-scaler API selects and aggregates samples using the ScaledObject metricQuery and operationOverTime. KEDA reads the result over gRPC, and KEDA with HPA or KPA updates the target workload. The same workload can provide the measured signal, closing the feedback loop.

## Example ScaledObject with Kedify OTEL Trigger

Here is a full example of a ScaledObject definition using the Kedify OTEL trigger, including advanced configurations for the `horizontalPodAutoscalerConfig`:

```yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: otel-example
spec:
  scaleTargetRef:
    name: nodeapp
  triggers:
    - type: kedify-otel
      metadata:
        scalerAddress: "keda-otel-scaler.default.svc:4318"
        metricQuery: "avg(http_server_request_count{app_id=nodeapp, method=GET, path=/v1.0/state/statestore})"
        targetValue: "5"
        clampMin: "0"
        clampMax: "10"
        operationOverTime: "rate"
  advanced:
    horizontalPodAutoscalerConfig:
      behavior:
        scaleDown:
          stabilizationWindowSeconds: 10
        scaleUp:
          stabilizationWindowSeconds: 10
```

## Verify and tune

Generate representative demand and confirm the query returns fresh values with the intended labels and units. Inspect ScaledObject/ScaledJob status, desired replicas or jobs, ready capacity, and application latency or backlog. Metrics emitted only by stopped pods cannot reliably activate a workload from zero.

Use [KEDA tuning](https://docs.kedify.io/best-practices/keda-best-practices/) for polling, caching, fallback and stabilization. Diagnose stale or missing metrics with [workload troubleshooting](https://docs.kedify.io/troubleshooting/workload-scaling/).

For a visual comparison of `last_one`, `avg`, `max` and counter rates, see the [worked metric-window graph](https://docs.kedify.io/reference/otel-scaler/#operation-over-time).

## Configuration reference

[OTel configuration](https://docs.kedify.io/reference/otel-scaler/) covers query syntax, temporal operations, ingestion and all trigger fields.

---
Canonical: https://docs.kedify.io/scalers/otel-scaler/
Source: src/content/docs/scalers/otel-scaler.md
Documentation index: https://docs.kedify.io/llms.txt
