mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
lib/promscrape/discovery/dockerswarm: properly set __meta_dockerswarm_container_label_* labels instead of __meta_dockerswarm_task_label_* labels
See https://github.com/prometheus/prometheus/issues/9187
This commit is contained in:
parent
708f1e8048
commit
3764ba98a5
3 changed files with 25 additions and 12 deletions
|
@ -17,6 +17,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
|
|
||||||
* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): fix potential panic in [multi-level cluster setup](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multi-level-cluster-setup) when top-level `vmselect` is configured with `-replicationFactor` bigger than 1. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2961).
|
* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): fix potential panic in [multi-level cluster setup](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multi-level-cluster-setup) when top-level `vmselect` is configured with `-replicationFactor` bigger than 1. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2961).
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly handle custom `endpoint` value in [ec2_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config). It was ignored since [v1.77.0](https://docs.victoriametrics.com/CHANGELOG.html#v1770) because of a bug in the implementation of [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1287).
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly handle custom `endpoint` value in [ec2_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config). It was ignored since [v1.77.0](https://docs.victoriametrics.com/CHANGELOG.html#v1770) because of a bug in the implementation of [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1287).
|
||||||
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): [dockerswarm_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dockerswarm_sd_config): properly set `__meta_dockerswarm_container_label_*` labels instead of `__meta_dockerswarm_task_label_*` labels as Prometheus does. See [this issue](https://github.com/prometheus/prometheus/issues/9187).
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): set `up` metric to `0` for partial scrapes in [stream parsing mode](https://docs.victoriametrics.com/vmagent.html#stream-parsing-mode). Previously the `up` metric was set to `1` when at least a single metric has been scraped before the error. This aligns the behaviour of `vmselect` with Prometheus.
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): set `up` metric to `0` for partial scrapes in [stream parsing mode](https://docs.victoriametrics.com/vmagent.html#stream-parsing-mode). Previously the `up` metric was set to `1` when at least a single metric has been scraped before the error. This aligns the behaviour of `vmselect` with Prometheus.
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): restart all the scrape jobs during [config reload](https://docs.victoriametrics.com/vmagent.html#configuration-update) after `global` section is changed inside `-promscrape.config`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2884).
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): restart all the scrape jobs during [config reload](https://docs.victoriametrics.com/vmagent.html#configuration-update) after `global` section is changed inside `-promscrape.config`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2884).
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly assume role with AWS ECS credentials. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2875). Thanks to @transacid for [the fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2876).
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly assume role with AWS ECS credentials. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2875). Thanks to @transacid for [the fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2876).
|
||||||
|
|
|
@ -15,7 +15,6 @@ type task struct {
|
||||||
ID string
|
ID string
|
||||||
ServiceID string
|
ServiceID string
|
||||||
NodeID string
|
NodeID string
|
||||||
Labels map[string]string
|
|
||||||
DesiredState string
|
DesiredState string
|
||||||
NetworksAttachments []struct {
|
NetworksAttachments []struct {
|
||||||
Addresses []string
|
Addresses []string
|
||||||
|
@ -32,6 +31,11 @@ type task struct {
|
||||||
Ports []portConfig
|
Ports []portConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Spec struct {
|
||||||
|
ContainerSpec struct {
|
||||||
|
Labels map[string]string
|
||||||
|
}
|
||||||
|
}
|
||||||
Slot int
|
Slot int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +86,8 @@ func addTasksLabels(tasks []task, nodesLabels, servicesLabels []map[string]strin
|
||||||
"__meta_dockerswarm_task_slot": strconv.Itoa(task.Slot),
|
"__meta_dockerswarm_task_slot": strconv.Itoa(task.Slot),
|
||||||
"__meta_dockerswarm_task_state": task.Status.State,
|
"__meta_dockerswarm_task_state": task.Status.State,
|
||||||
}
|
}
|
||||||
for k, v := range task.Labels {
|
for k, v := range task.Spec.ContainerSpec.Labels {
|
||||||
commonLabels["__meta_dockerswarm_task_label_"+discoveryutils.SanitizeLabelName(k)] = v
|
commonLabels["__meta_dockerswarm_container_label_"+discoveryutils.SanitizeLabelName(k)] = v
|
||||||
}
|
}
|
||||||
var svcPorts []portConfig
|
var svcPorts []portConfig
|
||||||
for i, v := range services {
|
for i, v := range services {
|
||||||
|
|
|
@ -27,13 +27,13 @@ func Test_parseTasks(t *testing.T) {
|
||||||
"Version": {
|
"Version": {
|
||||||
"Index": 23
|
"Index": 23
|
||||||
},
|
},
|
||||||
"Labels": {
|
|
||||||
"label1": "value1"
|
|
||||||
},
|
|
||||||
"Spec": {
|
"Spec": {
|
||||||
"ContainerSpec": {
|
"ContainerSpec": {
|
||||||
"Image": "redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842",
|
"Image": "redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842",
|
||||||
"Init": false
|
"Init": false,
|
||||||
|
"Labels": {
|
||||||
|
"label1": "value1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Resources": {
|
"Resources": {
|
||||||
"Limits": {},
|
"Limits": {},
|
||||||
|
@ -70,8 +70,18 @@ func Test_parseTasks(t *testing.T) {
|
||||||
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
||||||
ServiceID: "t91nf284wzle1ya09lqvyjgnq",
|
ServiceID: "t91nf284wzle1ya09lqvyjgnq",
|
||||||
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
||||||
Labels: map[string]string{
|
Spec: struct {
|
||||||
"label1": "value1",
|
ContainerSpec struct {
|
||||||
|
Labels map[string]string
|
||||||
|
}
|
||||||
|
}{
|
||||||
|
ContainerSpec: struct {
|
||||||
|
Labels map[string]string
|
||||||
|
}{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"label1": "value1",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
DesiredState: "running",
|
DesiredState: "running",
|
||||||
Slot: 1,
|
Slot: 1,
|
||||||
|
@ -97,7 +107,7 @@ func Test_parseTasks(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("parseTasks() got = %v, want %v", got, tt.want)
|
t.Errorf("parseTasks() got\n%v\nwant\n%v", got, tt.want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -126,7 +136,6 @@ func Test_addTasksLabels(t *testing.T) {
|
||||||
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
||||||
ServiceID: "t91nf284wzle1ya09lqvyjgnq",
|
ServiceID: "t91nf284wzle1ya09lqvyjgnq",
|
||||||
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
||||||
Labels: map[string]string{},
|
|
||||||
DesiredState: "running",
|
DesiredState: "running",
|
||||||
Slot: 1,
|
Slot: 1,
|
||||||
Status: struct {
|
Status: struct {
|
||||||
|
@ -194,7 +203,6 @@ func Test_addTasksLabels(t *testing.T) {
|
||||||
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
ID: "t4rdm7j2y9yctbrksiwvsgpu5",
|
||||||
ServiceID: "tgsci5gd31aai3jyudv98pqxf",
|
ServiceID: "tgsci5gd31aai3jyudv98pqxf",
|
||||||
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
NodeID: "qauwmifceyvqs0sipvzu8oslu",
|
||||||
Labels: map[string]string{},
|
|
||||||
DesiredState: "running",
|
DesiredState: "running",
|
||||||
Slot: 1,
|
Slot: 1,
|
||||||
NetworksAttachments: []struct {
|
NetworksAttachments: []struct {
|
||||||
|
|
Loading…
Reference in a new issue