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.
This commit is contained in:
parent
30197e7dfa
commit
44e6d1a313
|
@ -15,7 +15,7 @@ var (
|
||||||
Name: "active_sessions",
|
Name: "active_sessions",
|
||||||
Help: "Concurrent count of UDP sessions that are being proxied to any origin",
|
Help: "Concurrent count of UDP sessions that are being proxied to any origin",
|
||||||
})
|
})
|
||||||
totalUDPSessions = prometheus.NewGauge(prometheus.GaugeOpts{
|
totalUDPSessions = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: "udp",
|
Subsystem: "udp",
|
||||||
Name: "total_sessions",
|
Name: "total_sessions",
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package ingress
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
namespace = "cloudflared"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
icmpRequests = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: "icmp",
|
||||||
|
Name: "total_requests",
|
||||||
|
Help: "Total count of ICMP requests that have been proxied to any origin",
|
||||||
|
})
|
||||||
|
icmpReplies = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: "icmp",
|
||||||
|
Name: "total_replies",
|
||||||
|
Help: "Total count of ICMP replies that have been proxied from any origin",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
prometheus.MustRegister(
|
||||||
|
icmpRequests,
|
||||||
|
icmpReplies,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func incrementICMPRequest() {
|
||||||
|
icmpRequests.Inc()
|
||||||
|
}
|
||||||
|
|
||||||
|
func incrementICMPReply() {
|
||||||
|
icmpReplies.Inc()
|
||||||
|
}
|
|
@ -105,6 +105,7 @@ func isEchoReply(msg *icmp.Message) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst string, echoID int, seq int) {
|
func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst string, echoID int, seq int) {
|
||||||
|
incrementICMPRequest()
|
||||||
logger.Debug().
|
logger.Debug().
|
||||||
Str("src", src).
|
Str("src", src).
|
||||||
Str("dst", dst).
|
Str("dst", dst).
|
||||||
|
@ -118,6 +119,7 @@ func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst
|
||||||
}
|
}
|
||||||
|
|
||||||
func observeICMPReply(logger *zerolog.Logger, span trace.Span, dst string, echoID int, seq int) {
|
func observeICMPReply(logger *zerolog.Logger, span trace.Span, dst string, echoID int, seq int) {
|
||||||
|
incrementICMPReply()
|
||||||
logger.Debug().Str("dst", dst).Int("echoID", echoID).Int("seq", seq).Msg("Sent ICMP reply to edge")
|
logger.Debug().Str("dst", dst).Int("echoID", echoID).Int("seq", seq).Msg("Sent ICMP reply to edge")
|
||||||
span.SetAttributes(
|
span.SetAttributes(
|
||||||
attribute.String("dst", dst),
|
attribute.String("dst", dst),
|
||||||
|
|
Loading…
Reference in New Issue