Technology
KEDA
Enable event-driven autoscaling in Kubernetes with KEDA, OpenTelemetry observability, and Dash0 metrics integration for Prometheus-based scaling.
Overview
KEDA Integration in Dash0
KEDA (Kubernetes Event-Driven Autoscaling) is a lightweight component that brings event-driven autoscaling to Kubernetes by managing Horizontal Pod Autoscalers behind the scenes. Unlike traditional HPA scaling based on CPU and memory, KEDA can scale workloads based on events and external signals like message queue depth, database job tables, or custom application metrics.
This integration enables comprehensive observability of KEDA's control plane through OpenTelemetry metrics while demonstrating how to use Dash0's Prometheus-compatible API to drive intelligent autoscaling decisions.
For more information, visit the KEDA Project Page.
Use Cases
Transform your Kubernetes autoscaling strategy with event-driven patterns:
- Observable Autoscaling: Monitor KEDA's internal metrics to understand scaling decisions and troubleshoot autoscaler behavior
- Custom Metrics Scaling: Scale workloads based on application-specific metrics from Dash0, moving beyond CPU and memory
- Scale-to-Zero: Efficiently scale workloads down to zero replicas when no work is waiting, optimizing resource usage
- Event-Driven Workloads: Respond to external signals like queue depth, database job counts, or scheduled events
- Multi-Trigger Scaling: Combine multiple scaling triggers for complex autoscaling logic
Setup
Setup
This guide shows how to set up KEDA with OpenTelemetry observability and Dash0 integration. For a complete working example, see the Dash0 KEDA demo repository.
1. Install KEDA with OpenTelemetry
Install KEDA with OpenTelemetry metrics enabled:
helm repo add kedacore https://kedacore.github.io/charts
helm repo updateCreate a values file for KEDA:
# keda-values.yaml
extraArgs:
keda:
enable-prometheus-metrics: "false"
enable-opentelemetry-metrics: "true"
env:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://<opentelemetry collector endpoint>:4318"
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: "http/protobuf"
- name: OTEL_SERVICE_NAME
value: "keda-operator"Install KEDA:
helm install keda kedacore/keda \
--namespace keda \
--create-namespace \
-f keda-values.yaml2. Configure Authentication
Create a Kubernetes secret with your Dash0 API token:
kubectl create secret generic dash0-api-secret --from-literal=apiToken={{token}} --namespace <your-app-namespace>Create a TriggerAuthentication resource:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: dash0-auth
namespace: <your-app-namespace>
spec:
secretTargetRef:
- parameter: bearerToken
name: dash0-api-secret
key: apiToken3. Example: HTTP Request Rate Scaling
Create a ScaledObject that scales based on HTTP request rate from Dash0:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: <scaler-name>
namespace: <your-app-namespace>
spec:
scaleTargetRef:
name: <your-http-app>
minReplicaCount: 1
maxReplicaCount: 10
triggers:
- type: prometheus
name: <scaler-name>
metadata:
serverAddress: { { endpoint_api_prometheus } }
query: |
sum(rate({otel_metric_name="http.server.duration", service_name="your-app"}[2m]))
threshold: "5"
authModes: "bearer"
authenticationRef:
name: dash0-authConfigure the OpenTelemetry Collector
KEDA sends telemetry data to an OpenTelemetry Collector, which forwards it to Dash0.
For production environments, consider using one of these deployment methods:
- Dash0 operator for Kubernetes (recommended)
- OpenTelemetry Operator for Kubernetes
-
Helm Chart for The OpenTelemetry Collector
The key requirement is that your collector accepts OTLP/HTTP on port 4318.
Next Steps
- Explore the KEDA scalers documentation for more trigger types
- Set up alerts based on KEDA control plane metrics
- Create custom dashboards combining KEDA metrics with application metrics
- Experiment with multiple triggers on a single ScaledObject for complex scaling logic
