2024-04-21 12:28:17 -04:00
|
|
|
package notifier
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
2024-05-24 04:15:34 -04:00
|
|
|
"tailscale.com/envknob"
|
2024-04-21 12:28:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const prometheusNamespace = "headscale"
|
|
|
|
|
2024-05-24 04:15:34 -04:00
|
|
|
var debugHighCardinalityMetrics = envknob.Bool("HEADSCALE_DEBUG_HIGH_CARDINALITY_METRICS")
|
|
|
|
|
|
|
|
var notifierUpdateSent *prometheus.CounterVec
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if debugHighCardinalityMetrics {
|
|
|
|
notifierUpdateSent = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_update_sent_total",
|
|
|
|
Help: "total count of update sent on nodes channel",
|
|
|
|
}, []string{"status", "type", "trigger", "id"})
|
|
|
|
} else {
|
|
|
|
notifierUpdateSent = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_update_sent_total",
|
|
|
|
Help: "total count of update sent on nodes channel",
|
|
|
|
}, []string{"status", "type", "trigger"})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-21 12:28:17 -04:00
|
|
|
var (
|
2024-05-24 04:15:34 -04:00
|
|
|
notifierWaitersForLock = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_waiters_for_lock",
|
|
|
|
Help: "gauge of waiters for the notifier lock",
|
|
|
|
}, []string{"type", "action"})
|
2024-04-21 12:28:17 -04:00
|
|
|
notifierWaitForLock = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_wait_for_lock_seconds",
|
|
|
|
Help: "histogram of time spent waiting for the notifier lock",
|
|
|
|
Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.5, 1, 3, 5, 10},
|
|
|
|
}, []string{"action"})
|
2024-04-27 04:47:39 -04:00
|
|
|
notifierUpdateReceived = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_update_received_total",
|
|
|
|
Help: "total count of updates received by notifier",
|
|
|
|
}, []string{"type", "trigger"})
|
2024-04-21 12:28:17 -04:00
|
|
|
notifierNodeUpdateChans = promauto.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_open_channels_total",
|
|
|
|
Help: "total count open channels in notifier",
|
|
|
|
})
|
2024-05-24 04:15:34 -04:00
|
|
|
notifierBatcherWaitersForLock = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_batcher_waiters_for_lock",
|
|
|
|
Help: "gauge of waiters for the notifier batcher lock",
|
|
|
|
}, []string{"type", "action"})
|
|
|
|
notifierBatcherChanges = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_batcher_changes_pending",
|
|
|
|
Help: "gauge of full changes pending in the notifier batcher",
|
|
|
|
}, []string{})
|
|
|
|
notifierBatcherPatches = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Namespace: prometheusNamespace,
|
|
|
|
Name: "notifier_batcher_patches_pending",
|
|
|
|
Help: "gauge of patches pending in the notifier batcher",
|
|
|
|
}, []string{})
|
2024-04-21 12:28:17 -04:00
|
|
|
)
|