-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Closed
Description
What did you do?
rule3.yaml:
groups:
- name: MyRules
rules:
- alert: MySQLReplicationDown
expr: mysql_global_variables_innodb_replication_delay == -1
for: 5m
labels:
severity: High
alert_owner: alerts-infra
annotations:
description: MySQL replication is broken
test-rule3.yaml:
rule_files:
- rule3.yaml
tests:
- input_series:
- series: mysql_global_variables_innodb_replication_delay
values: '1 1 1 1 1 1 0 0 0 0 -1 -1 -1 -1 -1 -1'
interval: 1m
alert_rule_test:
- alertname: MySQLReplicationDown
eval_time: 15m
exp_alerts:
- exp_labels:
severity: High
alert_owner: alerts-infra
exp_annotations:
description: MySQL replication is broken
Test with promtool test rules test-rule3.yaml
Then comment out interval: 1m and test again.
(Based on user report in google groups)
What did you expect to see?
I expected the test to pass in both cases
What did you see instead? Under which circumstances?
The test passes with interval: 1m, but fails when this is commented out.
Unit Testing: test-rule3.yaml
FAILED:
alertname: MySQLReplicationDown, time: 15m,
exp:[
0:
Labels:{alert_owner="alerts-infra", alertname="MySQLReplicationDown", severity="High"}
Annotations:{description="MySQL replication is broken"}
],
got:[]
Note: the documentation for unit testing states that the evaluation_interval in a rule test file defaults to 1m. It doesn't say what the default is for the interval in a test group.
However, I was expecting this interval to default to either 1m, or to the evaluation_interval.
If it is intentionally defaulting to something else, then IMO this ought to be documented.
System information
Linux 5.4.0-162-generic x86_64
Prometheus version
prometheus, version 2.45.0 (branch: HEAD, revision: 8ef767e396bf8445f009f945b0162fd71827f445)
build user: root@920118f645b7
build date: 20230623-15:09:49
go version: go1.20.5
platform: linux/amd64
tags: netgo,builtinassets,stringlabels
Prometheus configuration file
N/A, this is promtool onlyAlertmanager version
N/A
Alertmanager configuration file
N/ALogs
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels