diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2c82f91e4..767efcc4b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,7 @@ The following tip changes can be tested by building VictoriaMetrics components f ## v1.79.x long-time support release (LTS) +* 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) * BUGFIX: allow specifying values bigger than 2GiB to the following command-line flag values on 32-bit architectures (`386` and `arm`): `-storage.minFreeDiskSpaceBytes` and `-remoteWrite.maxDiskUsagePerURL`. Previously values bigger than 2GiB were incorrectly truncated on these architectures. * BUGFIX: [VictoriaMetrics enterprise](https://docs.victoriametrics.com/enterprise.html): expose proper values for `vm_downsampling_partitions_scheduled` and `vm_downsampling_partitions_scheduled_size_bytes` metrics, which were added at [v1.78.0](https://docs.victoriametrics.com/CHANGELOG.html#v1780). See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2612). * BUGFIX: [DataDog protocol parser](https://docs.victoriametrics.com/#how-to-send-data-from-datadog-agent): do not re-use `host` and `device` fields from the previously parsed messages if these fields are missing in the currently parsed message. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3432). diff --git a/lib/promscrape/discovery/dockerswarm/api.go b/lib/promscrape/discovery/dockerswarm/api.go index d0bb79cef..35d2ab974 100644 --- a/lib/promscrape/discovery/dockerswarm/api.go +++ b/lib/promscrape/discovery/dockerswarm/api.go @@ -63,20 +63,16 @@ func (cfg *apiConfig) getAPIResponse(path string) ([]byte, error) { 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 { if len(filters) == 0 { return "" } - m := make(map[string]map[string]bool) + + m := make(map[string][]string) for _, f := range filters { - x := m[f.Name] - if x == nil { - x = make(map[string]bool) - m[f.Name] = x - } - for _, value := range f.Values { - x[value] = true - } + m[f.Name] = f.Values } buf, err := json.Marshal(m) if err != nil { diff --git a/lib/promscrape/discovery/dockerswarm/api_test.go b/lib/promscrape/discovery/dockerswarm/api_test.go index fc8888ee5..114ec43a4 100644 --- a/lib/promscrape/discovery/dockerswarm/api_test.go +++ b/lib/promscrape/discovery/dockerswarm/api_test.go @@ -22,5 +22,11 @@ func TestGetFiltersQueryArg(t *testing.T) { Name: "xxx", 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") }