Exercice 23

Sujet

Rajouter à votre supervision un cluster Kubernetes (URL et token ci-dessous) en utilisant kubernetes_sd_configs


api_server: https://rancher.k8s.datailor.fr/k8s/clusters/c-mdmxl
role: ingress
authorization:
  credentials: kubeconfig-u-crd2h8kh77:mgs57kl5z54l76qnqvj8dwvnlsqn5bw6cm68dp2277hm6hc4vvw7wt

Rajouter les role: ingress à votre scrape config du blackbox exporter.


Liste des ingress présentes dans le cluster :
NAMESPACE           NAME                 CLASS    HOSTS                                     ADDRESS                     PORTS     AGE
cattle-prometheus   prometheus-ingress   <none>   prometheus.formation.public.datailor.fr   10.102.28.13,10.102.28.14   80, 443   2d21h
cattle-prometheus   prometheus-ingress   <none>   grafana.formation.public.datailor.fr   10.102.28.13,10.102.28.14   80, 443   2d21h

Solution

show
#file:prometheus.yml
- job_name: blackbox_kubernetes
  kubernetes_sd_configs:
  - role: ingress
    api_server: https://rancher.k8s.datailor.fr/k8s/clusters/c-mdmxl
    authorization:
      credentials: kubeconfig-u-crd2h8kh77:mgs57kl5z54l76qnqvj8dwvnlsqn5bw6cm68dp2277hm6hc4vvw7wt
  metrics_path: /probe
  params:
    module: [http_2xx]
  relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: 10.102.28.XX:9115
#file: /opt/prometheus/blackbox/blackbox.yml
modules:
  http_2xx:
    prober: http
    timeout: 5s
    http:
      valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
      valid_status_codes: []  # Defaults to 2xx
      method: GET
      headers: {}
      follow_redirects: true
      fail_if_ssl: false
      fail_if_not_ssl: false
      fail_if_body_matches_regexp: []
      fail_if_body_not_matches_regexp: []
      fail_if_header_matches: [] # Verifies that no cookies are set
      fail_if_header_not_matches: []
      tls_config:
        insecure_skip_verify: false
      preferred_ip_protocol: "ip4" # defaults to "ip6"
      ip_protocol_fallback: false  # no fallback to "ip6"