As you suggested I updated input series data Still getting below error.
Could you please help me on which input series data I need to pass.
Alert:
groups:
- name: distribution-service.alerts
rules:
- alert: Distribution_Service
expr: changes(process_start_time_seconds{job=~"distribution-service"}[5m]) >= 1
for: 1m
labels:
severity: critical
annotations:
summary: Distribution-service too many restarts (instance {{ $labels.instance }})
description: Distribution-service has restarted more than once in the last 5 minutes. It might be crashlooping. VALUE = {{ $value }} LABELS = {{ $labels }}
Test Alert:
rule_files:
- ./distribution-service.yaml
evaluation_interval: 5m
tests:
input_series:
- series: 'process_start_time_seconds{job="distribution-service", instance="test-host"}'
alert_rule_test:
- eval_time: 5m
alertname: Distribution_Service
exp_alerts:
- exp_labels:
job: distribution-service
instance: test-host
exp_annotations:
summary: "Distribution-service too many restarts (instance test-host)"
description: "Distribution-service has restarted more than once in the last 5 minutes. It might be crashlooping. VALUE = 4 LABELS = map[instance:test-host job:distribution-service]"
Gerring Below Error:
Unit Testing: distribution-service-test.yaml
FAILED:
alertname: Distribution_Service, time: 5m,
exp:[
0:
Labels:{alertname="Distribution_Service", instance="test-host", job="distribution-service", severity="critical"}
Annotations:{description="Distribution-service has restarted more than once in the last 5 minutes. It might be crashlooping. VALUE = 4 LABELS = map[instance:test-host job:distribution-service]", summary="Distribution-service too many restarts (instance test-host)"}
],
got:[]