From 0fcf48443329d3dd7373ea4ed113d66941ba864a Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Fri, 3 Nov 2017 16:40:00 +0800 Subject: [PATCH 1/3] remove docker compose file 3.2 Volume LONG SYNTAX --- docker-compose.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f4be2cf..e992b68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.2' +version: '3.1' volumes: prometheus_data: {} @@ -39,15 +39,9 @@ services: node-exporter: image: prom/node-exporter volumes: - - type: bind - source: /proc - target: /host/proc - - type: bind - source: /sys - target: /host/sys - - type: bind - source: / - target: /rootfs + - /proc:/host/proc + - /sys:/host/sys + - /:/rootfs command: - '--path.procfs=/host/proc' - '--path.sysfs=/host/sys' From 35673af98d641999943268b6c9be915475e1af6e Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Fri, 10 Nov 2017 12:06:22 +0800 Subject: [PATCH 2/3] update prometheus to v2.0.0 --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e992b68..7873448 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,16 +11,16 @@ networks: services: prometheus: - image: prom/prometheus + image: prom/prometheus:v2.0.0 volumes: - ./prometheus/:/etc/prometheus/ - prometheus_data:/prometheus command: - - '-config.file=/etc/prometheus/prometheus.yml' - - '-storage.local.path=/prometheus' - - '-alertmanager.url=http://alertmanager:9093' - - '-web.console.libraries=/usr/share/prometheus/console_libraries' - - '-web.console.templates=/usr/share/prometheus/consoles' + - '--config.file=/etc/prometheus/prometheus.yml' + - '--storage.local.path=/prometheus' + - '--alertmanager.url=http://alertmanager:9093' + - '--web.console.libraries=/usr/share/prometheus/console_libraries' + - '--web.console.templates=/usr/share/prometheus/consoles' ports: - 9090:9090 links: From 806d49c00221853488e185757ef63eababf09bb7 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Fri, 10 Nov 2017 17:03:57 +0800 Subject: [PATCH 3/3] update alert --- docker-compose.yml | 3 +-- prometheus/alert.rules | 20 +++++++++++--------- prometheus/prometheus.yml | 8 ++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7873448..59deb0d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,7 @@ services: - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - - '--storage.local.path=/prometheus' - - '--alertmanager.url=http://alertmanager:9093' + - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/usr/share/prometheus/console_libraries' - '--web.console.templates=/usr/share/prometheus/consoles' ports: diff --git a/prometheus/alert.rules b/prometheus/alert.rules index 697931b..bd4b6a9 100644 --- a/prometheus/alert.rules +++ b/prometheus/alert.rules @@ -1,9 +1,11 @@ -ALERT service_down - IF up == 0 - -ALERT high_load - IF node_load1 > 0.5 - ANNOTATIONS { - summary = "Instance {{ $labels.instance }} under high load", - description = "{{ $labels.instance }} of job {{ $labels.job }} is under high load.", - } \ No newline at end of file +groups: +- name: example + rules: + - alert: InstanceDown + expr: up == 0 + for: 5m + labels: + severity: page + annotations: + summary: "Instance {{ $labels.instance }} down" + description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes." \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 2cf6b58..d51bb55 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -15,6 +15,14 @@ rule_files: # - "first.rules" # - "second.rules" +# alert +alerting: + alertmanagers: + - scheme: http + static_configs: + - targets: + - "alertmanager:9093" + # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: