-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gauge & Bar Gauge & Stat Panel should have option to sort each series #17245
Comments
We do not want to add sorting to each visualization as this is something better done in your query. We are looking at adding a data transform layer between query results and visualization and sorting could possibly go there |
Prometheus can only sort by value and it can't sort by label name. |
@torkelo |
Sort should be done in the query |
I can see that more visualizations would benefit from this, when can we expect this transform layer to be implemented? |
in next 3-5 months |
ETA? :) |
Only seems to happen for Prometheus datasource when you
A simpler query doesn't produce the re-ordering every page reload:
|
Some datasources don't support order (ex. stackdriver). That will be nice to order bar depending of the value. My use case is to order by the oldest message in pubsub subscription |
Another example of how sorting in the visualization is helpful. Here is my flux: The visualization requires I group by a field in order to properly show the data, however that creates 10 tables, and the visualization seems to display them in alphabetic by, in my case, "_field" rather in descending value order. |
Yes but even when prometheus returns a correct sorted list bar gauge does not use that sorting. So something break the sort along the way. |
@dunxiii try switching the |
This should be implemented as a sort transform using new transform feature |
Very useful feature, seems like a "sort transform" despite the datasource in use is the best approach. |
I'm using multiple data sources and applying the merge transform to combine them. |
@torkelo Right now Transform is unable to sort by value; are you saying that Transform should support sorting by value in the future? We were hoping that using |
If sort in query Grafana will use that sort order, could be that if you are using a transform like join or merge that your sort order will be lost however. But if you are not using any Transform the order is determined by the query |
@torkelo is that assuming that "Instant" is toggled to be on, or should that be true regardless of whether or not the query is regarded as "instant"? Here's a screenshot of a bar graph in Grafana 7.1.5 with no transformations applied, using the |
The prometheus sort functions only work on instant vectors, there is no series sorting |
I'd like for the bar gauge specifically to have a sort by property. The "Sort By" transformation doesn't work on data that is in multiple data frames and the bar gauge panel doesn't display data that is in a single data frame so right now I can't get both of these features to work together to get a sorted bar gauge visualization. (The table panel in conjunction with the reduce/series-to-rows transformation is a work around but it doesn't have the same dynamic display capabilities that the bar gauge panel has). |
I am currently displaying the output of an expression. It is table data, not timeseries. If there is a way to get that output sorted by value, I am not aware of it. |
you can use the Sort by transform to sort data |
There isn't an option to Sort by Value using Transform tab, and Grafana does not appear to obey the query's ORDER BY rules. |
To make clear what multiple people already have said, of course has such a sorting to be done in the Panel. Please note that the panel does perform a calculation (it even is labelled "Calculate") when it e.g. takes the "last" value of each series. So, if you want to order by that calculated value, this is the correct place to do it. |
figured it out. using sort() function in query fails silently unless you override Instant toggle to true. |
The panel is a bar gauge which lists the slowest tests overall as filtering is currently not possible. For filtering per project to work we need to introduce a new metric which has a label for every project we have. As label_values(top_failures_pct, project) is not the same as label_values(top_slowest_tests, project). The second issue is that a bar gauge can't be sorted correctly this is a Grafana limitation. grafana/grafana#17245
The panel is a bar gauge which lists the slowest tests overall as filtering is currently not possible. For filtering per project to work we need to introduce a new metric which has a label for every project we have. As label_values(top_failures_pct, project) is not the same as label_values(top_slowest_tests, project). The second issue is that a bar gauge can't be sorted correctly this is a Grafana limitation. grafana/grafana#17245
The panel is a bar gauge which lists the slowest tests overall as filtering is currently not possible. For filtering per project to work we need to introduce a new metric which has a label for every project we have. As label_values(top_failures_pct, project) is not the same as label_values(top_slowest_tests, project). The second issue is that a bar gauge can't be sorted correctly this is a Grafana limitation. grafana/grafana#17245
I tried sorting the result in the PromQL and it does sort as needed there ... but that sorting is ignored once displayed in the bar gauge in Grafana. |
@jgagnon44 strange, the Bar gauge panel does no sorting, so should display the data in the same order it's coming from the query |
Ok I find a solution : 1 - Make a Table I use grafana 10 |
Something doesn't add up. if I use |
Here is my solution. Then we can sort by the metric. {
"datasource": {
"type": "prometheus",
"uid": "cae1b9fc-5054-4994-bdcc-299ae73ca914"
},
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": {
"mode": "percentage",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "#EAB839",
"value": 90
},
{
"color": "green",
"value": 100
}
]
},
"color": {
"mode": "thresholds"
},
"decimals": 0,
"links": [
{
"targetBlank": true,
"title": "http://${__data.fields.instance}",
"url": "http://${__data.fields.instance}"
}
],
"max": 172800000,
"min": 0,
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 3,
"x": 16,
"y": 6
},
"id": 14,
"options": {
"reduceOptions": {
"values": true,
"calcs": [
"lastNotNull"
],
"fields": "/^Value$/"
},
"orientation": "horizontal",
"displayMode": "gradient",
"valueMode": "color",
"showUnfilled": true,
"minVizWidth": 0,
"minVizHeight": 10
},
"pluginVersion": "10.1.1",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "cae1b9fc-5054-4994-bdcc-299ae73ca914"
},
"editorMode": "code",
"exemplar": false,
"expr": "sysUpTime{job=\"SNMP\"}",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "__auto",
"range": false,
"refId": "A"
}
],
"title": "Switch_Uptime",
"transformations": [
{
"id": "sortBy",
"options": {
"fields": {},
"sort": [
{
"field": "Value"
}
]
}
}
],
"type": "bargauge"
} |
If you tried a sort_desc query in the Prometheus UI, it will force the query to use instant vectors. To prove this, paste that query into the Grafana panel and turn the "instant" toggle on. Refresh and you should see your results are sorted. These results should 1:1 match the results in the Prometheus UI even if you're not explicitly using instant vectors in the Prometheus UI. Toggling the "instant" toggle off in your panel, and then refreshing, would probably show more accurate values based on how your query was written verbatim. I'm frustrated that there's no functionality built into Grafana to help me sort the results of a non-instant vector query with Prometheus! It's right there, it feels so close to what I want -- but the information I really need is obscured when using instant vectors! |
In Time Series panels, users can sort interactively by name, mean, max and whatever other columns are present. It would be natural to expect similar functionality for bar graphs/gauges as well, instead of only one fixed sort order. For day-to-day operations it would e.g. be convenient to sort by max disk usage percentage, but when trying to find a specific server you might want to change to alphabetical sorting by server name. |
after trying to sort via transforms I figured out that it just works by adding Not sure why SortBy Transform didn't give me any option to sort by value. |
What would you like to be added:
Bar Guage looks very nice! It would be nice if we can sort the bar by titles and values.
Why is this needed:
The problem is that after auto refresh, the order of bars are changed.
The text was updated successfully, but these errors were encountered: