Skip to content

Commit

Permalink
add node ping total count metric
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Nov 23, 2020
1 parent e3190c7 commit ef41733
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
10 changes: 6 additions & 4 deletions docs/ovn-ovs-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ OVS_Monitor | | ovsdb/vswitchd metrics
14 | pinger_external_dns_latency_ms | The latency ms histogram the node request external dns
15 | pinger_pod_ping_latency_ms | The latency ms histogram for pod peer ping
16 | pinger_pod_ping_lost_total | The lost count for pod peer ping
17 | pinger_node_ping_latency_ms | The latency ms histogram for pod ping node
18 | pinger_node_ping_lost_total | The lost count for pod ping node
19 | pinger_external_ping_latency_ms | The latency ms histogram for pod ping external address
20 | pinger_node_external_lost_total | The lost count for pod ping external address
17 | pinger_pod_ping_count_total | The total count for pod peer ping
18 | pinger_node_ping_latency_ms | The latency ms histogram for pod ping node
19 | pinger_node_ping_lost_total | The lost count for pod ping node
20 | pinger_node_ping_count_total | The total count for pod ping node
21 | pinger_external_ping_latency_ms | The latency ms histogram for pod ping external address
22 | pinger_node_external_lost_total | The lost count for pod ping external address
Kube-OVN-Controller | | Controller metrics
1 | rest_client_request_latency_seconds | Request latency in seconds. Broken down by verb and URL
2 | rest_client_requests_total | Number of HTTP requests, partitioned by status code, method, and host
Expand Down
44 changes: 42 additions & 2 deletions pkg/pinger/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ var (
"target_node_ip",
"target_pod_ip",
})
podPingTotalCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "pinger_pod_ping_count_total",
Help: "The total count for pod peer ping",
}, []string{
"src_node_name",
"src_node_ip",
"src_pod_ip",
"target_node_name",
"target_node_ip",
"target_pod_ip",
})
nodePingLatencyHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "pinger_node_ping_latency_ms",
Expand All @@ -168,6 +180,17 @@ var (
"target_node_name",
"target_node_ip",
})
nodePingTotalCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "pinger_node_ping_count_total",
Help: "The total count for pod ping node",
}, []string{
"src_node_name",
"src_node_ip",
"src_pod_ip",
"target_node_name",
"target_node_ip",
})
externalPingLatencyHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "pinger_external_ping_latency_ms",
Expand Down Expand Up @@ -617,8 +640,10 @@ func init() {
prometheus.MustRegister(externalDnsRequestLatencyHistogram)
prometheus.MustRegister(podPingLatencyHistogram)
prometheus.MustRegister(podPingLostCounter)
prometheus.MustRegister(podPingTotalCounter)
prometheus.MustRegister(nodePingLatencyHistogram)
prometheus.MustRegister(nodePingLostCounter)
prometheus.MustRegister(nodePingTotalCounter)
prometheus.MustRegister(externalPingLatencyHistogram)
prometheus.MustRegister(externalPingLostCounter)

Expand Down Expand Up @@ -720,7 +745,7 @@ func SetExternalDnsUnhealthyMetrics(nodeName string) {
externalDnsUnhealthyGauge.WithLabelValues(nodeName).Set(1)
}

func SetPodPingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, targetNodeIP, targetPodIP string, latency float64, lost int) {
func SetPodPingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, targetNodeIP, targetPodIP string, latency float64, lost, total int) {
podPingLatencyHistogram.WithLabelValues(
srcNodeName,
srcNodeIP,
Expand All @@ -737,9 +762,17 @@ func SetPodPingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, targetN
targetNodeIP,
targetPodIP,
).Add(float64(lost))
podPingTotalCounter.WithLabelValues(
srcNodeName,
srcNodeIP,
srcPodIP,
targetNodeName,
targetNodeIP,
targetPodIP,
).Add(float64(total))
}

func SetNodePingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, targetNodeIP string, latency float64, lost int) {
func SetNodePingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, targetNodeIP string, latency float64, lost, total int) {
nodePingLatencyHistogram.WithLabelValues(
srcNodeName,
srcNodeIP,
Expand All @@ -754,6 +787,13 @@ func SetNodePingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetNodeName, target
targetNodeName,
targetNodeIP,
).Add(float64(lost))
nodePingTotalCounter.WithLabelValues(
srcNodeName,
srcNodeIP,
srcPodIP,
targetNodeName,
targetNodeIP,
).Add(float64(total))
}

func SetExternalPingMetrics(srcNodeName, srcNodeIP, srcPodIP, targetAddress string, latency float64, lost int) {
Expand Down
6 changes: 4 additions & 2 deletions pkg/pinger/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func pingNodes(config *Configuration) error {
config.PodName,
no.Name, addr.Address,
float64(stats.AvgRtt)/float64(time.Millisecond),
int(math.Abs(float64(stats.PacketsSent-stats.PacketsRecv))))
int(math.Abs(float64(stats.PacketsSent-stats.PacketsRecv))),
int(float64(stats.PacketsSent)))
}(addr.Address, no.Name)
}
}
Expand Down Expand Up @@ -154,7 +155,8 @@ func pingPods(config *Configuration) error {
nodeIP,
podIp,
float64(stats.AvgRtt)/float64(time.Millisecond),
int(math.Abs(float64(stats.PacketsSent-stats.PacketsRecv))))
int(math.Abs(float64(stats.PacketsSent-stats.PacketsRecv))),
int(float64(stats.PacketsSent)))
}(pod.Status.PodIP, pod.Name, pod.Status.HostIP, pod.Spec.NodeName)
}
}
Expand Down

0 comments on commit ef41733

Please sign in to comment.