You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The gather method of Registry currently emits the gathered metrics ordered by their label values sorted lexicographically (code):
gather calls the Collect method of the registered Collectors and then gathers the collected metrics into a lexicographically sorted slice of MetricFamily protobufs.
If I understand correctly, the legend in Grafana will order the series in the order they're emitted by Prometheus?
If so, it could greatly improve readability if labels could be sorted by natural order, i.e.
node-1
node-2
...
node-10
rather than the lexicographic order
node-1
node-10
node-2
...
Describe the solution you'd like
Options, ordered by my preferences:
Add a switch/option to gather to opt into natural ordering.
Allow support for passing a custom sorting function. On the one hand there are also only so many reasonable ways to sort strings that it might seem like overkill. But it also allows users to decide for themselves what library to use - and mean that this library doesn't need to ship nor depend on one. And one could of course also imagine esoteric use cases like sorting by Roman numerals or whatever.
Use natural ordering by default (with or without option to use lexicographic). I would do this for a new project, but changing existing default behavior might be undesired.
Describe alternatives you've considered
Post-sort the Vec<proto::MetricFamily> returned by gather. This is too hacky to see the light of day.
Additional context
None.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The
gather
method ofRegistry
currently emits the gathered metrics ordered by their label values sorted lexicographically (code):If I understand correctly, the legend in Grafana will order the series in the order they're emitted by Prometheus?
If so, it could greatly improve readability if labels could be sorted by natural order, i.e.
rather than the lexicographic order
Describe the solution you'd like
Options, ordered by my preferences:
gather
to opt into natural ordering.Describe alternatives you've considered
Post-sort the
Vec<proto::MetricFamily>
returned bygather
. This is too hacky to see the light of day.Additional context
None.
The text was updated successfully, but these errors were encountered: