@@ -163,8 +163,8 @@ func (this *summaryMetricsSource) decodeNodeStats(metrics map[string]*MetricSet,
163163 metrics [NodeKey (node .NodeName )] = nodeMetrics
164164
165165 for _ , container := range node .SystemContainers {
166- key := NodeContainerKey (node .NodeName , this .getContainerName (& container ))
167- containerMetrics := this .decodeContainerStats (labels , & container )
166+ key := NodeContainerKey (node .NodeName , this .getSystemContainerName (& container ))
167+ containerMetrics := this .decodeContainerStats (labels , & container , true )
168168 containerMetrics .Labels [LabelMetricSetType .Key ] = MetricSetTypeSystemContainer
169169 metrics [key ] = containerMetrics
170170 }
@@ -196,11 +196,11 @@ func (this *summaryMetricsSource) decodePodStats(metrics map[string]*MetricSet,
196196
197197 for _ , container := range pod .Containers {
198198 key := PodContainerKey (ref .Namespace , ref .Name , container .Name )
199- metrics [key ] = this .decodeContainerStats (podMetrics .Labels , & container )
199+ metrics [key ] = this .decodeContainerStats (podMetrics .Labels , & container , false )
200200 }
201201}
202202
203- func (this * summaryMetricsSource ) decodeContainerStats (podLabels map [string ]string , container * stats.ContainerStats ) * MetricSet {
203+ func (this * summaryMetricsSource ) decodeContainerStats (podLabels map [string ]string , container * stats.ContainerStats , isSystemContainer bool ) * MetricSet {
204204 glog .V (9 ).Infof ("Decoding container stats stats for container %s..." , container .Name )
205205 containerMetrics := & MetricSet {
206206 Labels : this .cloneLabels (podLabels ),
@@ -210,7 +210,11 @@ func (this *summaryMetricsSource) decodeContainerStats(podLabels map[string]stri
210210 ScrapeTime : this .getScrapeTime (container .CPU , container .Memory , nil ),
211211 }
212212 containerMetrics .Labels [LabelMetricSetType .Key ] = MetricSetTypePodContainer
213- containerMetrics .Labels [LabelContainerName .Key ] = this .getContainerName (container )
213+ if isSystemContainer {
214+ containerMetrics .Labels [LabelContainerName .Key ] = this .getSystemContainerName (container )
215+ } else {
216+ containerMetrics .Labels [LabelContainerName .Key ] = container .Name
217+ }
214218
215219 this .decodeUptime (containerMetrics , container .StartTime .Time )
216220 this .decodeCPUStats (containerMetrics , container .CPU )
@@ -348,7 +352,7 @@ func (this *summaryMetricsSource) addLabeledIntMetric(metrics *MetricSet, metric
348352}
349353
350354// Translate system container names to the legacy names for backwards compatibility.
351- func (this * summaryMetricsSource ) getContainerName (c * stats.ContainerStats ) string {
355+ func (this * summaryMetricsSource ) getSystemContainerName (c * stats.ContainerStats ) string {
352356 if legacyName , ok := systemNameMap [c .Name ]; ok {
353357 return legacyName
354358 }
0 commit comments