import files

This commit is contained in:
Yann Autissier
2021-02-09 17:05:00 +01:00
parent f5c4576411
commit 44a6d37ba5
425 changed files with 23195 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
FROM quay.io/prometheus/prometheus:latest as dist
LABEL maintainer "jc.iacono.gm@gmail.com"
ARG DOCKER_BUILD_DIR
ARG MONITORING_PRIMARY_TARGETS_BLACKBOX
ARG MONITORING_SECONDARY_TARGETS_BLACKBOX
COPY ${DOCKER_BUILD_DIR}/prometheus.tmpl /etc/prometheus/prometheus.tmpl
COPY ${DOCKER_BUILD_DIR}/alert-rules.yml /etc/prometheus/alert-rules.yml
# Creating the config file.
# The last -e instruction cleans the file from quotes in the lists
RUN sed \
-e 's|MONITORING_PRIMARY_TARGETS_BLACKBOX|'" - ${MONITORING_PRIMARY_TARGETS_BLACKBOX// /\\n - }"'|; s|MONITORING_SECONDARY_TARGETS_BLACKBOX|'" - ${MONITORING_SECONDARY_TARGETS_BLACKBOX// /\\n - }"'|' \
/etc/prometheus/prometheus.tmpl > /etc/prometheus/prometheus.yml
COPY ${DOCKER_BUILD_DIR}/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD []
FROM dist as local
ARG DOCKER_BUILD_DIR
FROM local as debug
ARG DOCKER_BUILD_DIR
FROM local as tests
ARG DOCKER_BUILD_DIR
FROM tests as preprod
ARG DOCKER_BUILD_DIR
FROM preprod as prod
ARG DOCKER_BUILD_DIR
+147
View File
@@ -0,0 +1,147 @@
groups:
- name: example
rules:
# CET / CEST
- record: is_european_summer_time
expr: |
(vector(1) and (month() > 3 and month() < 10))
or
(vector(1) and (month() == 3 and (day_of_month() - day_of_week()) >= 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and (month() == 10 and (day_of_month() - day_of_week()) < 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and ((month() == 10 and hour() < 1) or (month() == 3 and hour() > 0)) and ((day_of_month() >= 25) and (day_of_week() == 0)))
or
vector(0)
# French time (UTC+1) CET / CEST
- record: european_french_time
expr: time() + 3600 + 3600 * is_european_summer_time
# Alert for any instance that is unreachable for a few seconds.
- alert: InstanceDown-01-low
expr: probe_success == 0
for: 30s
labels:
severity: "low"
type: "timeout"
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "Instance {{ $labels.instance }} of job {{ $labels.job }} has been down for a few seconds."
# Alert for any instance that is unreachable for some time.
- alert: InstanceDown-02-medium
expr: probe_success == 0
for: 5m
labels:
severity: "medium"
type: "timeout"
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "Instance {{ $labels.instance }} of job {{ $labels.job }} has been down for 10 minutes"
# Alert for any instance that is unreachable for a long time.
- alert: InstanceDown-03-high
expr: probe_success == 0
for: 1h
labels:
severity: "high"
type: "timeout"
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "Instance {{ $labels.instance }} of job {{ $labels.job }} has been down for 1 hour"
# Alert for any instance that is unreachable for a very long time.
- alert: InstanceDown-04-critical
expr: probe_success == 0
for: 12h
labels:
severity: "critical"
type: "timeout"
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "Instance {{ $labels.instance }} of job {{ $labels.job }} has been down for more than 12 hours"
# Alert for GMV < 250€ from 8AM to 10PM on weekdays
- alert: "GMV (daytime) below lower threshold"
# Prometheus time is GMT
expr: gmv_hourly_return_value < 250 and ON() hour(european_french_time) > 8 < 22
for: 1h
labels:
severity: "high"
type: "lower than static threshold"
instance: "Hourly GMV"
annotations:
summary: "{{ $labels.instance }} GMV alert"
description: '`Hourly GMV` has been *Lower than 250€*, for more than 1 hour.
\n
\n> Current value is *{{ .Value | printf "%.2f" }}* (over the last hour)'
# Alert for GMV too low (under static 50€) over night 10PM to 8AM
- alert: "GMV nightly below lower threshold"
# Prometheus time is GMT
expr: gmv_hourly_return_value < 50 and ON() hour(european_french_time) < 8 > 22
for: 4h
labels:
severity: "low"
type: "lower than static threshold"
instance: "Hourly GMV"
annotations:
summary: "{{ $labels.instance }} GMV alert"
description: '`Hourly GMV` (night) has been *Lower than 50€*, for more than 4 hour.
\n
\n> Current value is *{{ .Value | printf "%.2f" }}* (over the last hour)
\n
\nGMV is usually very low between 23:30 and 05:00, but this still may require attention'
# Alert for GMV significantly lower (<33%) than mean value over last 4 weeks from 8AM to 10PM on weekdays
- alert: "GMV less than 33% compared to last 4 weeks"
# Prometheus time is GMT
expr: gmv_hourly_return_value < .33 * ( gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25 and ON() hour(european_french_time) > 8 < 22
for: 1h
labels:
severity: "low"
type: "lower than last 4 weeks"
instance: "Hourly GMV"
annotations:
summary: "{{ $labels.instance }} GMV alert"
description: '`Hourly GMV` has been *significantly lower than usual*, for more than 1 hour.
\n
\n> Current value is *{{ .Value | printf "%.2f" }}* (over the last hour)'
query: '>Mean value observed this month is {{ range query "((gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25)" }}*{{ .Value | printf "%.2f" }}*{{ end }} (same day of the week, same hour)'
# Alert for GMV critically lower (<20%) than mean value over last 4 weeks from 8AM to 10PM on weekdays
- alert: "GMV less than 20% compared to last 4 weeks"
# Prometheus time is GMT
expr: gmv_hourly_return_value < .20 * ( gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25 and ON() hour(european_french_time) > 8 < 22
for: 1h
labels:
severity: "high"
type: "low over last 4 weeks"
instance: "Hourly GMV"
annotations:
summary: "{{ $labels.instance }} GMV alert"
description: '`Hourly GMV` has been *critically lower than usual*, for more than 1 hour.
\n
\n> Current value is *{{ .Value | printf "%.2f" }}* (over the last hour)'
query: '>Mean value observed this month is {{ range query "((gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25)" }}*{{ .Value | printf "%.2f" }}*{{ end }} (same day of the week, same hour)'
# Alert for GMV suspiciously higher (>500%) than mean value over last 4 weeks from 8AM to 10PM on weekdays
- alert: "GMV more than 500% compared to last 4 weeks"
# Prometheus time is GMT
expr: gmv_hourly_return_value > 5 * ( gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25 and ON() hour(european_french_time) > 8 < 22
for: 1h
labels:
severity: "low"
type: "low over last 4 weeks"
instance: "Hourly GMV"
annotations:
summary: "{{ $labels.instance }} GMV alert"
description: '`Hourly GMV` has been *much higher than usual*, for more than 1 hour.
\n(If there is an ongoing sale, it is most probably ok)
\n
\n> Current value is *{{ .Value | printf "%.2f" }}* (over the last hour)'
query: '>Mean value observed this month is {{ range query "((gmv_hourly_oneweekago_return_value + gmv_hourly_twoweeksago_return_value + gmv_hourly_threeweeksago_return_value + gmv_hourly_fourweeksago_return_value ) * .25)" }}*{{ .Value | printf "%.2f" }}*{{ end }} (same day of the week, same hour)'
+11
View File
@@ -0,0 +1,11 @@
#!/bin/ash
set -euo pipefail
set -o errexit
set -x
trap 'kill -SIGQUIT $PID' INT
# Launch alertmanager by default, or paramater
[ $# -eq 0 ] && /bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.no-lockfile || exec "$@" &
PID=$! && wait
+107
View File
@@ -0,0 +1,107 @@
# my global config
global:
scrape_interval: 15s # Set the default scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 1m # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout global default is 10s.
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "alert-rules.yml"
# - "alert.rules"
# - "first_rules.yml"
# - "second_rules.yml"
scrape_configs:
- job_name: 'Containers'
metrics_path: /metrics
static_configs:
- targets:
- prometheus:9090
- blackbox:9115
- grafana:3000
- job_name: 'es-exporter'
static_configs:
- targets:
- es-exporter:9206
- job_name: 'node-exporter'
static_configs:
- targets:
- node-exporter:9100
- job_name: 'cadvisor-exporter'
static_configs:
- targets:
- cadvisor-exporter:8080
- job_name: 'blackbox_primary'
scrape_interval: 15s
scrape_timeout: 5s
metrics_path: /probe
params:
module:
- http_2xx
static_configs:
- targets:
MONITORING_PRIMARY_TARGETS_BLACKBOX
relabel_configs:
- source_labels: [__address__]
regex: (.*)(:80)?
target_label: __param_target
replacement: ${1}
- source_labels: [__param_target]
regex: (.*)
target_label: instance
replacement: ${1}
- source_labels: []
regex: .*
target_label: __address__
replacement: blackbox:9115
- job_name: 'blackbox_secondary'
scrape_interval: 60s
scrape_timeout: 15s
metrics_path: /probe
params:
module:
- http_2xx
static_configs:
- targets:
MONITORING_SECONDARY_TARGETS_BLACKBOX
relabel_configs:
- source_labels: [__address__]
regex: (.*)(:80)?
target_label: __param_target
replacement: ${1}
- source_labels: [__param_target]
regex: (.*)
target_label: instance
replacement: ${1}
- source_labels: []
regex: .*
target_label: __address__
replacement: blackbox:9115