diff --git a/docker-compose.yml b/docker-compose.yml index f4be2cf..a9027c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,11 +16,10 @@ services: - ./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.tsdb.path=/prometheus' + - '--web.console.libraries=/usr/share/prometheus/console_libraries' + - '--web.console.templates=/usr/share/prometheus/consoles' ports: - 9090:9090 links: diff --git a/prometheus/alert.rules b/prometheus/alert.rules deleted file mode 100644 index 697931b..0000000 --- a/prometheus/alert.rules +++ /dev/null @@ -1,9 +0,0 @@ -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 diff --git a/prometheus/alert.rules.yml b/prometheus/alert.rules.yml new file mode 100644 index 0000000..0cc6836 --- /dev/null +++ b/prometheus/alert.rules.yml @@ -0,0 +1,22 @@ +groups: +- name: example + rules: + + # Alert for any instance that is unreachable for >5 minutes. + - alert: service_down + expr: up == 0 + for: 2m + labels: + severity: page + annotations: + summary: "Instance {{ $labels.instance }} down" + description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes." + + - alert: high_load + expr: node_load1 > 0.5 + for: 2m + labels: + severity: page + annotations: + summary: "Instance {{ $labels.instance }} under high load" + description: "{{ $labels.instance }} of job {{ $labels.job }} is under high load." diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 2cf6b58..d6cec37 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -11,7 +11,7 @@ global: # Load and evaluate rules in this file every 'evaluation_interval' seconds. rule_files: - - "alert.rules" + - 'alert.rules.yml' # - "first.rules" # - "second.rules"