mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/graphite: remove duplicate name
tag from /tags/autoComplete/tags
handler
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/942
This commit is contained in:
parent
82972a8f2a
commit
007dbf273d
2 changed files with 20 additions and 2 deletions
|
@ -485,11 +485,18 @@ func GetGraphiteTags(filter string, limit int, deadline searchutils.Deadline) ([
|
|||
}
|
||||
// Substitute "__name__" with "name" for Graphite compatibility
|
||||
for i := range labels {
|
||||
if labels[i] == "__name__" {
|
||||
if labels[i] != "__name__" {
|
||||
continue
|
||||
}
|
||||
// Prevent from duplicate `name` tag.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/942
|
||||
if hasString(labels, "name") {
|
||||
labels = append(labels[:i], labels[i+1:]...)
|
||||
} else {
|
||||
labels[i] = "name"
|
||||
sort.Strings(labels)
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
if len(filter) > 0 {
|
||||
labels, err = applyGraphiteRegexpFilter(filter, labels)
|
||||
|
@ -503,6 +510,15 @@ func GetGraphiteTags(filter string, limit int, deadline searchutils.Deadline) ([
|
|||
return labels, nil
|
||||
}
|
||||
|
||||
func hasString(a []string, s string) bool {
|
||||
for _, x := range a {
|
||||
if x == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GetLabels returns labels until the given deadline.
|
||||
func GetLabels(deadline searchutils.Deadline) ([]string, error) {
|
||||
if deadline.Exceeded() {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
Though [InfluxDB line protocol](https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_tutorial/) denies multiple whitespace chars between these entities,
|
||||
some apps improperly put multiple whitespace chars. This workaround allows accepting data from such apps.
|
||||
|
||||
* BUGFIX: prevent from duplicate `name` tag returned from `/tags/autoComplete/tags` handler. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/942
|
||||
|
||||
|
||||
# [v1.49.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.49.0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue