fix: sort labels in prometheusremotewrite serializer (#11755)
This commit is contained in:
parent
15c7bc51f1
commit
872963aee6
|
|
@ -339,5 +339,11 @@ func getPromTS(name string, labels []prompb.Label, value float64, ts time.Time)
|
|||
Name: "__name__",
|
||||
Value: name,
|
||||
})
|
||||
|
||||
// we sort the labels since Prometheus TSDB does not like out of order labels
|
||||
sort.Slice(labels, func(i, j int) bool {
|
||||
return labels[i].Name < labels[j].Name
|
||||
})
|
||||
|
||||
return MakeMetricKey(labels), prompb.TimeSeries{Labels: labels, Samples: sample}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -582,16 +582,16 @@ cpu_time_idle{host_name="example.org"} 42
|
|||
},
|
||||
expected: []byte(`
|
||||
cpu_time_guest{cpu="cpu0"} 8106.04
|
||||
cpu_time_system{cpu="cpu0"} 26271.4
|
||||
cpu_time_user{cpu="cpu0"} 92904.33
|
||||
cpu_time_guest{cpu="cpu1"} 8181.63
|
||||
cpu_time_system{cpu="cpu1"} 25351.49
|
||||
cpu_time_user{cpu="cpu1"} 96912.57
|
||||
cpu_time_guest{cpu="cpu2"} 7470.04
|
||||
cpu_time_system{cpu="cpu2"} 24998.43
|
||||
cpu_time_user{cpu="cpu2"} 96034.08
|
||||
cpu_time_guest{cpu="cpu3"} 7517.95
|
||||
cpu_time_system{cpu="cpu0"} 26271.4
|
||||
cpu_time_system{cpu="cpu1"} 25351.49
|
||||
cpu_time_system{cpu="cpu2"} 24998.43
|
||||
cpu_time_system{cpu="cpu3"} 24970.82
|
||||
cpu_time_user{cpu="cpu0"} 92904.33
|
||||
cpu_time_user{cpu="cpu1"} 96912.57
|
||||
cpu_time_user{cpu="cpu2"} 96034.08
|
||||
cpu_time_user{cpu="cpu3"} 94148
|
||||
`),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue