openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
168 stars 54 forks source link

Sort prometheus labels in accordance with the prometheus spec #406

Closed alibresco closed 4 months ago

alibresco commented 4 months ago

Currently, the gnmic prometheus output does not sort labels lexicographically before sending them out the door.

This is required by the prometheus remote write spec:

MUST have label names sorted in lexicographical order.

It's unclear how all implementations of prometheus remote write targets handle the unsorted labels. In at least some, it can lead to issues with correctness or sharding efficiency.

I have made the fix and added a test.

karimra commented 4 months ago

Thanks for the contribution!