mirror of
https://github.com/prometheus/alertmanager
synced 2025-04-07 09:44:26 +00:00
Change compat metrics to counters (#3686)
This commit changes the metrics in the compat package from gauges to counters. The reason for this is that in some cases the gauge should behave like a gauge (i.e. loading configurations) but in other cases should behave like a counter (i.e. HTTP requests). Second, because the compat package is a global package (due to how config.Load works), in tenanted systems like Cortex and Mimir it was non-trivial to reset the gauges per tenant each time their configuration was reloaded. Instead, it's easier to compute the rate of increase as 0 instead of check that the gauge is 0 to know if UTF-8 strict mode can be enabled. Signed-off-by: George Robinson <george.robinson@grafana.com>
This commit is contained in:
parent
c97b7f1b27
commit
cab8ecbc95
@ -31,28 +31,28 @@ var DefaultOrigins = []string{
|
|||||||
var RegisteredMetrics = NewMetrics(prometheus.DefaultRegisterer)
|
var RegisteredMetrics = NewMetrics(prometheus.DefaultRegisterer)
|
||||||
|
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
Total *prometheus.GaugeVec
|
Total *prometheus.CounterVec
|
||||||
DisagreeTotal *prometheus.GaugeVec
|
DisagreeTotal *prometheus.CounterVec
|
||||||
IncompatibleTotal *prometheus.GaugeVec
|
IncompatibleTotal *prometheus.CounterVec
|
||||||
InvalidTotal *prometheus.GaugeVec
|
InvalidTotal *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMetrics(r prometheus.Registerer) *Metrics {
|
func NewMetrics(r prometheus.Registerer) *Metrics {
|
||||||
m := &Metrics{
|
m := &Metrics{
|
||||||
Total: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
|
Total: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alertmanager_matchers_parse",
|
Name: "alertmanager_matchers_parse_total",
|
||||||
Help: "Total number of matcher inputs parsed, including invalid inputs.",
|
Help: "Total number of matcher inputs parsed, including invalid inputs.",
|
||||||
}, []string{"origin"}),
|
}, []string{"origin"}),
|
||||||
DisagreeTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
|
DisagreeTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alertmanager_matchers_disagree",
|
Name: "alertmanager_matchers_disagree_total",
|
||||||
Help: "Total number of matcher inputs which produce different parsings (disagreement).",
|
Help: "Total number of matcher inputs which produce different parsings (disagreement).",
|
||||||
}, []string{"origin"}),
|
}, []string{"origin"}),
|
||||||
IncompatibleTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
|
IncompatibleTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alertmanager_matchers_incompatible",
|
Name: "alertmanager_matchers_incompatible_total",
|
||||||
Help: "Total number of matcher inputs that are incompatible with the UTF-8 parser.",
|
Help: "Total number of matcher inputs that are incompatible with the UTF-8 parser.",
|
||||||
}, []string{"origin"}),
|
}, []string{"origin"}),
|
||||||
InvalidTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
|
InvalidTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alertmanager_matchers_invalid",
|
Name: "alertmanager_matchers_invalid_total",
|
||||||
Help: "Total number of matcher inputs that could not be parsed.",
|
Help: "Total number of matcher inputs that could not be parsed.",
|
||||||
}, []string{"origin"}),
|
}, []string{"origin"}),
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ func TestIsValidUTF8LabelName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requireMetric(t *testing.T, expected float64, m *prometheus.GaugeVec) {
|
func requireMetric(t *testing.T, expected float64, m *prometheus.CounterVec) {
|
||||||
if expected == 0 {
|
if expected == 0 {
|
||||||
require.Equal(t, 0, testutil.CollectAndCount(m))
|
require.Equal(t, 0, testutil.CollectAndCount(m))
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user