Scale resource quota used/hard values correctly
package metrics
import (
+ "strings"
+
"github.com/signalfx/golib/datapoint"
"github.com/signalfx/golib/sfxclient"
"k8s.io/api/core/v1"
)
// GAUGE(kubernetes.resource_quota_used): The usage for a particular resource
-// in a specific namespace. Will only be sent if a quota is specified.
+// in a specific namespace. Will only be sent if a quota is specified. CPU
+// requests/limits will be sent as millicores.
// GAUGE(kubernetes.resource_quota_hard): The upper limit for a particular
// resource in a specific namespace. Will only be sent if a quota is
-// specified.
+// specified. CPU requests/limits will be sent as millicores.
// DIMENSION(resource): The k8s resource that the quota applies to
// DIMENSION(quota_name): The name of the k8s ResourceQuota object that the
@@ -40,11 +43,12 @@ func datapointsForResourceQuota(rq *v1.ResourceQuota) []*datapoint.Datapoint {
"kubernetes_namespace": rq.Namespace,
}
- asInt, ok := v.AsInt64()
- if !ok {
- asInt = v.AsDec().UnscaledBig().Int64()
+ val := v.Value()
+ if strings.HasSuffix(rq.Name, ".cpu") {
+ val = v.MilliValue()
}
- dps = append(dps, sfxclient.Gauge("kubernetes.resource_quota_"+t.typ, dims, asInt))
+
+ dps = append(dps, sfxclient.Gauge("kubernetes.resource_quota_"+t.typ, dims, val))
}
}
return dps
