mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discovery/dockerswarm: fix query encoding of filters (#3586)
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
1d16cc9349
commit
99f9b02283
3 changed files with 13 additions and 10 deletions
|
@ -29,6 +29,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
* BUGFIX: properly parse floating-point numbers without integer or fractional parts such as `.123` and `20.` during [data import](https://docs.victoriametrics.com/#how-to-import-time-series-data). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544).
|
* BUGFIX: properly parse floating-point numbers without integer or fractional parts such as `.123` and `20.` during [data import](https://docs.victoriametrics.com/#how-to-import-time-series-data). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544).
|
||||||
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly parse durations with uppercase suffixes such as `10S`, `5MS`, `1W`, etc. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3589).
|
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly parse durations with uppercase suffixes such as `10S`, `5MS`, `1W`, etc. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3589).
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic during target discovery when `vmagent` runs with `-promscrape.dropOriginalLabels` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3580). The bug has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850).
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic during target discovery when `vmagent` runs with `-promscrape.dropOriginalLabels` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3580). The bug has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850).
|
||||||
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): [dockerswarm_sd_configs](https://docs.victoriametrics.com/sd_configs.html#dockerswarm_sd_configs): properly encode `filters` field. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3579)
|
||||||
|
|
||||||
|
|
||||||
## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3)
|
## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3)
|
||||||
|
|
|
@ -63,20 +63,16 @@ func (cfg *apiConfig) getAPIResponse(path string) ([]byte, error) {
|
||||||
return cfg.client.GetAPIResponse(path)
|
return cfg.client.GetAPIResponse(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Encodes filters as `map[string][]string` and then marshals it to JSON.
|
||||||
|
// Reference: https://docs.docker.com/engine/api/v1.41/#tag/Task
|
||||||
func getFiltersQueryArg(filters []Filter) string {
|
func getFiltersQueryArg(filters []Filter) string {
|
||||||
if len(filters) == 0 {
|
if len(filters) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
m := make(map[string]map[string]bool)
|
|
||||||
|
m := make(map[string][]string)
|
||||||
for _, f := range filters {
|
for _, f := range filters {
|
||||||
x := m[f.Name]
|
m[f.Name] = f.Values
|
||||||
if x == nil {
|
|
||||||
x = make(map[string]bool)
|
|
||||||
m[f.Name] = x
|
|
||||||
}
|
|
||||||
for _, value := range f.Values {
|
|
||||||
x[value] = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buf, err := json.Marshal(m)
|
buf, err := json.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -22,5 +22,11 @@ func TestGetFiltersQueryArg(t *testing.T) {
|
||||||
Name: "xxx",
|
Name: "xxx",
|
||||||
Values: []string{"aa"},
|
Values: []string{"aa"},
|
||||||
},
|
},
|
||||||
}, "%7B%22name%22%3A%7B%22bar%22%3Atrue%2C%22foo%22%3Atrue%7D%2C%22xxx%22%3A%7B%22aa%22%3Atrue%7D%7D")
|
}, "%7B%22name%22%3A%5B%22foo%22%2C%22bar%22%5D%2C%22xxx%22%3A%5B%22aa%22%5D%7D")
|
||||||
|
f([]Filter{
|
||||||
|
{
|
||||||
|
Name: "desired-state",
|
||||||
|
Values: []string{"running", "shutdown"},
|
||||||
|
},
|
||||||
|
}, "%7B%22desired-state%22%3A%5B%22running%22%2C%22shutdown%22%5D%7D")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue