mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-30 07:59:40 -08:00
3f686cad8b
Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
158 lines
4.1 KiB
YAML
158 lines
4.1 KiB
YAML
rule_files:
|
|
- rules.yml
|
|
|
|
evaluation_interval: 1m
|
|
|
|
tests:
|
|
# Basic tests for promql_expr_test, not dependent on rules.
|
|
- interval: 1m
|
|
input_series:
|
|
- series: test_full
|
|
values: "0 0"
|
|
|
|
- series: test_stale
|
|
values: "0 stale"
|
|
|
|
- series: test_missing
|
|
values: "0 _ _ _ _ _ _ 0"
|
|
|
|
promql_expr_test:
|
|
# Ensure the sample is evaluated at the time we expect it to be.
|
|
- expr: timestamp(test_full)
|
|
eval_time: 0m
|
|
exp_samples:
|
|
- value: 0
|
|
- expr: timestamp(test_full)
|
|
eval_time: 1m
|
|
exp_samples:
|
|
- value: 60
|
|
- expr: timestamp(test_full)
|
|
eval_time: 2m
|
|
exp_samples:
|
|
- value: 60
|
|
|
|
# Ensure a value is stale as soon as it is marked as such.
|
|
- expr: test_stale
|
|
eval_time: 59s
|
|
exp_samples:
|
|
- value: 0
|
|
labels: "test_stale"
|
|
- expr: test_stale
|
|
eval_time: 1m
|
|
exp_samples: []
|
|
|
|
# Ensure lookback delta is respected, when a value is missing.
|
|
- expr: timestamp(test_missing)
|
|
eval_time: 5m
|
|
exp_samples:
|
|
- value: 0
|
|
- expr: timestamp(test_missing)
|
|
eval_time: 5m1s
|
|
exp_samples: []
|
|
|
|
# Minimal test case to check edge case of a single sample.
|
|
- input_series:
|
|
- series: test
|
|
values: 1
|
|
|
|
promql_expr_test:
|
|
- expr: test
|
|
eval_time: 0
|
|
exp_samples:
|
|
- value: 1
|
|
labels: test
|
|
|
|
# Test recording rules run even if input_series isn't provided.
|
|
- promql_expr_test:
|
|
- expr: count_over_time(fixed_data[1h])
|
|
eval_time: 1h
|
|
exp_samples:
|
|
- value: 61
|
|
- expr: timestamp(fixed_data)
|
|
eval_time: 1h
|
|
exp_samples:
|
|
- value: 3600
|
|
|
|
# Tests for alerting rules.
|
|
- interval: 1m
|
|
input_series:
|
|
- series: 'up{job="prometheus", instance="localhost:9090"}'
|
|
values: "0+0x1440"
|
|
|
|
promql_expr_test:
|
|
- expr: count(ALERTS) by (alertname, alertstate)
|
|
eval_time: 4m
|
|
exp_samples:
|
|
- labels: '{alertname="AlwaysFiring",alertstate="firing"}'
|
|
value: 1
|
|
- labels: '{alertname="InstanceDown",alertstate="pending"}'
|
|
value: 1
|
|
|
|
alert_rule_test:
|
|
- eval_time: 1d
|
|
alertname: AlwaysFiring
|
|
exp_alerts:
|
|
- {}
|
|
|
|
- eval_time: 1d
|
|
alertname: InstanceDown
|
|
exp_alerts:
|
|
- exp_labels:
|
|
severity: page
|
|
instance: localhost:9090
|
|
job: prometheus
|
|
exp_annotations:
|
|
summary: "Instance localhost:9090 down"
|
|
description: "localhost:9090 of job prometheus has been down for more than 5 minutes."
|
|
|
|
- eval_time: 0
|
|
alertname: AlwaysFiring
|
|
exp_alerts:
|
|
- {}
|
|
|
|
- eval_time: 0
|
|
alertname: InstanceDown
|
|
exp_alerts: []
|
|
|
|
# Tests for interval vs evaluation_interval.
|
|
- interval: 1s
|
|
input_series:
|
|
- series: 'test{job="test", instance="x:0"}'
|
|
# 2 minutes + 1 second of input data, recording rules should only run
|
|
# once a minute.
|
|
values: "0+1x120"
|
|
|
|
promql_expr_test:
|
|
- expr: job:test:count_over_time1m
|
|
eval_time: 0m
|
|
exp_samples:
|
|
- value: 1
|
|
labels: 'job:test:count_over_time1m{job="test"}'
|
|
- expr: timestamp(job:test:count_over_time1m)
|
|
eval_time: 10s
|
|
exp_samples:
|
|
- value: 0
|
|
labels: '{job="test"}'
|
|
|
|
- expr: job:test:count_over_time1m
|
|
eval_time: 1m
|
|
exp_samples:
|
|
- value: 61
|
|
labels: 'job:test:count_over_time1m{job="test"}'
|
|
- expr: timestamp(job:test:count_over_time1m)
|
|
eval_time: 1m10s
|
|
exp_samples:
|
|
- value: 60
|
|
labels: '{job="test"}'
|
|
|
|
- expr: job:test:count_over_time1m
|
|
eval_time: 2m
|
|
exp_samples:
|
|
- value: 61
|
|
labels: 'job:test:count_over_time1m{job="test"}'
|
|
- expr: timestamp(job:test:count_over_time1m)
|
|
eval_time: 2m59s999ms
|
|
exp_samples:
|
|
- value: 120
|
|
labels: '{job="test"}'
|