Add metrics for rule evaluation failures.

Fixes https://github.com/prometheus/prometheus/issues/417
This commit is contained in:
Julius Volz 2014-12-31 13:16:08 +01:00
parent 7aae5dd873
commit 9a4ca68a61

View file

@ -49,6 +49,13 @@ var (
}, },
[]string{ruleTypeLabel}, []string{ruleTypeLabel},
) )
evalFailures = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: namespace,
Name: "rule_evaluation_failures_total",
Help: "The total number of rule evaluation failures.",
},
)
iterationDuration = prometheus.NewSummary(prometheus.SummaryOpts{ iterationDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace, Namespace: namespace,
Name: "evaluator_duration_milliseconds", Name: "evaluator_duration_milliseconds",
@ -59,6 +66,7 @@ var (
func init() { func init() {
prometheus.MustRegister(iterationDuration) prometheus.MustRegister(iterationDuration)
prometheus.MustRegister(evalFailures)
prometheus.MustRegister(evalDuration) prometheus.MustRegister(evalDuration)
} }
@ -229,6 +237,11 @@ func (m *ruleManager) runIteration(results chan<- *extraction.Result) {
Timestamp: s.Timestamp, Timestamp: s.Timestamp,
} }
} }
if err != nil {
evalFailures.Inc()
}
m.results <- &extraction.Result{ m.results <- &extraction.Result{
Samples: samples, Samples: samples,
Err: err, Err: err,