forked from prometheus/alertmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support UTF-8 label matchers: Add metrics to matchers compat package (p…
…rometheus#3658) * Add metrics to matchers compat package This commit adds the following metrics to the compat package: alertmanager_matchers_parse alertmanager_matchers_disagree alertmanager_matchers_incompatible alertmanager_matchers_invalid With a label called origin to differentiate the different sources of inputs: the configuration file, the API, and amtool. The disagree_total metric is incremented when an input is invalid in both parsers, but results in different parsed representations, then there is disagreement. This should not happen, and suggests their is either a bug in one of the parsers or a mistake in the backwards compatible guarantees of the matchers/parse parser. The incompatible_total metric is incremented when an input is valid in pkg/labels, but not the UTF-8 parser in matchers/parse. In such case, the matcher should be updated to be compatible. This often means adding double quotes around the right hand side of the matcher. For example, foo="bar". The invalid_total metric is incremented when an input is invalid in both parsers. This was never a valid input. The tests have been updated to check the metrics are incremented as expected. Signed-off-by: George Robinson <george.robinson@grafana.com> --------- Signed-off-by: George Robinson <george.robinson@grafana.com> Signed-off-by: Gokhan Sari <gokhan@sari.me>
- Loading branch information
1 parent
382e44f
commit 0a4c1cf
Showing
12 changed files
with
306 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 The Prometheus Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package compat | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
const ( | ||
OriginAPI = "api" | ||
OriginConfig = "config" | ||
) | ||
|
||
var DefaultOrigins = []string{ | ||
OriginAPI, | ||
OriginConfig, | ||
} | ||
|
||
var RegisteredMetrics = NewMetrics(prometheus.DefaultRegisterer) | ||
|
||
type Metrics struct { | ||
Total *prometheus.GaugeVec | ||
DisagreeTotal *prometheus.GaugeVec | ||
IncompatibleTotal *prometheus.GaugeVec | ||
InvalidTotal *prometheus.GaugeVec | ||
} | ||
|
||
func NewMetrics(r prometheus.Registerer) *Metrics { | ||
m := &Metrics{ | ||
Total: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "alertmanager_matchers_parse", | ||
Help: "Total number of matcher inputs parsed, including invalid inputs.", | ||
}, []string{"origin"}), | ||
DisagreeTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "alertmanager_matchers_disagree", | ||
Help: "Total number of matcher inputs which produce different parsings (disagreement).", | ||
}, []string{"origin"}), | ||
IncompatibleTotal: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "alertmanager_matchers_incompatible", | ||
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", | ||
Help: "Total number of matcher inputs that could not be parsed.", | ||
}, []string{"origin"}), | ||
} | ||
return m | ||
} |
Oops, something went wrong.