diff --git a/blackbox/blackbox-exporter.yml b/blackbox/blackbox-exporter.yml new file mode 100644 index 0000000..2c6c400 --- /dev/null +++ b/blackbox/blackbox-exporter.yml @@ -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 \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..c165269 --- /dev/null +++ b/compose.yml @@ -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" diff --git a/grafana/provisioning/dashboards/overview.json b/grafana/provisioning/dashboards/overview.json new file mode 100644 index 0000000..0ade408 --- /dev/null +++ b/grafana/provisioning/dashboards/overview.json @@ -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 + } \ No newline at end of file diff --git a/grafana/provisioning/dashboards/website-monitoring.json b/grafana/provisioning/dashboards/website-monitoring.json new file mode 100644 index 0000000..ace361e --- /dev/null +++ b/grafana/provisioning/dashboards/website-monitoring.json @@ -0,0 +1,1251 @@ +{ + "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": 1, + "id": 2, + "iteration": 1601971789979, + "links": [], + "panels": [ + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-green", + "value": 200 + }, + { + "color": "dark-red", + "value": 201 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 0, + "y": 0 + }, + "id": 8, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_http_status_code{instance=\"$target\"}", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "HTTP status code", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [ + { + "from": "", + "id": 0, + "text": "No", + "to": "", + "type": 1, + "value": "0" + }, + { + "from": "", + "id": 1, + "text": "Yes", + "to": "", + "type": 1, + "value": "1" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 3, + "y": 0 + }, + "id": 14, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_http_ssl{instance=\"$target\"}", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "SSL", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-orange", + "value": 28 + }, + { + "color": "dark-green", + "value": 30 + } + ] + }, + "unit": "days" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 6, + "y": 0 + }, + "id": 17, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "(probe_ssl_earliest_cert_expiry{instance=\"$target\"} - time()) / (60*60*24)", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Certificate validity", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(255, 255, 255)", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "probe_tls_version_info{instance=\"intrasnl.org\", job=\"website-monitoring-http\", version=\"TLS 1.2\"}" + }, + "properties": [] + } + ] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 0 + }, + "id": 18, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "/^version$/", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_tls_version_info{instance=\"$target\"}", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "TLS version", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "semi-dark-blue", + "value": null + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 0 + }, + "id": 19, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_dns_lookup_time_seconds{instance=\"$target\",job=\"$http_job\"}", + "instant": false, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "DNS lookup time", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(255, 255, 255)", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 15, + "y": 0 + }, + "id": 20, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_http_version{instance=\"$target\"}", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "HTTP version", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(255, 255, 255)", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 18, + "y": 0 + }, + "id": 21, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_http_redirects{instance=\"$target\"}", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Redirect(s)", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [ + { + "from": "", + "id": 0, + "text": "No", + "to": "", + "type": 1, + "value": "0" + }, + { + "from": "", + "id": 1, + "text": "Yes", + "to": "", + "type": 1, + "value": "1" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-orange", + "value": null + }, + { + "color": "dark-green", + "value": 1 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 21, + "y": 0 + }, + "id": 22, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "probe_success{job=\"$icmp_job\",instance=\"$target\"}", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "ICMP", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 3, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-orange", + "value": 97 + }, + { + "color": "dark-green", + "value": 99 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 0, + "y": 3 + }, + "id": 9, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "avg_over_time(probe_success{job=\"$http_job\",instance=\"$target\"}[$__interval]) * 100", + "instant": false, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": "1d", + "timeShift": null, + "title": "Availability", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 3, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-orange", + "value": 97 + }, + { + "color": "dark-green", + "value": 99 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 8, + "y": 3 + }, + "id": 15, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "avg_over_time(probe_success{job=\"$http_job\",instance=\"$target\"}[$__interval]) * 100", + "instant": false, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": "3d", + "timeShift": null, + "title": "Availability", + "type": "stat" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 3, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-orange", + "value": 97 + }, + { + "color": "dark-green", + "value": 99 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 16, + "y": 3 + }, + "id": 16, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "7.2.0", + "targets": [ + { + "expr": "avg_over_time(probe_success{job=\"$http_job\",instance=\"$target\"}[$__interval]) * 100", + "instant": false, + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": "1w", + "timeShift": null, + "title": "Availability", + "type": "stat" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 7 + }, + "hiddenSeries": false, + "id": 5, + "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": "status code", + "color": "#37872D", + "legend": false, + "lines": false, + "pointradius": 1, + "points": true, + "yaxis": 2 + }, + { + "alias": "duration", + "color": "#1F60C4", + "fill": 3, + "fillGradient": 3 + }, + { + "alias": "invalid status code", + "color": "#C4162A", + "legend": false, + "lines": false, + "pointradius": 1, + "points": true, + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "probe_duration_seconds{instance=\"$target\",job=\"$http_job\"}", + "hide": false, + "interval": "", + "legendFormat": "duration", + "refId": "A" + }, + { + "expr": "probe_http_status_code{instance=\"$target\"} == 200", + "interval": "", + "legendFormat": "status code", + "refId": "B" + }, + { + "expr": "probe_http_status_code{instance=\"$target\"} != 200", + "hide": false, + "interval": "", + "legendFormat": "invalid status code", + "refId": "C" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "HTTP probe duration / status code", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": "status code", + "logBase": 1, + "max": "550", + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Display only ICMP failures", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 7 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.2.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "failure", + "color": "#FA6400", + "legend": false, + "lines": false, + "pointradius": 1, + "points": true, + "yaxis": 2 + }, + { + "alias": "duration", + "color": "#1F60C4", + "fill": 3, + "fillGradient": 3 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "probe_duration_seconds{instance=\"$target\",job=\"$icmp_job\"}", + "hide": false, + "interval": "", + "legendFormat": "duration", + "refId": "A" + }, + { + "expr": "probe_success{job=\"$icmp_job\",instance=\"$target\"} == 0", + "hide": false, + "interval": "", + "legendFormat": "failure", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "ICMP probe duration / failure", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": "failure", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 16 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.2.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "probe_http_duration_seconds{instance=\"$target\"}", + "interval": "", + "legendFormat": "{{ phase }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "HTTP probe (by phase)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 16 + }, + "hiddenSeries": false, + "id": 3, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.2.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "probe_icmp_duration_seconds{instance=\"$target\"}", + "interval": "", + "legendFormat": "{{ phase }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "ICMP probe (by phase)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": false, + "schemaVersion": 26, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": "", + "value": "" + }, + "datasource": "Prometheus", + "definition": "label_values(instance)", + "hide": 0, + "includeAll": false, + "label": "target", + "multi": false, + "name": "target", + "options": [], + "query": "label_values(instance)", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "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", + "skipUrlSync": false, + "type": "constant" + }, + { + "current": { + "selected": false, + "text": "website-monitoring-icmp", + "value": "website-monitoring-icmp" + }, + "hide": 2, + "label": "icmp_job", + "name": "icmp_job", + "options": [ + { + "selected": true, + "text": "website-monitoring-icmp", + "value": "website-monitoring-icmp" + } + ], + "query": "website-monitoring-icmp", + "skipUrlSync": false, + "type": "constant" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Website monitoring", + "uid": "EmUBHUFGk", + "version": 1 + } \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 2de0163..9e3a01a 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -52,6 +52,37 @@ scrape_configs: # labels: # 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 ! alerting: alertmanagers: diff --git a/prometheus/rules/web.rules.yml b/prometheus/rules/web.rules.yml new file mode 100644 index 0000000..c6e91a3 --- /dev/null +++ b/prometheus/rules/web.rules.yml @@ -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 \ No newline at end of file diff --git a/prometheus/targets.yml b/prometheus/targets.yml new file mode 100644 index 0000000..367cb66 --- /dev/null +++ b/prometheus/targets.yml @@ -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 \ No newline at end of file