promtool test rules lets you describe input series in a compact notation: '1x5' for a value of 1 repeated, '0+10x4' for a counter rising by 10. The number after the x is easy to read as “this many samples”. It is the number of steps after the first.
With Prometheus 3.15.0, counting the samples each form produces:
| Series | Samples |
|---|---|
'1 1 1 1 1' |
5 |
'1x5' |
6 |
'1+0x5' |
6 |
'1x5 _x3 1x2' |
9 (three steps of _ are gaps, which still use up time) |
a+bxn starts at a and adds b n times, so it writes n+1 values. 1x5 is shorthand for 1+0x5.
It matters most for alert timing. In a test series like this one:
- series: 'up{instance="a"}'
values: '1x5 0x10'
up is 1 from minute 0 to minute 5 inclusive, and 0 from minute 6. Not from minute 5. With for: 2m, an alert on up == 0 cannot fire before minute 8. In my tests it was still quiet at minute 7 and firing at minute 9, so a test expecting it at minute 7 fails, or passes for the wrong reason if you counted the other way.
When a timing assertion surprises you, write the series out longhand once, or add a promql_expr_test with count_over_time to check how many samples there really are.