Skip to content

Commit

Permalink
📝 Exemple chapitre 15
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannig committed Nov 20, 2021
1 parent 131fefa commit 4f15932
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 0 deletions.
83 changes: 83 additions & 0 deletions chapitre-15/blackbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
modules:
http_2xx:
prober: http
http:
preferred_ip_protocol: ipv4
http_insecure_tls:
prober: http
http:
preferred_ip_protocol: ipv4
tls_config:
insecure_skip_verify: true
http_post_2xx:
prober: http
http:
method: POST
tcp_connect:
prober: tcp
pop3s_banner:
prober: tcp
tcp:
query_response:
- expect: "^+OK"
tls: true
tls_config:
insecure_skip_verify: false
ssh_banner:
prober: tcp
tcp:
query_response:
- expect: "^SSH-2.0-"
- send: "SSH-2.0-blackbox-ssh-check"
irc_banner:
prober: tcp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
icmp:
prober: icmp
smtp_banner:
prober: tcp
timeout: 20s
tcp:
preferred_ip_protocol: ip4
query_response:
- expect: "220.*ESMTP"
- send: "EHLO prober\r"
- expect: "250-Hello prober"
- send: "QUIT"
smtp_starttls:
prober: tcp
timeout: 2s
tcp:
preferred_ip_protocol: ip4
query_response:
- expect: "220.*ESMTP"
- send: "EHLO prober"
- expect: "250"
- send: "STARTTLS"
- expect: "220"
- starttls: true
- send: "EHLO prober"
- expect: "250"
- send: "QUIT"
smtp_tls:
prober: tcp
timeout: 20s
tcp:
tls: true
preferred_ip_protocol: ip4
query_response:
- expect: "220.*ESMTP"
- send: "EHLO prober\r"
- expect: "250-Hello prober"
- send: "QUIT"
tcp_tls:
prober: tcp
timeout: 20s
tcp:
tls: true
18 changes: 18 additions & 0 deletions chapitre-15/blackbox_exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Blackbox exporter for Prometheus
Documentation=http://prometheus.io
Wants=network-online.target

[Service]
WorkingDirectory=/opt/blackbox_exporter
User=prometheus
Group=prometheus
Restart=on-failure
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/opt/blackbox_exporter/blackbox_exporter

TimeoutStopSec=20
UMask=0027

[Install]
WantedBy=multi-user.target
95 changes: 95 additions & 0 deletions chapitre-15/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
global:
scrape_interval: 15s
evaluation_interval: 15s

alerting:
alertmanagers:
- static_configs:
#- targets: [ localhost:9093 ]

rule_files:
- rules/*.yaml

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
file_sd_configs:
- files: ['nodes/*.yaml']
relabel_configs:
- source_labels: [__address__]
regex: '(xen-host-.*):(.*)'
target_label: xenhost
replacement: '$1'
- job_name: 'grafana'
static_configs:
- targets: ['localhost:3000']
# - job_name: 'win-exporter'
# static_configs:
# - targets: ['windows:9182']
# - job_name: 'postgres'
# static_configs:
# - targets: ['localhost:9187']
# - job_name: 'mysql'
# static_configs:
# - targets: ['localhost:9104']
- job_name: 'pushgateway'
honor_labels: true
static_configs:
- targets: ['localhost:9091']

- job_name: 'smtp_status'
metrics_path: /probe
params:
module: [smtp_banner]
static_configs:
- targets: [ 'localhost:1025' ]
relabel_configs:
Write target address in target parameter
- source_labels: [__address__]
target_label: __param_target
Make instance label the target
- source_labels: [__param_target]
target_label: instance
Actually talk to the blackbox exporter though
- target_label: __address__
replacement: 127.0.0.1:9115

- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: [ 'www.google.fr', "www.google.com", "prometheus.io" ]
relabel_configs:
# Write target address in target parameter
- source_labels: [__address__]
target_label: __param_target
# Make instance label the target
- source_labels: [__param_target]
target_label: instance
# Actually talk to the blackbox exporter though
- target_label: __address__
replacement: 127.0.0.1:9115

- job_name: 'snmp'
metrics_path: /snmp
params:
module: [if_mib_mycommunity]
static_configs:
- targets: [ '192.168.0.40' ]
relabel_configs:
Write target address in target parameter
- source_labels: [__address__]
target_label: __param_target
Make instance label the target
- source_labels: [__param_target]
target_label: instance
Actually talk to the snmp exporter though
- target_label: __address__
replacement: 127.0.0.1:9116
18 changes: 18 additions & 0 deletions chapitre-15/snmp_exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=SNMP exporter for Prometheus
Documentation=http://prometheus.io
Wants=network-online.target

[Service]
WorkingDirectory=/opt/snmp_exporter
User=prometheus
Group=prometheus
Restart=on-failure
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/opt/snmp_exporter/snmp_exporter

TimeoutStopSec=20
UMask=0027

[Install]
WantedBy=multi-user.target

0 comments on commit 4f15932

Please sign in to comment.