update compose.yml + add website-monitoring

This commit is contained in:
Grégory Lebreton 2025-09-29 16:27:25 +02:00
parent 994768a73d
commit 7dc383afa5
7 changed files with 2132 additions and 0 deletions

View File

@ -0,0 +1,15 @@
modules:
http_2xx:
prober: http
timeout: 5s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
valid_status_codes: []
method: GET
preferred_ip_protocol: "ip4"
ip_protocol_fallback: false
icmp:
prober: icmp
icmp:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: false

152
compose.yml Normal file
View File

@ -0,0 +1,152 @@
networks:
grafana-network:
driver: bridge
ipam:
config:
- subnet: 192.168.100.0/24
volumes:
prometheus_data: {}
grafana_data: {}
services:
# POUR AFFICHAGE DASHBOARD
grafana:
image: grafana/grafana:11.2.0
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_USER=${ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
ports:
- 3000:3000
networks:
grafana-network:
ipv4_address: 192.168.100.10
labels:
org.label-schema.group: "monitoring"
# METRICS GATHERER
prometheus:
image: prom/prometheus:v2.54.1
container_name: prometheus
volumes:
- ./prometheus:/etc/prometheus
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
restart: unless-stopped
expose:
- 9090
networks:
- grafana-network
labels:
org.label-schema.group: "monitoring"
# FOR HOST METRICS
nodeexporter:
image: prom/node-exporter:v1.8.2
container_name: nodeexporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
restart: unless-stopped
expose:
- 9100
networks:
- grafana-network
labels:
org.label-schema.group: "monitoring"
# FOR DOCKER CONTAINERS
cadvisor:
image: gcr.io/cadvisor/cadvisor
container_name: cadvisor
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
- /cgroup:/cgroup:ro #doesn't work on MacOS only for Linux
restart: unless-stopped
expose:
- 8080
networks:
- grafana-network
labels:
org.label-schema.group: "monitoring"
# LOKI FOR LOGS
loki:
image: grafana/loki:latest
container_name: loki
ports:
- '3100:3100'
volumes:
- ./loki/config:/etc/loki
- ./loki/cert:/etc/loki/cert
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
# environment:
command: -config.file=/etc/loki/config.yml -config.expand-env=true
networks:
- grafana-network
# FOR WEBSITE MONITORING
blackbox-exporter:
image: "prom/blackbox-exporter:latest"
hostname: "blackbox"
restart: always
networks:
- website_monitoring
ports:
- "127.0.0.1:9115:9115"
volumes:
- "./blackbox/blackbox-exporter.yml:/etc/prometheus/blackbox-exporter.yml"
command:
- "--config.file=/etc/prometheus/blackbox-exporter.yml"
# FOR ALERTS
alertmanager:
image: prom/alertmanager:v0.20.0
container_name: alertmanager
volumes:
- ./alertmanager:/etc/alertmanager
command:
#- '--config.file=/etc/alertmanager/config.yml'
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
restart: unless-stopped
expose:
- 9093
networks:
- grafana-network
labels:
org.label-schema.group: "monitoring"
pushgateway:
image: prom/pushgateway:v1.2.0
container_name: pushgateway
restart: unless-stopped
expose:
- 9091
networks:
- grafana-network
labels:
org.label-schema.group: "monitoring"

View File

@ -0,0 +1,621 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"iteration": 1600975868828,
"links": [],
"panels": [
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "rgb(255, 255, 255)",
"value": null
}
]
},
"unit": "targets"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.2.0",
"targets": [
{
"expr": "count(count by (instance) (probe_http_status_code{job=\"$http_job\"}))",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": " ",
"type": "stat"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"decimals": 2,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "dark-red",
"value": null
},
{
"color": "dark-orange",
"value": 90
},
{
"color": "dark-yellow",
"value": 95
},
{
"color": "dark-green",
"value": 99
}
]
},
"unit": "% SSL"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 4,
"y": 0
},
"id": 4,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.2.0",
"targets": [
{
"expr": "((count(count by (instance) (probe_http_ssl{job=\"$http_job\"} == 1))) / (count(count by (instance) (probe_http_ssl{job=\"$http_job\"})))) * 100",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": " ",
"type": "stat"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 10,
"w": 16,
"x": 8,
"y": 0
},
"hiddenSeries": false,
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.0",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "/.*/",
"color": "#C4162A",
"lines": false,
"pointradius": 1,
"points": true
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "probe_http_status_code{job=\"$http_job\"} != 200",
"interval": "",
"legendFormat": "{{ instance }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Invalid status code history",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "none",
"label": "status code",
"logBase": 1,
"max": "550",
"min": "0",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"decimals": 2,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "dark-red",
"value": null
},
{
"color": "dark-orange",
"value": 90
},
{
"color": "dark-yellow",
"value": 95
},
{
"color": "dark-green",
"value": 99
}
]
},
"unit": "% HTTP/200"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 8,
"x": 0,
"y": 5
},
"id": 3,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.2.0",
"targets": [
{
"expr": "((count(count by (instance) (probe_http_status_code == 200))) / (count(count by (instance) (probe_http_status_code)))) * 100",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": " ",
"type": "stat"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {
"align": "left",
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Status code"
},
"properties": [
{
"id": "custom.displayMode",
"value": "color-background"
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "dark-red",
"value": null
},
{
"color": "dark-green",
"value": 200
},
{
"color": "dark-red",
"value": 201
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "SSL"
},
"properties": [
{
"id": "custom.displayMode",
"value": "color-background"
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "dark-red",
"value": null
},
{
"color": "dark-green",
"value": 1
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Target"
},
"properties": [
{
"id": "custom.width",
"value": 500
}
]
},
{
"matcher": {
"id": "byName",
"options": "Certificate validity"
},
"properties": [
{
"id": "unit",
"value": "days"
},
{
"id": "custom.displayMode",
"value": "color-background"
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "dark-red",
"value": null
},
{
"color": "dark-orange",
"value": 25
},
{
"color": "dark-green",
"value": 30
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Probe duration"
},
"properties": [
{
"id": "unit",
"value": "s"
}
]
},
{
"matcher": {
"id": "byName",
"options": "DNS lookup time"
},
"properties": [
{
"id": "unit",
"value": "s"
}
]
}
]
},
"gridPos": {
"h": 15,
"w": 24,
"x": 0,
"y": 10
},
"id": 8,
"options": {
"showHeader": true,
"sortBy": [
{
"desc": false,
"displayName": "Certificate validity"
}
]
},
"pluginVersion": "7.2.0",
"targets": [
{
"expr": "probe_http_status_code{job=\"$http_job\"}",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
},
{
"expr": "probe_http_redirects{job=\"$http_job\"} - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "B"
},
{
"expr": "probe_http_ssl{job=\"$http_job\"} - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "C"
},
{
"expr": "probe_http_version{job=\"$http_job\"} - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "D"
},
{
"expr": "((probe_ssl_earliest_cert_expiry{job=\"$http_job\"}) - time()) / (60*60*24) - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "E"
},
{
"expr": "probe_duration_seconds{job=\"$http_job\"} - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "F"
},
{
"expr": "probe_dns_lookup_time_seconds{job=\"$http_job\"} - 0",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "G"
}
],
"timeFrom": null,
"timeShift": null,
"title": " ",
"transformations": [
{
"id": "merge",
"options": {}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"job": true
},
"indexByName": {},
"renameByName": {
"Value #A": "Status code",
"Value #B": "Redirects",
"Value #C": "SSL",
"Value #D": "HTTP version",
"Value #E": "Certificate validity",
"Value #F": "Probe duration",
"Value #G": "DNS lookup time",
"instance": "Target"
}
}
}
],
"type": "table"
}
],
"refresh": false,
"schemaVersion": 26,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "website-monitoring-http",
"value": "website-monitoring-http"
},
"hide": 2,
"label": "http_job",
"name": "http_job",
"options": [
{
"selected": true,
"text": "website-monitoring-http",
"value": "website-monitoring-http"
}
],
"query": "website-monitoring-http",
"queryValue": "",
"skipUrlSync": false,
"type": "constant"
}
]
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Overview",
"uid": "OmAoLmKGk",
"version": 1
}

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,37 @@ scrape_configs:
# labels: # labels:
# instance: serveur-distant # instance: serveur-distant
# WEBSITE MONITORING
- job_name: "website-monitoring-http"
metrics_path: /probe
params:
module: [http_2xx]
file_sd_configs:
- files:
- /etc/prometheus/targets.yml
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
- job_name: "website-monitoring-icmp"
metrics_path: /probe
params:
module: [icmp]
file_sd_configs:
- files:
- /etc/prometheus/targets.yml
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
# SI ALERT VIA ALERTMANAGER SINON COMMENTER ! # SI ALERT VIA ALERTMANAGER SINON COMMENTER !
alerting: alerting:
alertmanagers: alertmanagers:

