Exercice 22
Déployer le blackbox exporter
mkdir /opt/prometheus/blackbox
wget https://raw.githubusercontent.com/prometheus/blackbox_exporter/master/example.yml -O /opt/prometheus/blackbox/blackbox.yml
Ajouter au docker-compose.yml:
blackbox:
image: prom/blackbox-exporter:master
ports:
- 9115:9115
command: "--config.file=/config/blackbox.yml"
volumes:
- "/opt/prometheus/blackbox:/config"
Sujet
Configurer prometheus pour qu'il scrape les métriques des probe du blackbox exporter pour le site orange.fr
Attention, bien utiliser le module http_2xx_example à la place de http_2xx
Solution
show
# file:prometheus.yml
- job_name: blackbox
file_sd_configs:
- files:
- ./targets/blackbox/*.yml
refresh_interval: "15s"
metrics_path: /probe
params:
module: [http_2xx_orange_fr]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.102.28.71:9115
# file:./targets/blackbox/orange-targets.yml
- targets:
- orange.fr
labels:
node: promXX
Suite à la modification dans le docker-compose.yml effectuer :
docker-compose up -d
Note: Pour redémarrer le blackbox exporter :
docker-compose restart blackbox
Sujet
Trouver le code retour HTTP du site orange.fr tel que récupéré depuis le blackbox exporter
Solutions
show
probe_http_status_code{instance="orange.fr"}
Sujet
Résoudre le soucis en modifiant les headers HTTP dans la configuration du blackbox exporter
Solutions
show
#file: /opt/prometheus/blackbox/blackbox.yml
modules:
http_2xx_orange_fr:
prober: http
timeout: 5s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
valid_status_codes: [] # Defaults to 2xx
method: GET
headers:
Host: orange.fr
Accept-Language: en-US
Origin: orange.fr
follow_redirects: true
fail_if_ssl: false
fail_if_not_ssl: false
fail_if_body_matches_regexp:
- "Could not connect to database"
fail_if_body_not_matches_regexp:
- "[Oo]range"
fail_if_header_matches: [] # Verifies that no cookies are set
fail_if_header_not_matches:
- header: Set-Cookie
allow_missing: true
regexp: '.*'
tls_config:
insecure_skip_verify: false
preferred_ip_protocol: "ip4" # defaults to "ip6"
ip_protocol_fallback: false # no fallback to "ip6"
Sujet
Trouver le temps de réponse global d'orange.fr
Solution
show
probe_duration_seconds{instance="orange.fr"}
sum by (instance) (probe_http_duration_seconds{instance="orange.fr"})