Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change compat metrics to counters #3686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions matchers/compat/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ var DefaultOrigins = []string{
var RegisteredMetrics = NewMetrics(prometheus.DefaultRegisterer)

type Metrics struct {
Total *prometheus.GaugeVec
DisagreeTotal *prometheus.GaugeVec
IncompatibleTotal *prometheus.GaugeVec
InvalidTotal *prometheus.GaugeVec
Total *prometheus.CounterVec
DisagreeTotal *prometheus.CounterVec
IncompatibleTotal *prometheus.CounterVec
InvalidTotal *prometheus.CounterVec
}

func NewMetrics(r prometheus.Registerer) *Metrics {
m := &Metrics{
Total: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Name: "alertmanager_matchers_parse",
Total: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "alertmanager_matchers_parse_total",
Help: "Total number of matcher inputs parsed, including invalid inputs.",
}, []string{"origin"}),
DisagreeTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Name: "alertmanager_matchers_disagree",
DisagreeTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "alertmanager_matchers_disagree_total",
Help: "Total number of matcher inputs which produce different parsings (disagreement).",
}, []string{"origin"}),
IncompatibleTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Name: "alertmanager_matchers_incompatible",
IncompatibleTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "alertmanager_matchers_incompatible_total",
Help: "Total number of matcher inputs that are incompatible with the UTF-8 parser.",
}, []string{"origin"}),
InvalidTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Name: "alertmanager_matchers_invalid",
InvalidTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "alertmanager_matchers_invalid_total",
Help: "Total number of matcher inputs that could not be parsed.",
}, []string{"origin"}),
}
Expand Down
2 changes: 1 addition & 1 deletion matchers/compat/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
require.Equal(t, 0, testutil.CollectAndCount(m))
} else {
Expand Down
Loading