Thanks. In this case, it looks like a bug to me since for the following 
query, 
*avg by (service_id)($Metric{service_id=~"$underutilized_services"})*
if $underutilized_services" is empty, ideally it should return nothing 
instead of all data points by applying regex match.
btw, is there a way for me to get over this by using a different query?

On Friday, April 16, 2021 at 12:58:21 AM UTC-7 [email protected] wrote:

> The point is that service_id have regexp matchers, so it will 
> match all data instead of null.
>
> On Thu, Apr 15, 2021 at 12:23:24 PM +0800, chuanjia xing wrote:
>
> > Ping for this. Anyone can give some pointers for this? Thanks.
> >
> > On Tuesday, April 13, 2021 at 4:41:55 PM UTC-7 chuanjia xing 
> > wrote:
> >
> >> Hi there,
> >>
> >> I hit following issue when using Prometheus + Grafana, 
> >> and want to
> >> check if this is a bug in Prometheus query.
> >>
> >> Scenario:
> >>
> >> I am using Prometheus to collect CPUUtilization for aws 
> >> instances. In
> >> one dashboard, I want to show the metrics for services which 
> >> are
> >> underutilized. To do this, I first use Grafana Variable
> >> "underutilized_services" to find out the service names; then I 
> >> use this
> >> Variable in my Prometheus query to show the actual 
> >> CPUUtilization data for
> >> these services.
> >>
> >> I am using following Prometheus query:
> >>
> >> "*avg by
> >> (service_id)($Metric{service_id=~"$underutilized_services"})*"
> >>
> >> and $underutilized_services" is a list of service names, like 
> >> service1,
> >> service2...
> >>
> >> It is working well when the $underutilized_services is not 
> >> empty,
> >> like folllwing (first graph)
> >>
> >> But if the $underutilized_services is empty, then my 
> >> understanding is
> >> that it should now "No Data", but somehow it is showing 
> >> something wired,
> >> like following (second graph).
> >>
> >> If you look at the legend of the second graph, it shows:
> >>
> >> "*avg by
> >> (service_id)(aws_ec2_cpuutilization_p50{service_id=~"()"})*"
> >>
> >> It looks like above query actually returns some value, 
> >> which in my
> >> opinion it shouldn't.
> >>
> >> This is showing some confusing data for my 
> >> customer. Ideally it
> >> should show "No Data" in the second case.
> >>
> >> Is there a bug in Prometheus? Or I am not using the 
> >> query correctly?
> >>
> >>
>
>
>

-- 
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/f86fc482-493b-4594-9816-d972f6d644cdn%40googlegroups.com.

Reply via email to