mirror of https://github.com/prometheus/prometheus
Improve rules/ instrumentation
This commit adds a counter for the total number of rule evaluations and standardizes the units to seconds.pull/1266/head
parent
62075aa037
commit
f69e668fc4
|
@ -46,7 +46,7 @@ var (
|
||||||
evalDuration = prometheus.NewSummaryVec(
|
evalDuration = prometheus.NewSummaryVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: "rule_evaluation_duration_milliseconds",
|
Name: "rule_evaluation_duration_seconds",
|
||||||
Help: "The duration for a rule to execute.",
|
Help: "The duration for a rule to execute.",
|
||||||
},
|
},
|
||||||
[]string{ruleTypeLabel},
|
[]string{ruleTypeLabel},
|
||||||
|
@ -58,9 +58,16 @@ var (
|
||||||
Help: "The total number of rule evaluation failures.",
|
Help: "The total number of rule evaluation failures.",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
evalTotal = prometheus.NewCounter(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: "rule_evaluations_total",
|
||||||
|
Help: "The total number of rule evaluations.",
|
||||||
|
},
|
||||||
|
)
|
||||||
iterationDuration = prometheus.NewSummary(prometheus.SummaryOpts{
|
iterationDuration = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: "evaluator_duration_milliseconds",
|
Name: "evaluator_duration_seconds",
|
||||||
Help: "The duration for all evaluations to execute.",
|
Help: "The duration for all evaluations to execute.",
|
||||||
Objectives: map[float64]float64{0.01: 0.001, 0.05: 0.005, 0.5: 0.05, 0.90: 0.01, 0.99: 0.001},
|
Objectives: map[float64]float64{0.01: 0.001, 0.05: 0.005, 0.5: 0.05, 0.90: 0.01, 0.99: 0.001},
|
||||||
})
|
})
|
||||||
|
@ -121,7 +128,7 @@ func (g *Group) run() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
g.eval()
|
g.eval()
|
||||||
|
|
||||||
iterationDuration.Observe(float64(time.Since(start) / time.Millisecond))
|
iterationDuration.Observe(float64(time.Since(start)) / float64(time.Millisecond))
|
||||||
}
|
}
|
||||||
iter()
|
iter()
|
||||||
|
|
||||||
|
@ -199,6 +206,7 @@ func (g *Group) eval() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
evalTotal.Inc()
|
||||||
|
|
||||||
vector, err := rule.eval(now, g.opts.QueryEngine)
|
vector, err := rule.eval(now, g.opts.QueryEngine)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -220,7 +228,7 @@ func (g *Group) eval() {
|
||||||
}
|
}
|
||||||
|
|
||||||
evalDuration.WithLabelValues(string(rtyp)).Observe(
|
evalDuration.WithLabelValues(string(rtyp)).Observe(
|
||||||
float64(time.Since(start) / time.Millisecond),
|
float64(time.Since(start)) / float64(time.Second),
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, s := range vector {
|
for _, s := range vector {
|
||||||
|
|
Loading…
Reference in New Issue