Skip to content

Commit

Permalink
feat: handle sorting in config side
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Sep 26, 2023
1 parent 959b238 commit 6f36276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ func (r *Rest) HandleResults(result []gjson.Result, prop *prop, isEndPoint bool)
labelString := r.String()
labelArray = append(labelArray, labelString)
}
sort.Strings(labelArray)
instance.SetLabel(display, strings.Join(labelArray, ","))
} else {
instance.SetLabel(display, value.String())
Expand Down
4 changes: 3 additions & 1 deletion cmd/collectors/zapi/collector/zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ func (z *Zapi) PollData() (map[string]*matrix.Matrix, error) {
// Handling array with comma separated values
previousValue := instance.GetLabel(label)
if isAppend && previousValue != "" {
instance.SetLabel(label, previousValue+","+value)
currentVal := strings.Split(previousValue+","+value, ",")
sort.Strings(currentVal)
instance.SetLabel(label, strings.Join(currentVal, ","))
z.Logger.Trace().Msgf(" > %slabel (%s) [%s] set value (%s)%s", color.Yellow, key, label, instance.GetLabel(label)+","+value, color.End)
} else {
instance.SetLabel(label, value)
Expand Down

0 comments on commit 6f36276

Please sign in to comment.