mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 07:52:28 +00:00
cmd/promtool: add $externalLabels for alert unit tests
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
22824c2e08
commit
74ff35ccdd
@ -144,6 +144,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.
|
||||
@ -164,8 +165,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 New Issue
Block a user