mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Docker Swarm SD: Support tasks and service without published ports (#7686)
* Support tasks and service without published ports Mimics k8s discovery behaviour. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
04b028f1e6
commit
924e7239b7
|
@ -57,42 +57,68 @@ func (d *Discovery) refreshServices(ctx context.Context) ([]*targetgroup.Group,
|
|||
}
|
||||
|
||||
for _, s := range services {
|
||||
for _, e := range s.Endpoint.Ports {
|
||||
if e.Protocol != swarm.PortConfigProtocolTCP {
|
||||
continue
|
||||
commonLabels := map[string]string{
|
||||
swarmLabelServiceID: s.ID,
|
||||
swarmLabelServiceName: s.Spec.Name,
|
||||
swarmLabelServiceTaskContainerHostname: s.Spec.TaskTemplate.ContainerSpec.Hostname,
|
||||
swarmLabelServiceTaskContainerImage: s.Spec.TaskTemplate.ContainerSpec.Image,
|
||||
}
|
||||
commonLabels[swarmLabelServiceMode] = getServiceValueMode(s)
|
||||
|
||||
if s.UpdateStatus != nil {
|
||||
commonLabels[swarmLabelServiceUpdatingStatus] = string(s.UpdateStatus.State)
|
||||
}
|
||||
|
||||
for k, v := range s.Spec.Labels {
|
||||
ln := strutil.SanitizeLabelName(k)
|
||||
commonLabels[swarmLabelServiceLabelPrefix+ln] = v
|
||||
}
|
||||
|
||||
for _, p := range s.Endpoint.VirtualIPs {
|
||||
var added bool
|
||||
ip, _, err := net.ParseCIDR(p.Addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while parsing address %s: %w", p.Addr, err)
|
||||
}
|
||||
for _, p := range s.Endpoint.VirtualIPs {
|
||||
|
||||
for _, e := range s.Endpoint.Ports {
|
||||
if e.Protocol != swarm.PortConfigProtocolTCP {
|
||||
continue
|
||||
}
|
||||
labels := model.LabelSet{
|
||||
swarmLabelServiceEndpointPortName: model.LabelValue(e.Name),
|
||||
swarmLabelServiceEndpointPortPublishMode: model.LabelValue(e.PublishMode),
|
||||
swarmLabelServiceID: model.LabelValue(s.ID),
|
||||
swarmLabelServiceName: model.LabelValue(s.Spec.Name),
|
||||
swarmLabelServiceTaskContainerHostname: model.LabelValue(s.Spec.TaskTemplate.ContainerSpec.Hostname),
|
||||
swarmLabelServiceTaskContainerImage: model.LabelValue(s.Spec.TaskTemplate.ContainerSpec.Image),
|
||||
}
|
||||
|
||||
labels[swarmLabelServiceMode] = model.LabelValue(getServiceValueMode(s))
|
||||
|
||||
if s.UpdateStatus != nil {
|
||||
labels[swarmLabelServiceUpdatingStatus] = model.LabelValue(s.UpdateStatus.State)
|
||||
for k, v := range commonLabels {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
for k, v := range s.Spec.Labels {
|
||||
ln := strutil.SanitizeLabelName(k)
|
||||
labels[model.LabelName(swarmLabelServiceLabelPrefix+ln)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
ip, _, err := net.ParseCIDR(p.Addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while parsing address %s: %w", p.Addr, err)
|
||||
}
|
||||
addr := net.JoinHostPort(ip.String(), strconv.FormatUint(uint64(e.PublishedPort), 10))
|
||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||
|
||||
for k, v := range networkLabels[p.NetworkID] {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
addr := net.JoinHostPort(ip.String(), strconv.FormatUint(uint64(e.PublishedPort), 10))
|
||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||
|
||||
tg.Targets = append(tg.Targets, labels)
|
||||
added = true
|
||||
}
|
||||
|
||||
if !added {
|
||||
labels := model.LabelSet{}
|
||||
|
||||
for k, v := range commonLabels {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
for k, v := range networkLabels[p.NetworkID] {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
addr := net.JoinHostPort(ip.String(), fmt.Sprintf("%d", d.port))
|
||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||
|
||||
tg.Targets = append(tg.Targets, labels)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ host: %s
|
|||
tg := tgs[0]
|
||||
testutil.Assert(t, tg != nil, "tg should not be nil")
|
||||
testutil.Assert(t, tg.Targets != nil, "tg.targets should not be nil")
|
||||
testutil.Equals(t, 10, len(tg.Targets))
|
||||
testutil.Equals(t, 15, len(tg.Targets))
|
||||
|
||||
for i, lbls := range []model.LabelSet{
|
||||
{
|
||||
|
@ -65,8 +65,8 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("3qvd7bwfptmoht16t1f7jllb6"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-node-exporter:v0.16.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_node-exporter"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_node-exporter"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-node-exporter:v0.16.0@sha256:1d2518ec0501dd848e718bf008df37852b1448c862d6f256f2d39244975758d6"),
|
||||
},
|
||||
|
@ -83,11 +83,75 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("3qvd7bwfptmoht16t1f7jllb6"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-node-exporter:v0.16.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_node-exporter"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_node-exporter"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-node-exporter:v0.16.0@sha256:1d2518ec0501dd848e718bf008df37852b1448c862d6f256f2d39244975758d6"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.34:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("9bbq7j55tzzz85k2gg52x73rg"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("cloudflare/unsee:v0.8.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_unsee"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("cloudflare/unsee:v0.8.0@sha256:28398f47f63feb1647887999701fa730da351fc6d3cc7228e5da44b40a663ada"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.13:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("hv645udwaaewyw7wuc6nspm68"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-prometheus:v2.5.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_prometheus"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-prometheus:v2.5.0@sha256:f1a3781c4785637ba088dcf54889f77d9b6b69f21b2c0a167c1347473f4e2587"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.23:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("iml8vdd2dudvq457sbirpf66z"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("google/cadvisor"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_cadvisor"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("google/cadvisor:latest@sha256:815386ebbe9a3490f38785ab11bda34ec8dacf4634af77b8912832d4f85dca04"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.31:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("rl4jhdws3r4lkfvq8kx6c4xnr"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-alertmanager:v0.14.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_alertmanager"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-alertmanager:v0.14.0@sha256:7069b656bd5df0606ff1db81a7553a25dc72be51d3aca6a7e08d776566cefbd8"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.13:9090"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
|
@ -100,8 +164,42 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.13:9093"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_endpoint_port_name": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_endpoint_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.13:9094"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_endpoint_port_name": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_endpoint_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
|
@ -118,25 +216,8 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.13:9093"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_endpoint_port_name": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_endpoint_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
|
@ -153,25 +234,8 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.13:9094"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_endpoint_port_name": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_endpoint_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
|
@ -188,8 +252,8 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
|
@ -205,8 +269,8 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("uk9su5tb9ykfzew3qtmp14uzh"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-grafana:5.3.4"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_grafana"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_grafana"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-grafana:5.3.4@sha256:2aca8aa5716e6e0eed3fcdc88fec256a0a1828c491a8cf240486ae7cc473092d"),
|
||||
},
|
||||
|
@ -223,11 +287,27 @@ host: %s
|
|||
"__meta_dockerswarm_service_id": model.LabelValue("uk9su5tb9ykfzew3qtmp14uzh"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-grafana:5.3.4"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_grafana"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_grafana"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/swarmprom-grafana:5.3.4@sha256:2aca8aa5716e6e0eed3fcdc88fec256a0a1828c491a8cf240486ae7cc473092d"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.17:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("ul5qawv4s7f7msm7dtyfarw80"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_dockerd-exporter"),
|
||||
"__meta_dockerswarm_service_task_container_hostname": model.LabelValue(""),
|
||||
"__meta_dockerswarm_service_task_container_image": model.LabelValue("stefanprodan/caddy:latest@sha256:44541cfacb66f4799f81f17fcfb3cb757ccc8f327592745549f5930c42d115c9"),
|
||||
},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("item %d", i), func(t *testing.T) {
|
||||
testutil.Equals(t, lbls, tg.Targets[i])
|
||||
|
|
|
@ -106,12 +106,19 @@ func (d *Discovery) refreshTasks(ctx context.Context) ([]*targetgroup.Group, err
|
|||
tg.Targets = append(tg.Targets, labels)
|
||||
}
|
||||
|
||||
for _, p := range servicePorts[s.ServiceID] {
|
||||
if p.Protocol != swarm.PortConfigProtocolTCP {
|
||||
continue
|
||||
}
|
||||
for _, network := range s.NetworksAttachments {
|
||||
for _, address := range network.Addresses {
|
||||
for _, network := range s.NetworksAttachments {
|
||||
for _, address := range network.Addresses {
|
||||
var added bool
|
||||
|
||||
ip, _, err := net.ParseCIDR(address)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while parsing address %s: %w", address, err)
|
||||
}
|
||||
|
||||
for _, p := range servicePorts[s.ServiceID] {
|
||||
if p.Protocol != swarm.PortConfigProtocolTCP {
|
||||
continue
|
||||
}
|
||||
labels := model.LabelSet{
|
||||
swarmLabelTaskPortMode: model.LabelValue(p.PublishMode),
|
||||
}
|
||||
|
@ -124,13 +131,26 @@ func (d *Discovery) refreshTasks(ctx context.Context) ([]*targetgroup.Group, err
|
|||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
ip, _, err := net.ParseCIDR(address)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while parsing address %s: %w", address, err)
|
||||
}
|
||||
addr := net.JoinHostPort(ip.String(), strconv.FormatUint(uint64(p.PublishedPort), 10))
|
||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||
|
||||
tg.Targets = append(tg.Targets, labels)
|
||||
added = true
|
||||
}
|
||||
if !added {
|
||||
labels := model.LabelSet{}
|
||||
|
||||
for k, v := range commonLabels {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
for k, v := range networkLabels[network.Network.ID] {
|
||||
labels[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
|
||||
addr := net.JoinHostPort(ip.String(), fmt.Sprintf("%d", d.port))
|
||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||
|
||||
tg.Targets = append(tg.Targets, labels)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ host: %s
|
|||
tg := tgs[0]
|
||||
testutil.Assert(t, tg != nil, "tg should not be nil")
|
||||
testutil.Assert(t, tg.Targets != nil, "tg.targets should not be nil")
|
||||
testutil.Equals(t, 17, len(tg.Targets))
|
||||
testutil.Equals(t, 27, len(tg.Targets))
|
||||
|
||||
for i, lbls := range []model.LabelSet{
|
||||
{
|
||||
|
@ -108,6 +108,33 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.88:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.2"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("i9woemzxymn1n98o9ufebclgm"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("iml8vdd2dudvq457sbirpf66z"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("google/cadvisor"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_cadvisor"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue(""),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("7ogolpkgw2d2amnht1fbtm9oq"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("rejected"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.12:9100"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
|
@ -273,6 +300,168 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.35:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.4"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("worker-1"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("jkc2xd7p3xdazf0u6sh1m9dmr"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("worker"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("9bbq7j55tzzz85k2gg52x73rg"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("cloudflare/unsee:v0.8.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_unsee"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("a0734f9421e710b654ca9e67010cbb55c1d5f92c17cc9e6590ab61130a3587e0"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("i9skiw2n5jkjoq7gix2t9uzhy"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.14:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.1"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("oxygen"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("d3cw2msquo0d71yn42qrnb0tu"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("hv645udwaaewyw7wuc6nspm68"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-prometheus:v2.5.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_prometheus"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("f35e071f1251951a09566a2231cb318a1a29e158a3c3d15ad68fd937184c56b6"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("irj35fr4j59f1kvi0xdin9oly"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.20:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.1"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("oxygen"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("d3cw2msquo0d71yn42qrnb0tu"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("ul5qawv4s7f7msm7dtyfarw80"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_dockerd-exporter"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("3cee48a5b2b363576b255207aae2d1bd0d8872aa61c3ff3b6d180d78d672a943"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("k8x2806pevvxigagsxovjmur1"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.19:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.5"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("worker-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("ldawcom10uqi6owysgi28n4ve"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("worker"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("ul5qawv4s7f7msm7dtyfarw80"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_dockerd-exporter"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("d5fd335a33c1fca8fffa1ec17bb5010a6bb7fba7aa72fd2209c25be8f5d1b975"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("mita4y262u04g4c7zz7ns032a"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.18:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.4"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("worker-1"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("jkc2xd7p3xdazf0u6sh1m9dmr"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("worker"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("ul5qawv4s7f7msm7dtyfarw80"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_dockerd-exporter"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("ca72094e1ec0547e84aba227dd44446588172fa9ee273de9bf4e6040ff6937bd"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("nm3v4jifzhfkw3rz33gmnaq2z"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.75:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.5"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("worker-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("ldawcom10uqi6owysgi28n4ve"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("worker"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("iml8vdd2dudvq457sbirpf66z"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("google/cadvisor"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_cadvisor"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue(""),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("shutdown"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("pxdv57mpvquv2zbt7faz3xux9"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("rejected"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.19:9090"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
|
@ -300,6 +489,60 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.19:9093"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.2"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("i9woemzxymn1n98o9ufebclgm"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("5d00e145527f14d1bb2b13601000f1de9c95fc8ec1ccc1ff8291cadc31232957"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("qtr16op0cz5pdbx4rylm7up4g"),
|
||||
"__meta_dockerswarm_task_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.19:9094"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.2"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("i9woemzxymn1n98o9ufebclgm"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("5d00e145527f14d1bb2b13601000f1de9c95fc8ec1ccc1ff8291cadc31232957"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("qtr16op0cz5pdbx4rylm7up4g"),
|
||||
"__meta_dockerswarm_task_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.81:9090"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
|
@ -328,33 +571,6 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.19:9093"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.2"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("i9woemzxymn1n98o9ufebclgm"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("5d00e145527f14d1bb2b13601000f1de9c95fc8ec1ccc1ff8291cadc31232957"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("qtr16op0cz5pdbx4rylm7up4g"),
|
||||
"__meta_dockerswarm_task_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.81:9093"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
|
@ -383,33 +599,6 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.19:9094"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("true"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.2"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-2"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("i9woemzxymn1n98o9ufebclgm"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("tkv91uso46cck763aaqcb4rek"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_caddy"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("5d00e145527f14d1bb2b13601000f1de9c95fc8ec1ccc1ff8291cadc31232957"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("qtr16op0cz5pdbx4rylm7up4g"),
|
||||
"__meta_dockerswarm_task_port_publish_mode": model.LabelValue("ingress"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.81:9094"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
|
@ -438,6 +627,60 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("starting"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.24:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.1"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("oxygen"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("d3cw2msquo0d71yn42qrnb0tu"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("iml8vdd2dudvq457sbirpf66z"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("google/cadvisor"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_cadvisor"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("81dd017b6d9f36d779a3217021111ffc77dcdbd5f26da86c2ae8fada86f33d17"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("s0rh3k9l7ii9vb62lsfp4wc93"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.32:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.3"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-3"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("bvtjl7pnrtg0k88ywialsldpd"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("rl4jhdws3r4lkfvq8kx6c4xnr"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/swarmprom-alertmanager:v0.14.0"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("replicated"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_alertmanager"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("2c753737f2ac7b01b577324513d9bd2a1754e65ab2a44714090eb5d83d2961b2"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("sxwkumr37wjaqzir89uepm4nc"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("1"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.16:3000"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("qvwhwd6p61k4o0ulsknqb066z"),
|
||||
|
@ -515,6 +758,33 @@ host: %s
|
|||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.1.22:80"),
|
||||
"__meta_dockerswarm_network_id": model.LabelValue("npq2closzy836m07eaq1425k3"),
|
||||
"__meta_dockerswarm_network_ingress": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_internal": model.LabelValue("false"),
|
||||
"__meta_dockerswarm_network_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_network_name": model.LabelValue("mon_net"),
|
||||
"__meta_dockerswarm_network_scope": model.LabelValue("swarm"),
|
||||
"__meta_dockerswarm_node_address": model.LabelValue("10.0.232.3"),
|
||||
"__meta_dockerswarm_node_availability": model.LabelValue("active"),
|
||||
"__meta_dockerswarm_node_hostname": model.LabelValue("master-3"),
|
||||
"__meta_dockerswarm_node_id": model.LabelValue("bvtjl7pnrtg0k88ywialsldpd"),
|
||||
"__meta_dockerswarm_node_platform_architecture": model.LabelValue("x86_64"),
|
||||
"__meta_dockerswarm_node_platform_os": model.LabelValue("linux"),
|
||||
"__meta_dockerswarm_node_role": model.LabelValue("manager"),
|
||||
"__meta_dockerswarm_node_status": model.LabelValue("ready"),
|
||||
"__meta_dockerswarm_service_id": model.LabelValue("ul5qawv4s7f7msm7dtyfarw80"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_image": model.LabelValue("stefanprodan/caddy"),
|
||||
"__meta_dockerswarm_service_label_com_docker_stack_namespace": model.LabelValue("mon"),
|
||||
"__meta_dockerswarm_service_mode": model.LabelValue("global"),
|
||||
"__meta_dockerswarm_service_name": model.LabelValue("mon_dockerd-exporter"),
|
||||
"__meta_dockerswarm_task_container_id": model.LabelValue("dd50c428ebc7a7bd786c7b0db873bf53ed5cbe5312995a76eb8fd325dcf16032"),
|
||||
"__meta_dockerswarm_task_desired_state": model.LabelValue("running"),
|
||||
"__meta_dockerswarm_task_id": model.LabelValue("zhoo9feqxfyi9zg6acnt1eam2"),
|
||||
"__meta_dockerswarm_task_slot": model.LabelValue("0"),
|
||||
"__meta_dockerswarm_task_state": model.LabelValue("running"),
|
||||
},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("item %d", i), func(t *testing.T) {
|
||||
testutil.Equals(t, lbls, tg.Targets[i])
|
||||
|
|
|
@ -459,7 +459,10 @@ One of the following roles can be configured to discover targets:
|
|||
|
||||
#### `services`
|
||||
|
||||
The `services` role is used to discover [Swarm services](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks).
|
||||
The `services` role discovers all [Swarm services](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks)
|
||||
and exposes their ports as targets. For each published port of a service, a
|
||||
single target is generated. If a service has no published ports, a target per
|
||||
service is created using the `port` parameter defined in the SD configuration.
|
||||
|
||||
Available meta labels:
|
||||
|
||||
|
@ -481,7 +484,10 @@ Available meta labels:
|
|||
|
||||
#### `tasks`
|
||||
|
||||
The `tasks` role is used to discover [Swarm tasks](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks).
|
||||
The `tasks` role discovers all [Swarm tasks](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks)
|
||||
and exposes their ports as targets. For each published port of a task, a single
|
||||
target is generated. If a task has no published ports, a target per task is
|
||||
created using the `port` parameter defined in the SD configuration.
|
||||
|
||||
Available meta labels:
|
||||
|
||||
|
@ -552,7 +558,8 @@ tls_config:
|
|||
# Role of the targets to retrieve. Must be `services`, `tasks`, or `nodes`.
|
||||
role: <string>
|
||||
|
||||
# The port to scrape metrics from, when `role` is nodes.
|
||||
# The port to scrape metrics from, when `role` is nodes, and for discovered
|
||||
# tasks and services that don't have published ports.
|
||||
[ port: <int> | default = 80 ]
|
||||
|
||||
# The time after which the droplets are refreshed.
|
||||
|
|
Loading…
Reference in a new issue