diff --git a/metrics/core/labels.go b/metrics/core/labels.go index 6172908a6b..c85a1fef19 100644 --- a/metrics/core/labels.go +++ b/metrics/core/labels.go @@ -89,6 +89,10 @@ var ( Key: "schedulable", Description: "Node schedulable status.", } + LabelVolumeName = LabelDescriptor{ + Key: "volume_name", + Description: "The name of the volume.", + } ) type LabelDescriptor struct { diff --git a/metrics/core/metrics.go b/metrics/core/metrics.go index 085c4e0ea3..057dea7395 100644 --- a/metrics/core/metrics.go +++ b/metrics/core/metrics.go @@ -685,28 +685,6 @@ var MetricFilesystemAvailable = Metric{ }, } -var MetricVolumeTotal = Metric{ - MetricDescriptor: MetricDescriptor{ - Name: "volume/total_bytes", - Description: "Total bytes reserved for a volume", - Type: MetricGauge, - ValueType: ValueInt64, - Units: UnitsBytes, - Labels: metricLabels, - }, -} - -var MetricVolumeUsage = Metric{ - MetricDescriptor: MetricDescriptor{ - Name: "volume/used_bytes", - Description: "Usage bytes reserved for a volume", - Type: MetricGauge, - ValueType: ValueInt64, - Units: UnitsBytes, - Labels: metricLabels, - }, -} - var MetricFilesystemInodes = Metric{ MetricDescriptor: MetricDescriptor{ Name: "filesystem/inodes", diff --git a/metrics/sinks/stackdriver/metadata.go b/metrics/sinks/stackdriver/metadata.go index f17cbdde57..c6839c71e0 100644 --- a/metrics/sinks/stackdriver/metadata.go +++ b/metrics/sinks/stackdriver/metadata.go @@ -34,7 +34,7 @@ var ( cpuRequestedCoresMD = &metricMetadata{ MetricKind: "GAUGE", ValueType: "DOUBLE", - Name: "kubernetes.io/container/cpu/requested_cores", + Name: "kubernetes.io/container/cpu/request_cores", } cpuLimitCoresMD = &metricMetadata{ @@ -52,7 +52,7 @@ var ( memoryRequestedBytesMD = &metricMetadata{ MetricKind: "GAUGE", ValueType: "INT64", - Name: "kubernetes.io/container/memory/requested_bytes", + Name: "kubernetes.io/container/memory/request_bytes", } memoryLimitBytesMD = &metricMetadata{ @@ -75,22 +75,22 @@ var ( Name: "kubernetes.io/pod/volume/used_bytes", } - volumeRequestedBytesMD = &metricMetadata{ + volumeTotalBytesMD = &metricMetadata{ MetricKind: "GAUGE", ValueType: "INT64", - Name: "kubernetes.io/pod/volume/requested_bytes", + Name: "kubernetes.io/pod/volume/total_bytes", } - networkPodRxMD = &metricMetadata{ + networkPodReceivedBytesMD = &metricMetadata{ MetricKind: "CUMULATIVE", ValueType: "INT64", - Name: "kubernetes.io/pod/network/bytes_rx", + Name: "kubernetes.io/pod/network/received_bytes_count", } - networkPodTxMD = &metricMetadata{ + networkPodSentBytesMD = &metricMetadata{ MetricKind: "CUMULATIVE", ValueType: "INT64", - Name: "kubernetes.io/pod/network/bytes_tx", + Name: "kubernetes.io/pod/network/sent_bytes_count", } // Node metrics @@ -131,16 +131,16 @@ var ( Name: "kubernetes.io/node/memory/allocatable_bytes", } - networkNodeRxMD = &metricMetadata{ + networkNodeReceivedBytesMD = &metricMetadata{ MetricKind: "CUMULATIVE", ValueType: "INT64", - Name: "kubernetes.io/node/network/bytes_rx", + Name: "kubernetes.io/node/network/received_bytes_count", } - networkNodeTxMD = &metricMetadata{ + networkNodeSentBytesMD = &metricMetadata{ MetricKind: "CUMULATIVE", ValueType: "INT64", - Name: "kubernetes.io/node/network/bytes_tx", + Name: "kubernetes.io/node/network/sent_bytes_count", } cpuNodeDaemonCoreUsageTimeMD = &metricMetadata{ diff --git a/metrics/sinks/stackdriver/stackdriver.go b/metrics/sinks/stackdriver/stackdriver.go index 85b0164372..aafc2ecacb 100644 --- a/metrics/sinks/stackdriver/stackdriver.go +++ b/metrics/sinks/stackdriver/stackdriver.go @@ -32,6 +32,7 @@ import ( sd_api "google.golang.org/api/monitoring/v3" gce_util "k8s.io/heapster/common/gce" "k8s.io/heapster/metrics/core" + "strings" ) const ( @@ -310,7 +311,6 @@ func (sink *StackdriverSink) sendOneRequest(req *sd_api.CreateTimeSeriesRequest) WithLabelValues(strconv.Itoa(responseCode)). Add(float64(len(req.TimeSeries))) requestLatency.Observe(time.Since(startTime).Seconds() / time.Millisecond.Seconds()) - } func CreateStackdriverSink(uri *url.URL) (core.DataSink, error) { @@ -531,18 +531,18 @@ func (sink *StackdriverSink) TranslateLabeledMetric(timestamp time.Time, labels case core.MetricSetTypePod: podLabels := sink.getPodResourceLabels(labels) switch metric.Name { - case core.MetricVolumeUsage.MetricDescriptor.Name: + case core.MetricFilesystemUsage.MetricDescriptor.Name: point := sink.intPoint(timestamp, timestamp, metric.MetricValue.IntValue) ts := createTimeSeries("k8s_pod", podLabels, volumeUsedBytesMD, point) ts.Metric.Labels = map[string]string{ - "name": metric.Labels[core.LabelResourceID.Key], + core.LabelVolumeName.Key: strings.TrimPrefix(metric.Labels[core.LabelResourceID.Key], "Volume:"), } return ts - case core.MetricVolumeTotal.MetricDescriptor.Name: + case core.MetricFilesystemLimit.MetricDescriptor.Name: point := sink.intPoint(timestamp, timestamp, metric.MetricValue.IntValue) - ts := createTimeSeries("k8s_pod", podLabels, volumeRequestedBytesMD, point) + ts := createTimeSeries("k8s_pod", podLabels, volumeTotalBytesMD, point) ts.Metric.Labels = map[string]string{ - "name": metric.Labels[core.LabelResourceID.Key], + core.LabelVolumeName.Key: strings.TrimPrefix(metric.Labels[core.LabelResourceID.Key], "Volume:"), } return ts } @@ -601,10 +601,10 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str switch name { case core.MetricNetworkRx.MetricDescriptor.Name: point := sink.intPoint(timestamp, createTime, value.IntValue) - return createTimeSeries("k8s_pod", podLabels, networkPodRxMD, point) + return createTimeSeries("k8s_pod", podLabels, networkPodReceivedBytesMD, point) case core.MetricNetworkTx.MetricDescriptor.Name: point := sink.intPoint(timestamp, createTime, value.IntValue) - return createTimeSeries("k8s_pod", podLabels, networkPodTxMD, point) + return createTimeSeries("k8s_pod", podLabels, networkPodSentBytesMD, point) } case core.MetricSetTypeNode: nodeLabels := sink.getNodeResourceLabels(labels) @@ -640,10 +640,10 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str return ts case core.MetricNetworkRx.MetricDescriptor.Name: point := sink.intPoint(timestamp, createTime, value.IntValue) - return createTimeSeries("k8s_node", nodeLabels, networkNodeRxMD, point) + return createTimeSeries("k8s_node", nodeLabels, networkNodeReceivedBytesMD, point) case core.MetricNetworkTx.MetricDescriptor.Name: point := sink.intPoint(timestamp, createTime, value.IntValue) - return createTimeSeries("k8s_node", nodeLabels, networkNodeTxMD, point) + return createTimeSeries("k8s_node", nodeLabels, networkNodeSentBytesMD, point) } case core.MetricSetTypeSystemContainer: nodeLabels := sink.getNodeResourceLabels(labels) @@ -652,6 +652,7 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str point := sink.intPoint(timestamp, timestamp, value.IntValue) ts := createTimeSeries("k8s_node", nodeLabels, memoryNodeDaemonUsedBytesMD, point) ts.Metric.Labels = map[string]string{ + "component": labels[core.LabelContainerName.Key], "memory_type": "evictable", } return ts @@ -659,12 +660,17 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str point := sink.intPoint(timestamp, timestamp, value.IntValue) ts := createTimeSeries("k8s_node", nodeLabels, memoryNodeDaemonUsedBytesMD, point) ts.Metric.Labels = map[string]string{ + "component": labels[core.LabelContainerName.Key], "memory_type": "non-evictable", } return ts case core.MetricCpuUsage.MetricDescriptor.Name: point := sink.doublePoint(timestamp, createTime, float64(value.IntValue)/float64(time.Second/time.Nanosecond)) - return createTimeSeries("k8s_node", nodeLabels, cpuNodeDaemonCoreUsageTimeMD, point) + ts := createTimeSeries("k8s_node", nodeLabels, cpuNodeDaemonCoreUsageTimeMD, point) + ts.Metric.Labels = map[string]string{ + "component": labels[core.LabelContainerName.Key], + } + return ts } } return nil diff --git a/metrics/sinks/stackdriver/stackdriver_test.go b/metrics/sinks/stackdriver/stackdriver_test.go index 5a287261f9..19001e19ff 100644 --- a/metrics/sinks/stackdriver/stackdriver_test.go +++ b/metrics/sinks/stackdriver/stackdriver_test.go @@ -37,7 +37,7 @@ var ( containerLabels = map[string]string{"type": "pod_container"} podLabels = map[string]string{"type": "pod"} nodeLabels = map[string]string{"type": "node"} - nodeDaemonLabels = map[string]string{"type": "sys_container"} + nodeDaemonLabels = map[string]string{"type": "sys_container", "container_name": "kubelet"} ) func generateIntMetric(value int64) core.MetricValue { @@ -291,24 +291,24 @@ func TestTranslateMetricSet(t *testing.T) { containerUptime := testTranslateMetric(as, generateIntMetric(1000), containerLabels, "uptime", "kubernetes.io/container/uptime") containerCpuUsage := testTranslateMetric(as, generateIntMetric(2000000000), containerLabels, "cpu/usage", "kubernetes.io/container/cpu/core_usage_time") - containerCpuRequest := testTranslateMetric(as, generateIntMetric(3000), containerLabels, "cpu/request", "kubernetes.io/container/cpu/requested_cores") + containerCpuRequest := testTranslateMetric(as, generateIntMetric(3000), containerLabels, "cpu/request", "kubernetes.io/container/cpu/request_cores") containerCpuLimit := testTranslateMetric(as, generateIntMetric(4000), containerLabels, "cpu/limit", "kubernetes.io/container/cpu/limit_cores") containerMemoryUsage := testTranslateMetric(as, generateIntMetric(5), containerLabels, "memory/bytes_used", "kubernetes.io/container/memory/used_bytes") - containerMemoryRequest := testTranslateMetric(as, generateIntMetric(6), containerLabels, "memory/request", "kubernetes.io/container/memory/requested_bytes") + containerMemoryRequest := testTranslateMetric(as, generateIntMetric(6), containerLabels, "memory/request", "kubernetes.io/container/memory/request_bytes") containerMemoryLimit := testTranslateMetric(as, generateIntMetric(7), containerLabels, "memory/limit", "kubernetes.io/container/memory/limit_bytes") containerRestartCount := testTranslateMetric(as, generateIntMetric(8), containerLabels, "restart_count", "kubernetes.io/container/restart_count") - podNetworkBytesRx := testTranslateMetric(as, generateIntMetric(9), podLabels, "network/rx", "kubernetes.io/pod/network/bytes_rx") - podNetworkBytesTx := testTranslateMetric(as, generateIntMetric(10), podLabels, "network/tx", "kubernetes.io/pod/network/bytes_tx") - podVolumeTotal := testTranslateLabeledMetric(as, podLabels, generateLabeledIntMetric(11, map[string]string{}, "volume/total_bytes"), "kubernetes.io/pod/volume/requested_bytes") - podVolumeUsed := testTranslateLabeledMetric(as, podLabels, generateLabeledIntMetric(12, map[string]string{}, "volume/used_bytes"), "kubernetes.io/pod/volume/used_bytes") + podNetworkBytesRx := testTranslateMetric(as, generateIntMetric(9), podLabels, "network/rx", "kubernetes.io/pod/network/received_bytes_count") + podNetworkBytesTx := testTranslateMetric(as, generateIntMetric(10), podLabels, "network/tx", "kubernetes.io/pod/network/sent_bytes_count") + 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") 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") - nodeNetworkBytesRx := testTranslateMetric(as, generateIntMetric(19), nodeLabels, "network/rx", "kubernetes.io/node/network/bytes_rx") - nodeNetworkBytesTx := testTranslateMetric(as, generateIntMetric(20), nodeLabels, "network/tx", "kubernetes.io/node/network/bytes_tx") + nodeNetworkBytesRx := testTranslateMetric(as, generateIntMetric(19), nodeLabels, "network/rx", "kubernetes.io/node/network/received_bytes_count") + nodeNetworkBytesTx := testTranslateMetric(as, generateIntMetric(20), nodeLabels, "network/tx", "kubernetes.io/node/network/sent_bytes_count") nodeDaemonCpuUsage := testTranslateMetric(as, generateIntMetric(21000000000), nodeDaemonLabels, "cpu/usage", "kubernetes.io/node_daemon/cpu/core_usage_time") nodeDaemonMemoryUsage := testTranslateMetric(as, generateIntMetric(22), nodeDaemonLabels, "memory/bytes_used", "kubernetes.io/node_daemon/memory/used_bytes")