Skip to content

Commit

Permalink
feat: sort prometheus export tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lzf575 authored and taloric committed Oct 17, 2024
1 parent 83987a8 commit 361c1a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/ingester/flow_metrics/unmarshaller/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package unmarshaller
import (
"fmt"
"reflect"
"sort"
"strings"
"time"
"unsafe"
Expand Down Expand Up @@ -252,11 +253,15 @@ func EncodeToPrometheus(e app.Document, utags *utag.UniversalTagsManager, cfg *c

ts := prompb.TimeSeries{}
ts.Labels = make([]prompb.Label, 0, len(labels)+1)
ts.Labels = append(ts.Labels, labels...)
ts.Labels = append(ts.Labels, prompb.Label{
Name: "__name__",
Value: structTags.Name,
})
ts.Labels = append(ts.Labels, labels...)
sort.Slice(ts.Labels, func(i, j int) bool {
return ts.Labels[i].Name < ts.Labels[j].Name
})

ts.Samples = make([]prompb.Sample, 1)
ts.Samples[0].Value = valueFloat64
ts.Samples[0].Timestamp = int64(e.Time()) * 1000 // convert to ms
Expand Down

0 comments on commit 361c1a4

Please sign in to comment.