-
Feature Request
-
Resolution: Unresolved
-
Normal
-
None
-
None
-
None
-
False
-
None
-
False
-
Not Selected
-
-
-
Proposed title of this feature request
Add metrics in Prometheus about the TCP sockets inside the pod, including ESTABLISHED, TIME_WAIT, CLOSE_WAIT, etc.
Description:
currently CRI-O doesn't provided the tcp stats information in the pod look like ESTABLISHED, TIME_WAIT, CLOSE_WAIT, etc.
https://github.com/cri-o/cri-o/blob/main/internal/lib/stats/network_metrics.go
Just 'ESTABLISHED' info could checked by using 'container_sockets'
https://github.com/cri-o/cri-o/blob/main/internal/lib/stats/metrics.go#L314-L318
cadvisor could provide some network metrics but CRI-O doesn't include them.
https://github.com/openshift/google-cadvisor/blob/master/docs/storage/prometheus.md
container_network_advance_tcp_stats_total Gauge advanced tcp connections statistic for container
container_network_tcp6_usage_total Gauge tcp6 connection usage statistic for container tcp
container_network_tcp_usage_total Gauge tcp connection usage statistic for container tcp
Additional Information:
These two container_network_tcp_usage_total & container_network_tcp6_usage_total metrics have tcp stats could check ESTABLISHED, TIME_WAIT, CLOSE_WAIT, etc.
if includedMetrics.Has(container.NetworkTcpUsageMetrics) { c.containerMetrics = append(c.containerMetrics, []containerMetric{ { name: "container_network_tcp_usage_total", help: "tcp connection usage statistic for container", valueType: prometheus.GaugeValue, extraLabels: []string{"tcp_state"}, getValues: func(s *info.ContainerStats) metricValues { return metricValues{ { value: float64(s.Network.Tcp.Established), labels: []string{"established"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.SynSent), labels: []string{"synsent"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.SynRecv), labels: []string{"synrecv"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.FinWait1), labels: []string{"finwait1"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.FinWait2), labels: []string{"finwait2"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.TimeWait), labels: []string{"timewait"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.Close), labels: []string{"close"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.CloseWait), labels: []string{"closewait"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.LastAck), labels: []string{"lastack"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.Listen), labels: []string{"listen"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp.Closing), labels: []string{"closing"}, timestamp: s.Timestamp, }, } }, }, }...) c.containerMetrics = append(c.containerMetrics, []containerMetric{ { name: "container_network_tcp6_usage_total", help: "tcp6 connection usage statistic for container", valueType: prometheus.GaugeValue, extraLabels: []string{"tcp_state"}, getValues: func(s *info.ContainerStats) metricValues { return metricValues{ { value: float64(s.Network.Tcp6.Established), labels: []string{"established"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.SynSent), labels: []string{"synsent"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.SynRecv), labels: []string{"synrecv"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.FinWait1), labels: []string{"finwait1"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.FinWait2), labels: []string{"finwait2"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.TimeWait), labels: []string{"timewait"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.Close), labels: []string{"close"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.CloseWait), labels: []string{"closewait"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.LastAck), labels: []string{"lastack"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.Listen), labels: []string{"listen"}, timestamp: s.Timestamp, }, { value: float64(s.Network.Tcp6.Closing), labels: []string{"closing"}, timestamp: s.Timestamp, }, } }, }, }...) }