View File

@ -0,0 +1,20 @@
groups:
- name: web.rules
rules:
- alert: invalid_http_status_code
expr: probe_http_status_code != 200
for: 1m
labels:
severity: critical
- alert: certificate_validity_28_days
expr: (probe_ssl_earliest_cert_expiry - time ()) < ( 60 * 60 * 24 * 28 )
for: 1m
labels:
severity: warning
- alert: certificate_validity_10_days
expr: (probe_ssl_earliest_cert_expiry - time ()) < ( 60 * 60 * 24 * 10 )
for: 1m
labels:
severity: critical

42
prometheus/targets.yml Normal file
View File

@ -0,0 +1,42 @@
- targets:
# GNPROD
- git.legaragenumerique.fr
- id.legaragenumerique.fr
- nextcloud.legaragenumerique.fr
- leboard.legaragenumerique.fr
- penpot.legaragenumerique.fr
- learn.legaragenumerique.fr
- ai.legaragenumerique.fr
- bash.legaragenumerique.fr
- element.legaragenumerique.fr
# WEBHOSTING
- ltqf.fr
- portraitsmusicaux.legaragenumerique.fr
# PROD 2
- amandiersmenil.fr
- mail.legaragenumerique.fr
- doc.legaragenumerique.fr
- quizz.legaragenumerique.fr
- ssh.legaragenumerique.fr
# PROD 3
- edx.legaragenumerique.fr
- bbb.legaragenumerique.fr
- www.legaragenumerique.fr
- monitoring.legaragenumerique.fr
- odoo.legaragenumerique.fr
- portainer.legaragenumerique.fr
- beatume.legaragenumerique.fr
# ADVENTURE
- adventure.legaragenumerique.fr
# DRONE CI
- drone.legaragenumerique.fr
# GAMESERVER
- wow-registration.lgn.dev
- k3s.lgn.dev