On Thursday, 7 May 2020 17:54:47 UTC+1, piyush sharma wrote:
>
> Hey 
>
> I have a query like this 
>
> if  sum by (locale) ( expression1)/sum by (locale) ( expression2) >=0
>
> This gives me no data points and hence a broken graph 
>
>
Looks like a reasonable expression (without the "if" on the front).  Always 
check operator precedence 
<https://prometheus.io/docs/prometheus/latest/querying/operators/#binary-operator-precedence>
 
(or add extra parentheses), but that looks OK: "/" binds more tightly than 
">="

The way I'd recommend debugging this is to run the two parts of the query 
separately in the PromQL web interface:

sum by (locale) ( expression1)
sum by (locale) ( expression2)

Use the "console" view.  Check if these two sub-expressions both generate 
results.  Check if they both have the same set of labels - which of course 
should be "locale" in this case - because a bare "/" will only combine LHS 
and RHS values with exactly the same label set.

If you want further help, you should show your *actual* query expression, 
and some examples of the *actual* metrics you are working on (complete with 
labels and values).  The Console view in prometheus' expression interface 
can help you do this.

 

> sum_over_time did not work in this case as it does not take the "by" 
> option 
> Any way I can re write this ... can I make it avg of sum by locale or 
> something like that ?
>
>
Well, you've not described in concrete terms what you're trying to achieve, 
nor what the input data looks like.

avg_over_time needs a range vector as its input: this is two-dimensional.  
It has a bunch of time series, and each timeseries has multiple data points 
at different times.  I mentioned before how to make a range vector out of 
an instant vector.

"sum" and "sum by" works over the seires dimension (i.e. combining values 
at the same time, but taken from different timeseries, meaning with 
different labels).

"sum_over_time" works over the time dimension, and sums separately for each 
timeseries.  "by" makes no sense with this, because each sum is across the 
same timeseries - in other words, every point being summed has the same set 
of labels.

-- 
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 prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/5057f221-f67c-48fe-a33a-a6f31e6c0581%40googlegroups.com.

Reply via email to