mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 16:02:28 +00:00
3a204be6b7
* WIP: PromQL: Allow engine to return strings Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com> * Add test suggested by @roidelapluie Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com> * Fix typo in React UI Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com> * Fix parenthesis handling for functions and aggregator params Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com> * Add more tests Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com> * Fix React UI test Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
118 lines
6.7 KiB
Plaintext
118 lines
6.7 KiB
Plaintext
load 10s
|
|
metric 1 2
|
|
|
|
# Evaluation before 0s gets no sample.
|
|
eval instant at 10s sum_over_time(metric[50s:10s])
|
|
{} 3
|
|
|
|
eval instant at 10s sum_over_time(metric[50s:5s])
|
|
{} 4
|
|
|
|
# Every evaluation yields the last value, i.e. 2
|
|
eval instant at 5m sum_over_time(metric[50s:10s])
|
|
{} 12
|
|
|
|
# Series becomes stale at 5m10s (5m after last sample)
|
|
# Hence subquery gets a single sample at 6m-50s=5m10s.
|
|
eval instant at 6m sum_over_time(metric[50s:10s])
|
|
{} 2
|
|
|
|
eval instant at 10s rate(metric[20s:10s])
|
|
{} 0.1
|
|
|
|
eval instant at 20s rate(metric[20s:5s])
|
|
{} 0.05
|
|
|
|
clear
|
|
|
|
load 10s
|
|
http_requests{job="api-server", instance="1", group="production"} 0+20x1000 200+30x1000
|
|
http_requests{job="api-server", instance="0", group="production"} 0+10x1000 100+30x1000
|
|
http_requests{job="api-server", instance="0", group="canary"} 0+30x1000 300+80x1000
|
|
http_requests{job="api-server", instance="1", group="canary"} 0+40x2000
|
|
|
|
eval instant at 8000s rate(http_requests{group=~"pro.*"}[1m:10s])
|
|
{job="api-server", instance="0", group="production"} 1
|
|
{job="api-server", instance="1", group="production"} 2
|
|
|
|
eval instant at 20000s avg_over_time(rate(http_requests[1m])[1m:1s])
|
|
{job="api-server", instance="0", group="canary"} 8
|
|
{job="api-server", instance="1", group="canary"} 4
|
|
{job="api-server", instance="1", group="production"} 3
|
|
{job="api-server", instance="0", group="production"} 3
|
|
|
|
clear
|
|
|
|
load 10s
|
|
metric1 0+1x1000
|
|
metric2 0+2x1000
|
|
metric3 0+3x1000
|
|
|
|
eval instant at 1000s sum_over_time(metric1[30s:10s])
|
|
{} 394
|
|
|
|
# This is (394*2 - 100), because other than the last 100 at 1000s,
|
|
# everything else is repeated with the 5s step.
|
|
eval instant at 1000s sum_over_time(metric1[30s:5s])
|
|
{} 688
|
|
|
|
# Offset is aligned with the step.
|
|
eval instant at 1010s sum_over_time(metric1[30s:10s] offset 10s)
|
|
{} 394
|
|
|
|
# Same result for different offsets due to step alignment.
|
|
eval instant at 1010s sum_over_time(metric1[30s:10s] offset 9s)
|
|
{} 297
|
|
|
|
eval instant at 1010s sum_over_time(metric1[30s:10s] offset 7s)
|
|
{} 297
|
|
|
|
eval instant at 1010s sum_over_time(metric1[30s:10s] offset 5s)
|
|
{} 297
|
|
|
|
eval instant at 1010s sum_over_time(metric1[30s:10s] offset 3s)
|
|
{} 297
|
|
|
|
eval instant at 1010s sum_over_time((metric1)[30s:10s] offset 3s)
|
|
{} 297
|
|
|
|
# Nested subqueries
|
|
eval instant at 1000s rate(sum_over_time(metric1[30s:10s])[50s:10s])
|
|
{} 0.4
|
|
|
|
eval instant at 1000s rate(sum_over_time(metric2[30s:10s])[50s:10s])
|
|
{} 0.8
|
|
|
|
eval instant at 1000s rate(sum_over_time(metric3[30s:10s])[50s:10s])
|
|
{} 1.2
|
|
|
|
eval instant at 1000s rate(sum_over_time((metric1+metric2+metric3)[30s:10s])[30s:10s])
|
|
{} 2.4
|
|
|
|
clear
|
|
|
|
# Fibonacci sequence, to ensure the rate is not constant.
|
|
# Additional note: using subqueries unnecessarily is unwise.
|
|
load 7s
|
|
metric 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 4807526976 7778742049 12586269025 20365011074 32951280099 53316291173 86267571272 139583862445 225851433717 365435296162 591286729879 956722026041 1548008755920 2504730781961 4052739537881 6557470319842 10610209857723 17167680177565 27777890035288 44945570212853 72723460248141 117669030460994 190392490709135 308061521170129 498454011879264 806515533049393 1304969544928657 2111485077978050 3416454622906707 5527939700884757 8944394323791464 14472334024676221 23416728348467685 37889062373143906 61305790721611591 99194853094755497 160500643816367088 259695496911122585 420196140727489673 679891637638612258 1100087778366101931 1779979416004714189 2880067194370816120 4660046610375530309 7540113804746346429 12200160415121876738 19740274219868223167 31940434634990099905 51680708854858323072 83621143489848422977 135301852344706746049 218922995834555169026 354224848179261915075 573147844013817084101 927372692193078999176 1500520536206896083277 2427893228399975082453 3928413764606871165730 6356306993006846248183 10284720757613717413913 16641027750620563662096 26925748508234281076009 43566776258854844738105 70492524767089125814114 114059301025943970552219 184551825793033096366333 298611126818977066918552 483162952612010163284885 781774079430987230203437 1264937032042997393488322 2046711111473984623691759 3311648143516982017180081 5358359254990966640871840 8670007398507948658051921 14028366653498915298923761 22698374052006863956975682 36726740705505779255899443 59425114757512643212875125 96151855463018422468774568 155576970220531065681649693 251728825683549488150424261 407305795904080553832073954 659034621587630041982498215 1066340417491710595814572169 1725375039079340637797070384 2791715456571051233611642553 4517090495650391871408712937 7308805952221443105020355490 11825896447871834976429068427 19134702400093278081449423917 30960598847965113057878492344 50095301248058391139327916261 81055900096023504197206408605 131151201344081895336534324866 212207101440105399533740733471 343358302784187294870275058337 555565404224292694404015791808 898923707008479989274290850145 1454489111232772683678306641953 2353412818241252672952597492098 3807901929474025356630904134051 6161314747715278029583501626149 9969216677189303386214405760200 16130531424904581415797907386349 26099748102093884802012313146549 42230279526998466217810220532898 68330027629092351019822533679447 110560307156090817237632754212345 178890334785183168257455287891792 289450641941273985495088042104137 468340976726457153752543329995929 757791618667731139247631372100066 1226132595394188293000174702095995 1983924214061919432247806074196061 3210056809456107725247980776292056 5193981023518027157495786850488117 8404037832974134882743767626780173 13598018856492162040239554477268290 22002056689466296922983322104048463 35600075545958458963222876581316753 57602132235424755886206198685365216 93202207781383214849429075266681969 150804340016807970735635273952047185 244006547798191185585064349218729154 394810887814999156320699623170776339 638817435613190341905763972389505493 1033628323428189498226463595560281832 1672445759041379840132227567949787325 2706074082469569338358691163510069157 4378519841510949178490918731459856482 7084593923980518516849609894969925639 11463113765491467695340528626429782121 18547707689471986212190138521399707760
|
|
|
|
# Extrapolated from [3@21, 144@77]: (144 - 3) / (77 - 21)
|
|
eval instant at 80s rate(metric[1m])
|
|
{} 2.517857143
|
|
|
|
# No extrapolation, [2@20, 144@80]: (144 - 2) / 60
|
|
eval instant at 80s rate(metric[1m:10s])
|
|
{} 2.366666667
|
|
|
|
# Only one value between 10s and 20s, 2@14
|
|
eval instant at 20s min_over_time(metric[10s])
|
|
{} 2
|
|
|
|
# min(1@10, 2@20)
|
|
eval instant at 20s min_over_time(metric[10s:10s])
|
|
{} 1
|
|
|
|
eval instant at 20m min_over_time(rate(metric[5m])[20m:1m])
|
|
{} 0.12119047619047618
|
|
|