Merge pull request #371 from martinlindhe/revert-364-master

Revert "Add container_name label to container collector"
This commit is contained in:
Calle Pettersson
2019-08-03 11:13:15 +02:00
committed by GitHub

View File

@@ -45,7 +45,7 @@ func NewContainerMetricsCollector() (Collector, error) {
ContainerAvailable: prometheus.NewDesc( ContainerAvailable: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "available"), prometheus.BuildFQName(Namespace, subsystem, "available"),
"Available", "Available",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
ContainersCount: prometheus.NewDesc( ContainersCount: prometheus.NewDesc(
@@ -57,73 +57,73 @@ func NewContainerMetricsCollector() (Collector, error) {
UsageCommitBytes: prometheus.NewDesc( UsageCommitBytes: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "memory_usage_commit_bytes"), prometheus.BuildFQName(Namespace, subsystem, "memory_usage_commit_bytes"),
"Memory Usage Commit Bytes", "Memory Usage Commit Bytes",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
UsageCommitPeakBytes: prometheus.NewDesc( UsageCommitPeakBytes: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "memory_usage_commit_peak_bytes"), prometheus.BuildFQName(Namespace, subsystem, "memory_usage_commit_peak_bytes"),
"Memory Usage Commit Peak Bytes", "Memory Usage Commit Peak Bytes",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
UsagePrivateWorkingSetBytes: prometheus.NewDesc( UsagePrivateWorkingSetBytes: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "memory_usage_private_working_set_bytes"), prometheus.BuildFQName(Namespace, subsystem, "memory_usage_private_working_set_bytes"),
"Memory Usage Private Working Set Bytes", "Memory Usage Private Working Set Bytes",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
RuntimeTotal: prometheus.NewDesc( RuntimeTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_total"), prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_total"),
"Total Run time in Seconds", "Total Run time in Seconds",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
RuntimeUser: prometheus.NewDesc( RuntimeUser: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_usermode"), prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_usermode"),
"Run Time in User mode in Seconds", "Run Time in User mode in Seconds",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
RuntimeKernel: prometheus.NewDesc( RuntimeKernel: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_kernelmode"), prometheus.BuildFQName(Namespace, subsystem, "cpu_usage_seconds_kernelmode"),
"Run time in Kernel mode in Seconds", "Run time in Kernel mode in Seconds",
[]string{"container_id", "container_name"}, []string{"container_id"},
nil, nil,
), ),
BytesReceived: prometheus.NewDesc( BytesReceived: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_receive_bytes_total"), prometheus.BuildFQName(Namespace, subsystem, "network_receive_bytes_total"),
"Bytes Received on Interface", "Bytes Received on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
BytesSent: prometheus.NewDesc( BytesSent: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_transmit_bytes_total"), prometheus.BuildFQName(Namespace, subsystem, "network_transmit_bytes_total"),
"Bytes Sent on Interface", "Bytes Sent on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
PacketsReceived: prometheus.NewDesc( PacketsReceived: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_receive_packets_total"), prometheus.BuildFQName(Namespace, subsystem, "network_receive_packets_total"),
"Packets Received on Interface", "Packets Received on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
PacketsSent: prometheus.NewDesc( PacketsSent: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_transmit_packets_total"), prometheus.BuildFQName(Namespace, subsystem, "network_transmit_packets_total"),
"Packets Sent on Interface", "Packets Sent on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
DroppedPacketsIncoming: prometheus.NewDesc( DroppedPacketsIncoming: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_receive_packets_dropped_total"), prometheus.BuildFQName(Namespace, subsystem, "network_receive_packets_dropped_total"),
"Dropped Incoming Packets on Interface", "Dropped Incoming Packets on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
DroppedPacketsOutgoing: prometheus.NewDesc( DroppedPacketsOutgoing: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "network_transmit_packets_dropped_total"), prometheus.BuildFQName(Namespace, subsystem, "network_transmit_packets_dropped_total"),
"Dropped Outgoing Packets on Interface", "Dropped Outgoing Packets on Interface",
[]string{"container_id", "container_name", "interface"}, []string{"container_id", "interface"},
nil, nil,
), ),
}, nil }, nil
@@ -169,7 +169,6 @@ func (c *ContainerMetricsCollector) collect(ch chan<- prometheus.Metric) (*prome
for _, containerDetails := range containers { for _, containerDetails := range containers {
containerId := containerDetails.ID containerId := containerDetails.ID
containerName := containerDetails.Name
container, err := hcsshim.OpenContainer(containerId) container, err := hcsshim.OpenContainer(containerId)
if container != nil { if container != nil {
@@ -192,43 +191,43 @@ func (c *ContainerMetricsCollector) collect(ch chan<- prometheus.Metric) (*prome
c.ContainerAvailable, c.ContainerAvailable,
prometheus.CounterValue, prometheus.CounterValue,
1, 1,
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.UsageCommitBytes, c.UsageCommitBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(cstats.Memory.UsageCommitBytes), float64(cstats.Memory.UsageCommitBytes),
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.UsageCommitPeakBytes, c.UsageCommitPeakBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(cstats.Memory.UsageCommitPeakBytes), float64(cstats.Memory.UsageCommitPeakBytes),
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.UsagePrivateWorkingSetBytes, c.UsagePrivateWorkingSetBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(cstats.Memory.UsagePrivateWorkingSetBytes), float64(cstats.Memory.UsagePrivateWorkingSetBytes),
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.RuntimeTotal, c.RuntimeTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(cstats.Processor.TotalRuntime100ns)*ticksToSecondsScaleFactor, float64(cstats.Processor.TotalRuntime100ns)*ticksToSecondsScaleFactor,
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.RuntimeUser, c.RuntimeUser,
prometheus.CounterValue, prometheus.CounterValue,
float64(cstats.Processor.RuntimeUser100ns)*ticksToSecondsScaleFactor, float64(cstats.Processor.RuntimeUser100ns)*ticksToSecondsScaleFactor,
containerId, containerName, containerId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.RuntimeKernel, c.RuntimeKernel,
prometheus.CounterValue, prometheus.CounterValue,
float64(cstats.Processor.RuntimeKernel100ns)*ticksToSecondsScaleFactor, float64(cstats.Processor.RuntimeKernel100ns)*ticksToSecondsScaleFactor,
containerId, containerName, containerId,
) )
if len(cstats.Network) == 0 { if len(cstats.Network) == 0 {
@@ -243,37 +242,37 @@ func (c *ContainerMetricsCollector) collect(ch chan<- prometheus.Metric) (*prome
c.BytesReceived, c.BytesReceived,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.BytesReceived), float64(networkInterface.BytesReceived),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.BytesSent, c.BytesSent,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.BytesSent), float64(networkInterface.BytesSent),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsReceived, c.PacketsReceived,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.PacketsReceived), float64(networkInterface.PacketsReceived),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsSent, c.PacketsSent,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.PacketsSent), float64(networkInterface.PacketsSent),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.DroppedPacketsIncoming, c.DroppedPacketsIncoming,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.DroppedPacketsIncoming), float64(networkInterface.DroppedPacketsIncoming),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.DroppedPacketsOutgoing, c.DroppedPacketsOutgoing,
prometheus.CounterValue, prometheus.CounterValue,
float64(networkInterface.DroppedPacketsOutgoing), float64(networkInterface.DroppedPacketsOutgoing),
containerId, containerName, networkInterface.EndpointId, containerId, networkInterface.EndpointId,
) )
break break
} }