mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-28 04:02:21 -04:00
Migrate notifier metrics with callbacks
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
This commit is contained in:
parent
ea2370e773
commit
92c98331f4
3 changed files with 24 additions and 41 deletions
|
|
@ -36,21 +36,14 @@ func newAlertMetrics(
|
|||
queueLen, alertmanagersDiscovered func() float64,
|
||||
) *alertMetrics {
|
||||
m := &alertMetrics{
|
||||
latencySummary: metrics.NewPrometheusNotificationsLatencySeconds(),
|
||||
latencyHistogram: metrics.NewPrometheusNotificationsLatencyHistogramSeconds(),
|
||||
errors: metrics.NewPrometheusNotificationsErrorsTotal(),
|
||||
sent: metrics.NewPrometheusNotificationsSentTotal(),
|
||||
dropped: metrics.NewPrometheusNotificationsDroppedTotal(),
|
||||
// GaugeFunc metrics require callbacks, so they remain manual
|
||||
queueLength: prometheus.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_queue_length",
|
||||
Help: "The number of alert notifications in the queue.",
|
||||
}, queueLen),
|
||||
queueCapacity: metrics.NewPrometheusNotificationsQueueCapacity(),
|
||||
alertmanagersDiscovered: prometheus.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_alertmanagers_discovered",
|
||||
Help: "The number of alertmanagers discovered and active.",
|
||||
}, alertmanagersDiscovered),
|
||||
latencySummary: metrics.NewPrometheusNotificationsLatencySeconds(),
|
||||
latencyHistogram: metrics.NewPrometheusNotificationsLatencyHistogramSeconds(),
|
||||
errors: metrics.NewPrometheusNotificationsErrorsTotal(),
|
||||
sent: metrics.NewPrometheusNotificationsSentTotal(),
|
||||
dropped: metrics.NewPrometheusNotificationsDroppedTotal(),
|
||||
queueLength: prometheus.NewGaugeFunc(metrics.PrometheusNotificationsQueueLengthOpts(), queueLen),
|
||||
queueCapacity: metrics.NewPrometheusNotificationsQueueCapacity(),
|
||||
alertmanagersDiscovered: prometheus.NewGaugeFunc(metrics.PrometheusNotificationsAlertmanagersDiscoveredOpts(), alertmanagersDiscovered),
|
||||
}
|
||||
|
||||
m.queueCapacity.Set(float64(queueCap))
|
||||
|
|
|
|||
|
|
@ -26,17 +26,10 @@ func (a AlertmanagerAttr) Value() string {
|
|||
}
|
||||
|
||||
// PrometheusNotificationsAlertmanagersDiscovered records the number of alertmanagers discovered and active.
|
||||
type PrometheusNotificationsAlertmanagersDiscovered struct {
|
||||
prometheus.Gauge
|
||||
}
|
||||
|
||||
// NewPrometheusNotificationsAlertmanagersDiscovered returns a new PrometheusNotificationsAlertmanagersDiscovered instrument.
|
||||
func NewPrometheusNotificationsAlertmanagersDiscovered() PrometheusNotificationsAlertmanagersDiscovered {
|
||||
return PrometheusNotificationsAlertmanagersDiscovered{
|
||||
Gauge: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_alertmanagers_discovered",
|
||||
Help: "The number of alertmanagers discovered and active.",
|
||||
}),
|
||||
func PrometheusNotificationsAlertmanagersDiscoveredOpts() prometheus.GaugeOpts {
|
||||
return prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_alertmanagers_discovered",
|
||||
Help: "The number of alertmanagers discovered and active.",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,8 +141,8 @@ func NewPrometheusNotificationsLatencySeconds() PrometheusNotificationsLatencySe
|
|||
Name: "prometheus_notifications_latency_seconds",
|
||||
Help: "Latency quantiles for sending alert notifications.",
|
||||
Objectives: map[float64]float64{
|
||||
0.5: 0.05,
|
||||
0.9: 0.01,
|
||||
0.5: 0.05,
|
||||
0.9: 0.01,
|
||||
0.99: 0.001,
|
||||
},
|
||||
}, labels),
|
||||
|
|
@ -191,17 +184,10 @@ func NewPrometheusNotificationsQueueCapacity() PrometheusNotificationsQueueCapac
|
|||
}
|
||||
|
||||
// PrometheusNotificationsQueueLength records the number of alert notifications in the queue.
|
||||
type PrometheusNotificationsQueueLength struct {
|
||||
prometheus.Gauge
|
||||
}
|
||||
|
||||
// NewPrometheusNotificationsQueueLength returns a new PrometheusNotificationsQueueLength instrument.
|
||||
func NewPrometheusNotificationsQueueLength() PrometheusNotificationsQueueLength {
|
||||
return PrometheusNotificationsQueueLength{
|
||||
Gauge: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_queue_length",
|
||||
Help: "The number of alert notifications in the queue.",
|
||||
}),
|
||||
func PrometheusNotificationsQueueLengthOpts() prometheus.GaugeOpts {
|
||||
return prometheus.GaugeOpts{
|
||||
Name: "prometheus_notifications_queue_length",
|
||||
Help: "The number of alert notifications in the queue.",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ groups:
|
|||
metric_name: prometheus_notifications_alertmanagers_discovered
|
||||
instrument: gauge
|
||||
unit: "{alertmanager}"
|
||||
# Note: This is implemented as GaugeFunc in code (requires callback)
|
||||
annotations:
|
||||
prometheus:
|
||||
only_opts: true # Implemented as GaugeFunc
|
||||
|
||||
- id: metric.prometheus_notifications_dropped_total
|
||||
type: metric
|
||||
|
|
@ -49,7 +51,9 @@ groups:
|
|||
metric_name: prometheus_notifications_queue_length
|
||||
instrument: gauge
|
||||
unit: "{notification}"
|
||||
# Note: This is implemented as GaugeFunc in code (requires callback)
|
||||
annotations:
|
||||
prometheus:
|
||||
only_opts: true # Implemented as GaugeFunc
|
||||
|
||||
# Metrics with alertmanager label
|
||||
- id: metric.prometheus_notifications_errors_total
|
||||
|
|
|
|||
Loading…
Reference in a new issue