Skip to content

Prometheus AMP scaler returning error : "Credential should be scoped to a valid region." #5419

@sguruvar

Description

@sguruvar

Report

Amazon Managed Prometheus (AMP) Scaler returning "Credential should be scoped to a valid region."
2024-01-19T22:35:52Z ERROR prometheus_scaler error executing prometheus query {"type": "ScaledObject", "namespace": "default", "name": "so", "error": "prometheus query api returned error. status: 403 response: {\"message\":\"Credential should be scoped to a valid region. \"}"} github.com/kedacore/keda/v2/pkg/scalers.(*prometheusScaler).GetMetricsAndActivity /workspace/pkg/scalers/prometheus_scaler.go:391

Expected Behavior

Root cause is that the AWS region is taken as empty

Actual Behavior

2024-01-19T22:35:52Z ERROR prometheus_scaler error executing prometheus query {"type": "ScaledObject", "namespace": "default", "name": "so", "error": "prometheus query api returned error. status: 403 response: {\"message\":\"Credential should be scoped to a valid region. \"}"} github.com/kedacore/keda/v2/pkg/scalers.(*prometheusScaler).GetMetricsAndActivity /workspace/pkg/scalers/prometheus_scaler.go:391

Steps to Reproduce the Problem

  1. Take latest Keda core with helm v2.13.1
  2. Try with the below podIdentity and scaledObject
  3. You will see the error
    apiVersion: keda.sh/v1alpha1 kind: TriggerAuthentication metadata: name: keda-trigger-auth-aws-credentials spec: podIdentity: provider: aws

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: so spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: songinx cooldownPeriod: 1 fallback: failureThreshold: 3 replicas: 1 minReplicaCount: 1 maxReplicaCount: 30 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: stabilizationWindowSeconds: 15 triggers: - type: prometheus authenticationRef: name: keda-trigger-auth-aws-credentials metadata: serverAddress: https://aps-workspaces.us-east-2.amazonaws.com/workspaces/ws-d3284d62-5c77-4c0d-8095-7f752dd585dc metricName: s0-prometheus awsRegion: us-east-2 threshold: "10.0" query: vector(100) identityOwner: operator

Logs from KEDA operator

2024-01-19T22:35:52Z	ERROR	prometheus_scaler	error executing prometheus query	{"type": "ScaledObject", "namespace": "default", "name": "so", "error": "prometheus query api returned error. status: 403 response: {\"message\":\"Credential should be scoped to a valid region. \"}"}
github.com/kedacore/keda/v2/pkg/scalers.(*prometheusScaler).GetMetricsAndActivity
	/workspace/pkg/scalers/prometheus_scaler.go:391

KEDA Version

2.13.0

Kubernetes Version

1.27

Platform

Amazon Web Services

Scaler Details

Prometheus

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Ready To Ship

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions