Search code examples
prometheuspromql

How can I query prometheus data greater than value but include all data in series vector?


I think this image says it all

enter image description here

I want to query a series in Prometheus with values greater than .5 but include the lower values in the series so the chart is complete. These are Gauge metrics ranging from 0-1 (decimal percent/ratio) I would like for all the lines in the chart to be complete. Current Query

avg_over_time((failure_percentage > .5)[10m:])

I have tried self joins and grouping to no success.


Solution

  • I was able to solve this with the help of some folks on the prometheus slack using a sort of join hack

    avg_over_time(failure_percentage[10m]) * ( (failure_percentage > 0.5) ^0 )
    

    Original Comment by user viq (For full context and explanation)

    I wonder.... a drity trick that comes to mind is something like

     metric * ( (metric > 0.5) ^ 0)
    

    Since for multiplication to work both sides need to exactly match on labels, so you'll get only the results that match what's on the right, right (I think) should give you only results that match the condition, and ^0 should make the value always be 1, so you're getting in effect metric * 1 maaaaybe, untested