Why Kubernetes HPA convert custom metric?

3/26/2019

Kubernetes Horisontal Pod Autoscaling (HPA) modifies my custom metric: StackDriver displays correct metric, but HPA shows another number. For example, StackDrives value is 118K, but HPA displays 1656144. I understand that HPA use some conversation for floating numbers, but my metric is integer: Unit: number Kind: Gauge Value type: Int64.

Running in GKE 1.11.7.

Any ideas?

-- Vitaly
kubernetes

2 Answers

5/20/2019

In your HPA manifest you did not specify value of --horizontal-pod-autoscaler-sync-period flag. As default it is set to 15 seconds.

In your case it means that HPA value is amout of whole deployment queue in last 15 seconds. More information can be found in HPA Documentation.

As you mentioned in StackDriver you used GAUGE metric which measures a value at a particular point in time - Stackdriver

In short, StackDriver shows current value in the exact time, HPA values is amount of last 15 seconds.

-- PjoterS
Source: StackOverflow

4/23/2019

if you specify targetValue it will be a whole number, so there won't be scaling down of pods. If you use targetAverageValue it will calculate based on the number of pods created.

-- Sai Prasanth
Source: StackOverflow