Metrics API Latest

Scale applications based on a metric provided by an API

Availability: v2.0+ Maintainer: Community

Suggest a change

Trigger Specification

This specification describes the metrics-api trigger that scales based on a metric value provided by an API.

This scaler allows users to utilize any existing APIs as a metric provider.

Here is an example of trigger configuration using metric-api scaler:

- type: metric-api
    targetValue: "8"
    url: "http://api:3232/api/v1/stats"
    valueLocation: "components.worker.tasks"

Parameter list:

  • url: Full URL of the API operation to call to get the metric value (eg. http://app:1317/api/v1/stats).
  • valueLocation: GJSON path notation to refer to the field in the payload containing the metric value
  • targetValue: Target value to scale on. When the metric provided by the API is equal or higher to this value, KEDA will start scaling out. When the metric is 0 or less, KEDA will scale down to 0.

Authentication Parameters

Not supported yet.


Here is a full example of scaled object definition using Metric API trigger:

kind: ScaledObject
  name: http-scaledobject
  namespace: keda
    deploymentName: dummy
  maxReplicaCount: 12
    name: dummy
    - type: metrics-api
        targetValue: "7"
        url: "http://api:3232/components/stats"
        valueLocation: 'components.worker.tasks'

When checking current metric Metrics API scaler sends GET request to provided url and then uses valueLocation to access the value in response’s payload.

The above example expects that the API endpoint will return response similar to this one:

  "components": {
    "worker": {
      "tasks": 12,

Assuming such response, Metrics API trigger will figure out that current metric value is 12.

NOTE: The value of the metric must be json number type. The value is casted to integer.

Currently available scalers for KEDA