@@ -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 }
@@ -194,11 +194,11 @@ func (this *summaryMetricsSource) decodePodStats(metrics map[string]*MetricSet,
194194
195195 for _ , container := range pod .Containers {
196196 key := PodContainerKey (ref .Namespace , ref .Name , container .Name )
197- metrics [key ] = this .decodeContainerStats (podMetrics .Labels , & container )
197+ metrics [key ] = this .decodeContainerStats (podMetrics .Labels , & container , false )
198198 }
199199}
200200
201- func (this * summaryMetricsSource ) decodeContainerStats (podLabels map [string ]string , container * stats.ContainerStats ) * MetricSet {
201+ func (this * summaryMetricsSource ) decodeContainerStats (podLabels map [string ]string , container * stats.ContainerStats , isSystemContainer bool ) * MetricSet {
202202 glog .V (9 ).Infof ("Decoding container stats stats for container %s..." , container .Name )
203203 containerMetrics := & MetricSet {
204204 Labels : this .cloneLabels (podLabels ),
@@ -208,7 +208,11 @@ func (this *summaryMetricsSource) decodeContainerStats(podLabels map[string]stri
208208 ScrapeTime : this .getScrapeTime (container .CPU , container .Memory , nil ),
209209 }
210210 containerMetrics .Labels [LabelMetricSetType .Key ] = MetricSetTypePodContainer
211- containerMetrics .Labels [LabelContainerName .Key ] = this .getContainerName (container )
211+ if isSystemContainer {
212+ containerMetrics .Labels [LabelContainerName .Key ] = this .getSystemContainerName (container )
213+ } else {
214+ containerMetrics .Labels [LabelContainerName .Key ] = container .Name
215+ }
212216
213217 this .decodeUptime (containerMetrics , container .StartTime .Time )
214218 this .decodeCPUStats (containerMetrics , container .CPU )
@@ -346,7 +350,7 @@ func (this *summaryMetricsSource) addLabeledIntMetric(metrics *MetricSet, metric
346350}
347351
348352// Translate system container names to the legacy names for backwards compatibility.
349- func (this * summaryMetricsSource ) getContainerName (c * stats.ContainerStats ) string {
353+ func (this * summaryMetricsSource ) getSystemContainerName (c * stats.ContainerStats ) string {
350354 if legacyName , ok := systemNameMap [c .Name ]; ok {
351355 return legacyName
352356 }
0 commit comments