Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Export node cpu metrics in whole cores #1983

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions metrics/sinks/stackdriver/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,10 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str
nodeLabels := sink.getNodeResourceLabels(labels)
switch name {
case core.MetricNodeCpuCapacity.MetricDescriptor.Name:
point := sink.doublePoint(timestamp, timestamp, float64(value.FloatValue))
point := sink.doublePoint(timestamp, timestamp, float64(value.FloatValue)/1000)
return createTimeSeries("k8s_node", nodeLabels, cpuTotalCoresMD, point)
case core.MetricNodeCpuAllocatable.MetricDescriptor.Name:
point := sink.doublePoint(timestamp, timestamp, float64(value.FloatValue))
point := sink.doublePoint(timestamp, timestamp, float64(value.FloatValue)/1000)
return createTimeSeries("k8s_node", nodeLabels, cpuAllocatableCoresMD, point)
case core.MetricCpuUsage.MetricDescriptor.Name:
point := sink.doublePoint(timestamp, collectionStartTime, float64(value.IntValue)/float64(time.Second/time.Nanosecond))
Expand Down
4 changes: 2 additions & 2 deletions metrics/sinks/stackdriver/stackdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ func TestTranslateMetricSet(t *testing.T) {
podVolumeTotal := testTranslateLabeledMetric(as, podLabels, generateLabeledIntMetric(11, map[string]string{}, "filesystem/limit"), "kubernetes.io/pod/volume/total_bytes")
podVolumeUsed := testTranslateLabeledMetric(as, podLabels, generateLabeledIntMetric(12, map[string]string{}, "filesystem/usage"), "kubernetes.io/pod/volume/used_bytes")
nodeCpuUsage := testTranslateMetric(as, generateIntMetric(13000000000), nodeLabels, "cpu/usage", "kubernetes.io/node/cpu/core_usage_time")
nodeCpuTotal := testTranslateMetric(as, generateFloatMetric(14), nodeLabels, "cpu/node_capacity", "kubernetes.io/node/cpu/total_cores")
nodeCpuAllocatable := testTranslateMetric(as, generateFloatMetric(15), nodeLabels, "cpu/node_allocatable", "kubernetes.io/node/cpu/allocatable_cores")
nodeCpuTotal := testTranslateMetric(as, generateFloatMetric(14000), nodeLabels, "cpu/node_capacity", "kubernetes.io/node/cpu/total_cores")
nodeCpuAllocatable := testTranslateMetric(as, generateFloatMetric(15000), nodeLabels, "cpu/node_allocatable", "kubernetes.io/node/cpu/allocatable_cores")
nodeMemoryUsage := testTranslateMetric(as, generateIntMetric(16), nodeLabels, "memory/bytes_used", "kubernetes.io/node/memory/used_bytes")
nodeMemoryTotal := testTranslateMetric(as, generateIntMetric(17), nodeLabels, "memory/node_capacity", "kubernetes.io/node/memory/total_bytes")
nodeMemoryAllocatable := testTranslateMetric(as, generateIntMetric(18), nodeLabels, "memory/node_allocatable", "kubernetes.io/node/memory/allocatable_bytes")
Expand Down