mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
* Remove task labels from Docker Swarm SD (#9187) Signed-off-by: Ujjwal Goyal <importujjwal@gmail.com> Add container labels to Docker Swarm SD (#9187) Signed-off-by: Ujjwal Goyal <importujjwal@gmail.com> * Reorder labels in configuration doc Signed-off-by: Ujjwal Goyal <importujjwal@gmail.com>
This commit is contained in:
parent
097b359b41
commit
9e7ae4d963
|
@ -28,14 +28,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
swarmLabelTaskPrefix = swarmLabel + "task_"
|
swarmLabelTaskPrefix = swarmLabel + "task_"
|
||||||
swarmLabelTaskID = swarmLabelTaskPrefix + "id"
|
swarmLabelTaskID = swarmLabelTaskPrefix + "id"
|
||||||
swarmLabelTaskLabelPrefix = swarmLabelTaskPrefix + "label_"
|
swarmLabelTaskDesiredState = swarmLabelTaskPrefix + "desired_state"
|
||||||
swarmLabelTaskDesiredState = swarmLabelTaskPrefix + "desired_state"
|
swarmLabelTaskStatus = swarmLabelTaskPrefix + "state"
|
||||||
swarmLabelTaskStatus = swarmLabelTaskPrefix + "state"
|
swarmLabelTaskContainerID = swarmLabelTaskPrefix + "container_id"
|
||||||
swarmLabelTaskContainerID = swarmLabelTaskPrefix + "container_id"
|
swarmLabelTaskSlot = swarmLabelTaskPrefix + "slot"
|
||||||
swarmLabelTaskSlot = swarmLabelTaskPrefix + "slot"
|
swarmLabelTaskPortMode = swarmLabelTaskPrefix + "port_publish_mode"
|
||||||
swarmLabelTaskPortMode = swarmLabelTaskPrefix + "port_publish_mode"
|
swarmLabelContainerLabelPrefix = swarmLabel + "container_label_"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *Discovery) refreshTasks(ctx context.Context) ([]*targetgroup.Group, error) {
|
func (d *Discovery) refreshTasks(ctx context.Context) ([]*targetgroup.Group, error) {
|
||||||
|
@ -75,9 +75,11 @@ func (d *Discovery) refreshTasks(ctx context.Context) ([]*targetgroup.Group, err
|
||||||
commonLabels[swarmLabelTaskContainerID] = s.Status.ContainerStatus.ContainerID
|
commonLabels[swarmLabelTaskContainerID] = s.Status.ContainerStatus.ContainerID
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range s.Labels {
|
if s.Spec.ContainerSpec != nil {
|
||||||
ln := strutil.SanitizeLabelName(k)
|
for k, v := range s.Spec.ContainerSpec.Labels {
|
||||||
commonLabels[swarmLabelTaskLabelPrefix+ln] = v
|
ln := strutil.SanitizeLabelName(k)
|
||||||
|
commonLabels[swarmLabelContainerLabelPrefix+ln] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range serviceLabels[s.ServiceID] {
|
for k, v := range serviceLabels[s.ServiceID] {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -792,10 +792,10 @@ created using the `port` parameter defined in the SD configuration.
|
||||||
|
|
||||||
Available meta labels:
|
Available meta labels:
|
||||||
|
|
||||||
|
* `__meta_dockerswarm_container_label_<labelname>`: each label of the container
|
||||||
* `__meta_dockerswarm_task_id`: the id of the task
|
* `__meta_dockerswarm_task_id`: the id of the task
|
||||||
* `__meta_dockerswarm_task_container_id`: the container id of the task
|
* `__meta_dockerswarm_task_container_id`: the container id of the task
|
||||||
* `__meta_dockerswarm_task_desired_state`: the desired state of the task
|
* `__meta_dockerswarm_task_desired_state`: the desired state of the task
|
||||||
* `__meta_dockerswarm_task_label_<labelname>`: each label of the task
|
|
||||||
* `__meta_dockerswarm_task_slot`: the slot of the task
|
* `__meta_dockerswarm_task_slot`: the slot of the task
|
||||||
* `__meta_dockerswarm_task_state`: the state of the task
|
* `__meta_dockerswarm_task_state`: the state of the task
|
||||||
* `__meta_dockerswarm_task_port_publish_mode`: the publish mode of the task port
|
* `__meta_dockerswarm_task_port_publish_mode`: the publish mode of the task port
|
||||||
|
|
Loading…
Reference in a new issue