Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Refactor dockerswarm-ingress probe config
Browse files Browse the repository at this point in the history
  • Loading branch information
socheatsok78 committed Jun 12, 2024
1 parent a5e9b35 commit a817df9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 143 deletions.
114 changes: 0 additions & 114 deletions rootfs/dockerswarm/dockerswarm-endpoints-nodeport.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
# io.prometheus.probe_enabled=<true|false>
# io.prometheus.probe_disabled=<true|false>
#
# io.prometheus.dockerswarm-endpoints.should_be_probed=<true|false>
# io.prometheus.dockerswarm-ingress.should_be_probed=<true|false>
scrape_configs:

- job_name: 'dockerswarm-endpoints-ingresses'
- job_name: 'dockerswarm-ingress'
scrape_interval: 15s

metrics_path: /probe
params:
module: [icmp_ttl5]
module: [http_2xx]

dockerswarm_sd_configs:
- host: unix:///var/run/docker.sock
Expand All @@ -27,9 +27,9 @@ scrape_configs:
# Keep or drop targets with the following rules
# ================================================================================

# io.prometheus.dockerswarm-endpoints.should_be_probed=<true|false>
# io.prometheus.dockerswarm-ingress.should_be_probed=<true|false>
- source_labels:
- __meta_dockerswarm_service_label_io_prometheus_dockerswarm_endpoints_should_be_probed
- __meta_dockerswarm_service_label_io_prometheus_dockerswarm_ingress_should_be_probed
regex: 'false'
action: drop

Expand All @@ -41,34 +41,23 @@ scrape_configs:
# io.prometheus.probe_disabled=<true|false>
- source_labels:
- __meta_dockerswarm_service_label_io_prometheus_probe_disabled
regex: 'false'
regex: 'true'
action: drop

# Keep only tasks connected to the "host" network
- source_labels:
- __meta_dockerswarm_network_ingress
regex: 'true'
action: keep
# Keep only tasks connected to the "dockerswarm_ingress" network
- source_labels:
- __meta_dockerswarm_service_endpoint_port_publish_mode
regex: 'ingress'
- __meta_dockerswarm_network_name
regex: 'dockerswarm_ingress'
action: keep

# ================================================================================
# Override prometheus and blackbox internal labels
# ================================================================================
- source_labels:
- __address__
target_label: __tmp_target
regex: ([^:]+)(?::\d+)?
replacement: $1
- source_labels: [__address__]
target_label: __tmp_address
- source_labels: [__tmp_target]
target_label: __param_target
- target_label: __address__
replacement: blackbox-exporter.svc.cluster.local:9115
- source_labels: [__tmp_address]
- source_labels: [__param_target]
target_label: instance

# Drop all labels starting with "io.prometheus."
Expand Down
1 change: 1 addition & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
make:
docker network create --scope=swarm --driver=overlay --attachable dockerswarm_ingress || true
docker network create --scope=swarm --driver=overlay --attachable dockerswarm_metrics || true
docker network create --scope=swarm --driver=overlay --attachable prometheus_exporter || true
docker stack deploy -c docker-stack.yml --detach=false prometheus_test
Expand Down
18 changes: 10 additions & 8 deletions test/docker-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ volumes:
prometheus-data:

networks:
dockerswarm_ingress:
name: dockerswarm_ingress
external: true
dockerswarm_metrics:
name: dockerswarm_metrics
external: true
Expand Down Expand Up @@ -45,7 +48,7 @@ services:
- published: 3000
target: 3000
networks:
dockerswarm_metrics:
dockerswarm_ingress:
# volumes:
# - grafana-data:/var/lib/grafana

Expand All @@ -66,7 +69,7 @@ services:
labels:
io.prometheus.role: "prometheus"
io.prometheus.dockerswarm-tasks.should_be_scraped: "false"
io.prometheus.dockerswarm-endpoints.should_be_probed: "false"
io.prometheus.dockerswarm-ingress.should_be_probed: "false"
logging: *x-default-logging
environment:
- DOCKERSWARM_SERVICE_ID={{.Service.ID}}
Expand All @@ -82,6 +85,7 @@ services:
target: 9090
hostname: prometheus.{{.Node.ID}}.cluster.local
networks:
dockerswarm_ingress:
dockerswarm_metrics:
prometheus_exporter:
extra_hosts:
Expand All @@ -105,13 +109,11 @@ services:
io.prometheus.enabled: "true"
io.prometheus.job_name: "blackbox-exporter"
io.prometheus.scrape_port: "9115"
io.prometheus.dockerswarm-endpoints.should_be_probed: "false"
io.prometheus.dockerswarm-ingress.should_be_probed: "false"
logging: *x-default-logging
ports:
- published: 9115
target: 9115
hostname: blackbox-exporter.svc.cluster.local
networks:
dockerswarm_ingress:
dockerswarm_metrics:
prometheus_exporter:

Expand All @@ -128,7 +130,7 @@ services:
labels:
io.prometheus.role: "node-exporter"
io.prometheus.dockerswarm-tasks.should_be_scraped: "false"
io.prometheus.dockerswarm-endpoints.should_be_probed: "false"
io.prometheus.dockerswarm-ingress.should_be_probed: "false"
logging: *x-default-logging
ports:
- published: 9100
Expand Down Expand Up @@ -157,7 +159,7 @@ services:
labels:
io.prometheus.role: "cadvisor"
io.prometheus.dockerswarm-tasks.should_be_scraped: "false"
io.prometheus.dockerswarm-endpoints.should_be_probed: "false"
io.prometheus.dockerswarm-ingress.should_be_probed: "false"
logging: *x-default-logging
ports:
- published: 8080
Expand Down

0 comments on commit a817df9

Please sign in to comment.