How to get value of external metrics in k8s and prometheus-adapter

75 views Asked by At

I have a k8s on AWS (EKS). I'm using prometheus-adapter to expose custom metrics and external metrics for HPA (HorizontalPodAutoscaler). I'm using Helm to install prometheus-adapter (Chart version 4.9.0).

I'm trying to fetch the value for my external metrics but failing to do so.

I can see that the metrics is there:

kubectl get --raw '/apis/external.metrics.k8s.io/v1beta1' | jq .

outputs:

{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "external.metrics.k8s.io/v1beta1",
  "resources": [
    {
      "name": "some_dummy_sqs_01",
      "singularName": "",
      "namespaced": true,
      "kind": "ExternalMetricValueList",
      "verbs": [
        "get"
      ]
    }
  ]
}

I have tried with the following paths, with no luck:

  1. /apis/external.metrics.k8s.io/v1beta1/some_dummy_sqs_01 -> Error from server (NotFound): the server could not find the requested resource
  2. /apis/external.metrics.k8s.io/v1beta1/namespaces/some_dummy_sqs_01 -> Error from server (NotFound): the server could not find the requested resource
  3. /apis/external.metrics.k8s.io/v1beta1/namespaces//some_dummy_sqs_01 -> Error from server (InternalError): Internal error occurred: unable to fetch metrics
  4. /apis/external.metrics.k8s.io/v1beta1/namespaces/*/some_dummy_sqs_01 -> Error from server (InternalError): Internal error occurred: unable to fetch metrics
  5. /apis/external.metrics.k8s.io/v1beta1/namespaces/prometheus/some_dummy_sqs_01 -> Error from server (InternalError): Internal error occurred: unable to fetch metrics

prometheus-adapter configuration looks like this:

# prom-adapter-values.yaml

prometheus:
  url: http://prometheus-server
  port: 80

rules:
  default: false
  external:
    - seriesQuery: 'sqs_approximatenumberofmessages{queue!="",namespace!=""}'
      resources:
        namespaced: false
      name:
        matches: ""
        as: "some_dummy_sqs_01"
      metricsQuery: 'sum(rate(<<.Series>>[1m]) by (queue)'

0

There are 0 answers