Timeseries: Gauge Type
Time Range: 30 Days
Data Source: Mimir
Visualization: Stat
Current PromQL: quantile_over_time(.95,sdwan_edge_bps_total{serviceId="$ServiceId"}[30d])
Context:
As you can see on the Stat panel Area (the actual data points it goes up and down).
It seems like the promql I did gets the 95th percentile of the linear data. it doesn’t sort the data from lowest to highest.
sort() doesn’t work in grafana as well within the promql
Expected Result:
get the 95th percentile of the data (sorted from lowest to highest)
Question:
Is there a proper PromQL statement I can use?
or
Is there a way to use Transformation in Grafana, to Sort the timeseries. then get the 95th percentile
or
Is there a promql statement where I can get the nth record
for example:
timeseries name: stat_a
number of data: 100
index number: 95
stat_a[index number]
then I will get that particular index (I’ll just use some math functions to like get the 95th row based on the record count within 30days)
Yeah I think you can use Grafana to sort the time series data in ascending or descending order by using the sort by transformation (I think…). Once the data is sorted, you can run your query.
Try with and without the sort_desc or sort function, I wanna know how it goes with.
btw, the reason I’m saying it’s displaying wrong value. When I export the data in Excel (CSV), and tried to manually calculate the 95th percentile, it’s showing different result than what it is showing in grafana
also, here’s a better view of the result using grafana’s explore feature
Yeah my bad I forgot to remove the sort function haha
I noticed in your value via CSV that the timestamp are really not the same between 1 percentile and 0.95 percentile. Can you check if that’s normal?
I also saw that in the 0.95th percentile the data looks sorted from highest to lowest and the opposite for the 1th percentile. Which, indeed will show a decreasing graph…
There is your issue: excel, when importing data into it esp numbers and dates it has the reputation of munging and taking over data.
Please share a sample of the data you exported to excel
don’t worry about this guys. Since I can’t make this work with a simple promql query, I just used a different visualization (Dynamic Text Panel), went back to being a dev and wrote a code to get the percentile. added some additional info as well (Percentage used against total speed)
now, it’s having the same result as manual testing via excel
For future reference, I think it’s better if you have histogram data instead of gauge, then you can use the default stats panel and use histogram_quantile(.95, metric) for the promql statement.
For anyone who is using the same setup as I did. Timeseries (Gauge)