How I get the number of (currently) established TCP connections in prometheus (kubernetes monitoring)

8/16/2021

I am using this command in linux to see (currently) established TCP connections:

netstat -ant | grep ESTABLISHED | wc -l 

How can i translate this command to PromQL (per node) ?

I am using prometheus with node exporter in my kubernetes cluster

-- karlos
kubernetes
prometheus
prometheus-node-exporter

1 Answer

8/16/2021

To get number of currently open TCP connections, you can use node_netstat_Tcp_CurrEstab (Gauge) metric.

you can also use node_netstat_Tcp_ActiveOpens (Counter) metrics with appropriate rate such as

rate(node_netstat_Tcp_ActiveOpens[10m])

These metrics are based on TCP-MIB (RFC-4022) and they are obtained by parsing /proc/net/netstat and /proc/net/tcp files on every node running exporter.

-- rkosegi
Source: StackOverflow