---
kind: ConfigMap
apiVersion: v1
metadata:
  labels:
    app: prometheus
  name: prometheus-config
  namespace: openfaas
data:
  prometheus.yml: |
    global:
      scrape_interval:     15s
      evaluation_interval: 15s
      external_labels:
          monitor: 'faas-monitor'
    rule_files:
        - 'alert.rules'
    scrape_configs:
      - job_name: 'prometheus'
        scrape_interval: 5s
        static_configs:
          - targets: ['localhost:9090']
      - job_name: "gateway"
        scrape_interval: 5s
        dns_sd_configs:
          - names: ['gateway']
            port: 8080
            type: A
            refresh_interval: 5s
  alert.rules: |
    ALERT service_down
      IF up == 0
    ALERT APIHighInvocationRate
      IF sum ( rate(gateway_function_invocation_total{code="200"}[10s]) ) by (function_name) > 5000
      FOR 5s
      LABELS {
        service = "gateway",
        severity = "major",
        value = "{{$value}}"
      }
      ANNOTATIONS {
        summary = "High invocation total on {{ $labels.instance }}",
        description =  "High invocation total on {{ $labels.instance }}"
      }

