From f728224ef276c69e67c581951b28f77a7ca1c9f3 Mon Sep 17 00:00:00 2001 From: szediktam Date: Wed, 16 Feb 2022 21:03:20 +0800 Subject: [PATCH] feat: add storage metrics for container collector Signed-off-by: szediktam --- collector/container.go | 55 +++++++++++++++++++++++++++++++++++++ docs/collector.container.md | 4 +++ 2 files changed, 59 insertions(+) diff --git a/collector/container.go b/collector/container.go index 7f42ed9b..332f6c16 100644 --- a/collector/container.go +++ b/collector/container.go @@ -37,6 +37,12 @@ type ContainerMetricsCollector struct { PacketsSent *prometheus.Desc DroppedPacketsIncoming *prometheus.Desc DroppedPacketsOutgoing *prometheus.Desc + + // Storage + ReadCountNormalized *prometheus.Desc + ReadSizeBytes *prometheus.Desc + WriteCountNormalized *prometheus.Desc + WriteSizeBytes *prometheus.Desc } // NewContainerMetricsCollector constructs a new ContainerMetricsCollector @@ -127,6 +133,30 @@ func NewContainerMetricsCollector() (Collector, error) { []string{"container_id", "interface"}, nil, ), + ReadCountNormalized: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "storage_read_count_normalized_total"), + "Read Count Normalized", + []string{"container_id"}, + nil, + ), + ReadSizeBytes: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "storage_read_size_bytes_total"), + "Read Size Bytes", + []string{"container_id"}, + nil, + ), + WriteCountNormalized: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "storage_write_count_normalized_total"), + "Write Count Normalized", + []string{"container_id"}, + nil, + ), + WriteSizeBytes: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "storage_write_size_bytes_total"), + "Write Size Bytes", + []string{"container_id"}, + nil, + ), }, nil } @@ -274,6 +304,31 @@ func (c *ContainerMetricsCollector) collect(ch chan<- prometheus.Metric) (*prome ) break } + + ch <- prometheus.MustNewConstMetric( + c.ReadCountNormalized, + prometheus.CounterValue, + float64(cstats.Storage.ReadCountNormalized), + containerIdWithPrefix, + ) + ch <- prometheus.MustNewConstMetric( + c.ReadSizeBytes, + prometheus.CounterValue, + float64(cstats.Storage.ReadSizeBytes), + containerIdWithPrefix, + ) + ch <- prometheus.MustNewConstMetric( + c.WriteCountNormalized, + prometheus.CounterValue, + float64(cstats.Storage.WriteCountNormalized), + containerIdWithPrefix, + ) + ch <- prometheus.MustNewConstMetric( + c.WriteSizeBytes, + prometheus.CounterValue, + float64(cstats.Storage.WriteSizeBytes), + containerIdWithPrefix, + ) } return nil, nil diff --git a/docs/collector.container.md b/docs/collector.container.md index bbb95170..f109c9f6 100644 --- a/docs/collector.container.md +++ b/docs/collector.container.md @@ -30,6 +30,10 @@ Name | Description | Type | Labels `windows_container_network_transmit_bytes_total` | Bytes Sent on Interface | counter | `container_id`, `interface` `windows_container_network_transmit_packets_total` | Packets Sent on Interface | counter | `container_id`, `interface` `windows_container_network_transmit_packets_dropped_total` | Dropped Outgoing Packets on Interface | counter | `container_id`, `interface` +`windows_container_storage_read_count_normalized_total"` | Read Count Normalized | counter | `container_id` +`windows_container_storage_read_size_bytes_total"` | Read Size Bytes | counter | `container_id` +`windows_container_storage_write_count_normalized_total"` | Write Count Normalized | counter | `container_id` +`windows_container_storage_write_size_bytes_total"` | Write Size Bytes | counter | `container_id` ### Example metric _windows_container_network_receive_bytes_total{container_id="docker://1bd30e8b8ac28cbd76a9b697b4d7bb9d760267b0733d1bc55c60024e98d1e43e",interface="822179E7-002C-4280-ABBA-28BCFE401826"} 9.3305343e+07_