@@ -32,6 +32,7 @@ import (
3232 sd_api "google.golang.org/api/monitoring/v3"
3333 gce_util "k8s.io/heapster/common/gce"
3434 "k8s.io/heapster/metrics/core"
35+ "strings"
3536)
3637
3738const (
@@ -310,7 +311,6 @@ func (sink *StackdriverSink) sendOneRequest(req *sd_api.CreateTimeSeriesRequest)
310311 WithLabelValues (strconv .Itoa (responseCode )).
311312 Add (float64 (len (req .TimeSeries )))
312313 requestLatency .Observe (time .Since (startTime ).Seconds () / time .Millisecond .Seconds ())
313-
314314}
315315
316316func CreateStackdriverSink (uri * url.URL ) (core.DataSink , error ) {
@@ -531,18 +531,18 @@ func (sink *StackdriverSink) TranslateLabeledMetric(timestamp time.Time, labels
531531 case core .MetricSetTypePod :
532532 podLabels := sink .getPodResourceLabels (labels )
533533 switch metric .Name {
534- case core .MetricVolumeUsage .MetricDescriptor .Name :
534+ case core .MetricFilesystemUsage .MetricDescriptor .Name :
535535 point := sink .intPoint (timestamp , timestamp , metric .MetricValue .IntValue )
536536 ts := createTimeSeries ("k8s_pod" , podLabels , volumeUsedBytesMD , point )
537537 ts .Metric .Labels = map [string ]string {
538- "name" : metric .Labels [core .LabelResourceID .Key ],
538+ core . LabelVolumeName . Key : strings . TrimPrefix ( metric .Labels [core .LabelResourceID .Key ], "Volume:" ) ,
539539 }
540540 return ts
541- case core .MetricVolumeTotal .MetricDescriptor .Name :
541+ case core .MetricFilesystemLimit .MetricDescriptor .Name :
542542 point := sink .intPoint (timestamp , timestamp , metric .MetricValue .IntValue )
543- ts := createTimeSeries ("k8s_pod" , podLabels , volumeRequestedBytesMD , point )
543+ ts := createTimeSeries ("k8s_pod" , podLabels , volumeTotalBytesMD , point )
544544 ts .Metric .Labels = map [string ]string {
545- "name" : metric .Labels [core .LabelResourceID .Key ],
545+ core . LabelVolumeName . Key : strings . TrimPrefix ( metric .Labels [core .LabelResourceID .Key ], "Volume:" ) ,
546546 }
547547 return ts
548548 }
@@ -601,10 +601,10 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str
601601 switch name {
602602 case core .MetricNetworkRx .MetricDescriptor .Name :
603603 point := sink .intPoint (timestamp , createTime , value .IntValue )
604- return createTimeSeries ("k8s_pod" , podLabels , networkPodRxMD , point )
604+ return createTimeSeries ("k8s_pod" , podLabels , networkPodReceivedBytesMD , point )
605605 case core .MetricNetworkTx .MetricDescriptor .Name :
606606 point := sink .intPoint (timestamp , createTime , value .IntValue )
607- return createTimeSeries ("k8s_pod" , podLabels , networkPodTxMD , point )
607+ return createTimeSeries ("k8s_pod" , podLabels , networkPodSentBytesMD , point )
608608 }
609609 case core .MetricSetTypeNode :
610610 nodeLabels := sink .getNodeResourceLabels (labels )
@@ -640,10 +640,10 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str
640640 return ts
641641 case core .MetricNetworkRx .MetricDescriptor .Name :
642642 point := sink .intPoint (timestamp , createTime , value .IntValue )
643- return createTimeSeries ("k8s_node" , nodeLabels , networkNodeRxMD , point )
643+ return createTimeSeries ("k8s_node" , nodeLabels , networkNodeReceivedBytesMD , point )
644644 case core .MetricNetworkTx .MetricDescriptor .Name :
645645 point := sink .intPoint (timestamp , createTime , value .IntValue )
646- return createTimeSeries ("k8s_node" , nodeLabels , networkNodeTxMD , point )
646+ return createTimeSeries ("k8s_node" , nodeLabels , networkNodeSentBytesMD , point )
647647 }
648648 case core .MetricSetTypeSystemContainer :
649649 nodeLabels := sink .getNodeResourceLabels (labels )
@@ -652,19 +652,25 @@ func (sink *StackdriverSink) TranslateMetric(timestamp time.Time, labels map[str
652652 point := sink .intPoint (timestamp , timestamp , value .IntValue )
653653 ts := createTimeSeries ("k8s_node" , nodeLabels , memoryNodeDaemonUsedBytesMD , point )
654654 ts .Metric .Labels = map [string ]string {
655+ "component" : labels [core .LabelContainerName .Key ],
655656 "memory_type" : "evictable" ,
656657 }
657658 return ts
658659 case core .MetricMemoryWorkingSet .MetricDescriptor .Name :
659660 point := sink .intPoint (timestamp , timestamp , value .IntValue )
660661 ts := createTimeSeries ("k8s_node" , nodeLabels , memoryNodeDaemonUsedBytesMD , point )
661662 ts .Metric .Labels = map [string ]string {
663+ "component" : labels [core .LabelContainerName .Key ],
662664 "memory_type" : "non-evictable" ,
663665 }
664666 return ts
665667 case core .MetricCpuUsage .MetricDescriptor .Name :
666668 point := sink .doublePoint (timestamp , createTime , float64 (value .IntValue )/ float64 (time .Second / time .Nanosecond ))
667- return createTimeSeries ("k8s_node" , nodeLabels , cpuNodeDaemonCoreUsageTimeMD , point )
669+ ts := createTimeSeries ("k8s_node" , nodeLabels , cpuNodeDaemonCoreUsageTimeMD , point )
670+ ts .Metric .Labels = map [string ]string {
671+ "component" : labels [core .LabelContainerName .Key ],
672+ }
673+ return ts
668674 }
669675 }
670676 return nil
0 commit comments