Hi, There are at least a couple of things off in that query:
* http_service_api looks like it's probably a counter metric (although it doesn't have a "_total" suffix), so you need to apply rate() to it first, before applying a sum(). Otherwise you are looking at the absolute value of the counter, which has accumulated over a long time, which doesn't tell you much. * Due to your "by(method)" your output labels are just "method" on both sides of the binop, so you don't need the "ignoring()" and also not the "group_left()". Maybe you mean something closer to this? https://demo.promlens.com/?l=14PEjXeJocK (changed the metric and label names to ones that have data in the demo setup) sum_over_time(sum by(method) (100*sum by (method) (rate(demo_api_request_duration_seconds_count{status="200"}[1m])) / sum by (method) (rate(demo_api_request_duration_seconds_count[1m])) < bool 98)[1d:1m]) I guess in the end it should give you something close to "how many minutes per method over the last day did each method have a percentage of <98 of statusCode="0"? Regards, Julius On Fri, Apr 23, 2021 at 5:17 PM Luciano Polo <[email protected]> wrote: > HI, > > I am not able to make this query to work precise enough. Hopefully, > someone can help me out. > > This Query works fine. It returns 1 if the result is less than 98 > 100*sum(http_service_api{apiCode="0"}) by (method) / ignoring (apiCode) > group_left() sum(http_service_api{} ) by (method) < bool 98 > > This is the part I am having issues with. I need to add all ones within a > period of time where the result was lower than 98. > So the query is: > > sum_over_time(sum(100*sum(http_service_api{apiCode="0"}) by (method) / > ignoring (apiCode) group_left() sum(http_service_api{} ) by (method) < > bool 98) by (method)[1d:1m]) > > I should expect the number to increase every time the result is less than > 98, I this but I also see it decreasing. I have not been able to figure > out why? > > Any idea is appreciated. > > Thanks in advanced > > -- > You received this message because you are subscribed to the Google Groups > "Prometheus Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/prometheus-users/9decf191-cf6d-4194-a092-d714e2cfdab5n%40googlegroups.com > <https://groups.google.com/d/msgid/prometheus-users/9decf191-cf6d-4194-a092-d714e2cfdab5n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Julius Volz PromLabs - promlabs.com -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/CAObpH5y%3Dvik9Bq2R%2BNVeqd%2BiByHBd22FZyT8_kW-_xq_jG4bow%40mail.gmail.com.

