mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 18:39:58 +00:00
TUN-7477: Add UDP/TCP session metrics
New gauge metrics are exposed in the prometheus endpoint to capture the current and total TCP and UDP sessions that cloudflared has proxied.
This commit is contained in:
40
datagramsession/metrics.go
Normal file
40
datagramsession/metrics.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package datagramsession
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "cloudflared"
|
||||
)
|
||||
|
||||
var (
|
||||
activeUDPSessions = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: "udp",
|
||||
Name: "active_sessions",
|
||||
Help: "Concurrent count of UDP sessions that are being proxied to any origin",
|
||||
})
|
||||
totalUDPSessions = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: "udp",
|
||||
Name: "total_sessions",
|
||||
Help: "Total count of UDP sessions that have been proxied to any origin",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(
|
||||
activeUDPSessions,
|
||||
totalUDPSessions,
|
||||
)
|
||||
}
|
||||
|
||||
func incrementUDPSessions() {
|
||||
totalUDPSessions.Inc()
|
||||
activeUDPSessions.Inc()
|
||||
}
|
||||
|
||||
func decrementUDPActiveSessions() {
|
||||
activeUDPSessions.Dec()
|
||||
}
|
Reference in New Issue
Block a user