kubectl get --raw '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/app_request_count_per_second'| jq
{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta1",
"metadata": {},
"items": [
{
"describedObject": {
"kind": "Pod",
"namespace": "default",
"name": "hello-pod",
"apiVersion": "/v1"
},
"metricName": "app_request_count_per_second",
"timestamp": "2024-05-29T08:38:20Z",
"value": "5914m",
"selector": null
}
]
}
this is ready for custom.metrics.k8s.io api. And this is my hpa.yaml
cat hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: hello-hpa
namespace: prometheus
spec:
minReplicas: 1
maxReplicas: 3
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hello-pod
metrics:
- type: Pods
pods:
metric:
name: app_request_count_per_second
target:
type: AverageValue
averageValue: 4
but I get this error in hpa describe. “FailedGetPodsMetric the HPA was unable to compute the replica count: unable to get metric app_request_count_per_second: no metrics returned from custom metrics API”
Events:
“Warning FailedComputeMetricsReplicas 26m (x12 over 29m) horizontal-pod-autoscaler invalid metrics (1 invalid out of 1), first error is: failed to get pods metric value: unable to get metric app_request_count_per_second: no metrics returned from custom metrics API
Warning FailedGetPodsMetric 3m55s (x101 over 29m) horizontal-pod-autoscaler unable to get metric app_request_count_per_second: no metrics returned from custom metrics API”