Feature 10981: installation of AlertManager as part of NG-SA
[osm/devops.git] / installers / docker / osm_pods / ng-prometheus.yaml
index 0172aaf..77ccbd1 100644 (file)
@@ -30,10 +30,13 @@ spec:
   type: NodePort
 ---
 apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: prom
 data:
-  osm_rules.yml: |
+  osm_metric_rules.yml: |
     groups:
-      - name: osm_rules
+      - name: osm_metric_rules
         rules:
         - record: vm_status_extended
           expr: (last_over_time(vm_status[1m]) * on (vm_id, vim_id) group_left(ns_id, vnf_id, vdu_id, project_id, job, vdu_name, vnf_member_index) last_over_time(ns_topology[1m])) or (last_over_time(ns_topology[1m]) * -1)
@@ -47,6 +50,16 @@ data:
           expr: (0 * (count (vm_status_extended==0) by (ns_id)>=0)) or (min by (ns_id) (vm_status_extended))
           labels:
             job: osm_prometheus
+  osm_alert_rules.yml: |
+    groups:
+      - name: osm_alert_rules
+        rules:
+        - alert: vdu_down
+          expr: vm_status_extended != 1
+          for: 3m
+          annotations:
+            summary: "VDU {{ $labels.vm_id }} in VIM {{ $labels.vim_id }} is down"
+            description: "VDU {{ $labels.vm_id }} in VIM {{ $labels.vim_id }} has been down for more than 3 minutes. NS instance id is {{ $labels.ns_id }}"
   prometheus.yml: |
     # Copyright 2018 The Prometheus Authors
     # Copyright 2018 Whitestack
@@ -75,12 +88,12 @@ data:
       alertmanagers:
       - static_configs:
         - targets:
-          - alertmanager:9093
+          - alertmanager:9093
 
     # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
     rule_files:
-      - "osm_rules.yml"
-      # - "second_rules.yml"
+      - "osm_metric_rules.yml"
+      - "osm_alert_rules.yml"
 
     # A scrape configuration containing exactly one endpoint to scrape:
     # Here it's Prometheus itself.
@@ -94,9 +107,6 @@ data:
         static_configs:
         - targets:
           - pushgateway-prometheus-pushgateway:9091
-kind: ConfigMap
-metadata:
-  name: prom
 ---
 apiVersion: apps/v1
 kind: StatefulSet
@@ -119,7 +129,7 @@ spec:
       - name: prometheus-init-config
         image: busybox
         command: ["/bin/sh", "-c"]
-        args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_rules.yml /etc/prometheus']
+        args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_metric_rules.yml /config/osm_alert_rules.yml /etc/prometheus']
         volumeMounts:
           - name: prom-config
             mountPath: /etc/prometheus