#8210·keda

Dynatrace scaler does not trigger fallback when DQL returns MISSING_BUCKET_PERMISSIONS

Author: escomputersCreated Sep 21, 2026Updated Sep 22, 2026
Labelsbugscalerscaler-dynatrace

Report

When using the Dynatrace scaler with a DQL query, Dynatrace returns a successful query response (state: SUCCEEDED) even when the token does not have permission to read the metrics bucket.

The completed query result contains a MISSING_BUCKET_PERMISSIONS warning in result.metadata.grail.notifications while still being reported as SUCCEEDED.

If the DQL query is written to return r = 0 when no metric data is available, KEDA treats the query as successful and the trigger as inactive. As a result, the configured fallback is not activated.

This can be problematic with minReplicaCount: 0, because a permissions issue may be interpreted in the same way as a legitimate zero metric value and the workload can scale to zero.

Expected Behavior

A Dynatrace response indicating that the requested metrics cannot be read because of missing bucket permissions should be considered as a scaler failure, so that the normal KEDA fallback mechanism can take effect.

Actual Behavior

Dynatrace returns HTTP success and state: SUCCEEDED, but the response also contains:

json
{
  "records": [
    {
      "r": 0.0
    }
  ],
  "metadata": {
    "grail": {
      "notifications": [
        {
          "message": "No bucket permissions for table metrics.",
          "notificationType": "MISSING_BUCKET_PERMISSIONS",
          "severity": "WARNING"
        }
      ]
    }
  }
}

The Dynatrace scaler remains healthy and no query error is reported. So, KEDA does not report a scaler failure, numberOfFailures remains 0, and the configured fallback is not activated.

ScaledObject status:

yaml
health:
  s0-dynatrace:
    numberOfFailures: 0
    status: Happy

fallback:
  reason: NoFallbackFound

Steps to Reproduce the Problem

  1. In Dynatrace, create or use an existing metric that can be queried through Grail, and create a valid platform token DT_TOKEN that can authenticate successfully but intentionally does not have permission to read the metrics bucket.

  2. Create a DQL query that explicitly returns r = 0 when no matching metric data is available, and save it as a valid Dynatrace API request payload:

bash
QUERY=$(cat <<'DQL'
timeseries metric_count = sum(<existing-metric-key>, default:0),
  from: now()-2h
| fieldsAdd metric_total = arraySum(metric_count)
| fields metric_total
| append [data record(metric_total = 0)]
| summarize r = toDouble(sum(metric_total))
DQL
)

jq -n \
  --arg query "$QUERY" \
  '{
    query: $query,
    timezone: "UTC",
    requestTimeoutMilliseconds: 60000,
    maxResultRecords: 10
  }' > /tmp/dt-query.json

Replace <existing-metric-key> with a metric available in the Dynatrace environment.

  1. Configure fallback on the ScaledObject, for example:
yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: dynatrace-fallback-repro
  namespace: default
spec:
  scaleTargetRef:
    name: test-deployment

  minReplicaCount: 0
  maxReplicaCount: 2
  pollingInterval: 60
  cooldownPeriod: 30

  fallback:
    failureThreshold: 1
    replicas: 2
    behavior: static

  triggers:
    - type: dynatrace
      authenticationRef:
        name: dynatrace-auth
        kind: ClusterTriggerAuthentication
      metadata:
        query: >-
          timeseries metric_count = sum(example.metric, default:0),
            from: now()-2h
          | fieldsAdd metric_total = arraySum(metric_count)
          | fields metric_total
          | append [data record(metric_total = 0)]
          | summarize r = toDouble(sum(metric_total))
        threshold: "1"
        activationThreshold: "0"
  1. Execute the query using the same Dynatrace token configured for the scaler:
bash
curl -sS -X POST \
  "$DT_HOST/platform/storage/query/v1/query:execute?enrich=metric-metadata" \
  -H "Authorization: Bearer $DT_TOKEN" \
  -H "Content-Type: application/json" \
  --data @/tmp/dt-query.json
  1. Observe that Dynatrace returns a successful query response (state: SUCCEEDED) with r: 0, while also reporting:
json
   notificationType: MISSING_BUCKET_PERMISSIONS
   message: "No bucket permissions for table metrics."
  1. Observe that KEDA considers the scaler healthy and fallback is not activated.

Logs from KEDA operator

KEDA Version

2.20.1

Kubernetes Version

1.35

Platform

Microsoft Azure

Scaler Details

Dynatrace

Would you be open to contributing a fix?

Maybe

Anything else?

From looking at the current Dynatrace scaler implementation, it appears that the DQL response handling uses the query state and result.records[].r, while Grail notifications are not evaluated

One possible direction might be to treat permission-related notifications such as MISSING_BUCKET_PERMISSIONS as a scaler error, allowing the existing fallback mechanism to handle the condition. However, I would leave the appropriate handling to the maintainers.

Thanks