mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Merge pull request #5608 from simonpasquier/external-labels-for-alert-tests
cmd/promtool: add $externalLabels for alert unit tests
This commit is contained in:
commit
dc22f74153
|
@ -157,6 +157,7 @@ type testGroup struct {
|
|||
InputSeries []series `yaml:"input_series"`
|
||||
AlertRuleTests []alertTestCase `yaml:"alert_rule_test,omitempty"`
|
||||
PromqlExprTests []promqlTestCase `yaml:"promql_expr_test,omitempty"`
|
||||
ExternalLabels labels.Labels `yaml:"external_labels,omitempty"`
|
||||
}
|
||||
|
||||
// test performs the unit tests.
|
||||
|
@ -177,8 +178,7 @@ func (tg *testGroup) test(mint, maxt time.Time, evalInterval time.Duration, grou
|
|||
Logger: log.NewNopLogger(),
|
||||
}
|
||||
m := rules.NewManager(opts)
|
||||
// TODO(beorn7): Provide a way to pass in external labels.
|
||||
groupsMap, ers := m.LoadGroups(tg.Interval, nil, ruleFiles...)
|
||||
groupsMap, ers := m.LoadGroups(tg.Interval, tg.ExternalLabels, ruleFiles...)
|
||||
if ers != nil {
|
||||
return ers
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ alert_rule_test:
|
|||
# Unit tests PromQL expressions.
|
||||
promql_expr_test:
|
||||
[ - <promql_test_case> ]
|
||||
|
||||
# External labels accessible to the alert template.
|
||||
external_labels:
|
||||
[ <labelname>: <string> ... ]
|
||||
```
|
||||
|
||||
### `<series>`
|
||||
|
|
Loading…
Reference in a new issue