Skip to content

Commit 44e6d1a

Browse files
committed
TUN-8441: Correct UDP total sessions metric to a counter and add new ICMP metrics
cloudflared_udp_total_sessions was incorrectly a gauge when it represents the total since the cloudflared process started and will only ever increase. Additionally adds new ICMP metrics for requests and replies.
1 parent 30197e7 commit 44e6d1a

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

datagramsession/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var (
1515
Name: "active_sessions",
1616
Help: "Concurrent count of UDP sessions that are being proxied to any origin",
1717
})
18-
totalUDPSessions = prometheus.NewGauge(prometheus.GaugeOpts{
18+
totalUDPSessions = prometheus.NewCounter(prometheus.CounterOpts{
1919
Namespace: namespace,
2020
Subsystem: "udp",
2121
Name: "total_sessions",

ingress/icmp_metrics.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package ingress
2+
3+
import (
4+
"github.com/prometheus/client_golang/prometheus"
5+
)
6+
7+
const (
8+
namespace = "cloudflared"
9+
)
10+
11+
var (
12+
icmpRequests = prometheus.NewCounter(prometheus.CounterOpts{
13+
Namespace: namespace,
14+
Subsystem: "icmp",
15+
Name: "total_requests",
16+
Help: "Total count of ICMP requests that have been proxied to any origin",
17+
})
18+
icmpReplies = prometheus.NewCounter(prometheus.CounterOpts{
19+
Namespace: namespace,
20+
Subsystem: "icmp",
21+
Name: "total_replies",
22+
Help: "Total count of ICMP replies that have been proxied from any origin",
23+
})
24+
)
25+
26+
func init() {
27+
prometheus.MustRegister(
28+
icmpRequests,
29+
icmpReplies,
30+
)
31+
}
32+
33+
func incrementICMPRequest() {
34+
icmpRequests.Inc()
35+
}
36+
37+
func incrementICMPReply() {
38+
icmpReplies.Inc()
39+
}

ingress/origin_icmp_proxy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func isEchoReply(msg *icmp.Message) bool {
105105
}
106106

107107
func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst string, echoID int, seq int) {
108+
incrementICMPRequest()
108109
logger.Debug().
109110
Str("src", src).
110111
Str("dst", dst).
@@ -118,6 +119,7 @@ func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst
118119
}
119120

120121
func observeICMPReply(logger *zerolog.Logger, span trace.Span, dst string, echoID int, seq int) {
122+
incrementICMPReply()
121123
logger.Debug().Str("dst", dst).Int("echoID", echoID).Int("seq", seq).Msg("Sent ICMP reply to edge")
122124
span.SetAttributes(
123125
attribute.String("dst", dst),

0 commit comments

Comments
 (0)