in pkg/metrics/collector/netlink_metrics.go [358:387]
func (c *netlinkCollector) Update(ch chan<- prometheus.Metric) error {
if enablePodWatch && firstRun {
if err := createPodWatch(); err != nil {
glog.Infof("Error, pod watch not running with err, %q", err)
}
firstRun = false
}
snapshots, err := getRequests()
if err != nil {
return fmt.Errorf("could not get tcp requests: %q", err)
}
retransmits := getRetransmits(snapshots)
ch <- prometheus.MustNewConstMetric(NodeTCPConnectionsDesc, prometheus.GaugeValue, float64(len(snapshots)))
ch <- prometheus.MustNewConstMetric(NodeActiveTCPRetransmits, prometheus.GaugeValue, float64(retransmits))
if !enablePodWatch {
return nil
}
statMap := createStatMap(snapshots)
for pod, stats := range statMap {
ch <- prometheus.MustNewConstMetric(TCPConnectionsDesc, prometheus.GaugeValue,
float64(stats.tcpConnections), pod.ObjectMeta.Name, pod.ObjectMeta.Namespace)
ch <- prometheus.MustNewConstMetric(ActiveTCPRetransmits, prometheus.GaugeValue,
float64(stats.retransmits), pod.ObjectMeta.Name, pod.ObjectMeta.Namespace)
}
return nil
}