kind: ConfigMap
apiVersion: v1
metadata:
    name: prometheus-config
    namespace: openfaas
    selfLink: /api/v1/namespaces/openfaas/configmaps/prometheus-config
    uid: 4803a1e8-3986-11ea-b115-42010a8001d6
    resourceVersion: '2007012'
    creationTimestamp: '2020-01-18T00:05:48Z'
    labels:
        app: openfaas
        chart: openfaas-5.4.1
        component: prometheus-config
        heritage: Helm
        release: openfaas
data:
    alert.rules.yml: |
        groups:
          - name: openfaas
            rules:
            - alert: service_down
              expr: up == 0
            - alert: APIHighInvocationRate
              expr: sum(rate(gateway_function_invocation_total{code="200"}[10s])) BY (function_name) > 5
              for: 5s
              labels:
                service: gateway
                severity: major
              annotations:
                description: High invocation total on "{{$labels.function_name}}"
                summary: High invocation total on "{{$labels.function_name}}"
    prometheus.yml: |
        global:
          scrape_interval:     15s
          evaluation_interval: 15s
          external_labels:
              monitor: 'faas-monitor'

        rule_files:
            - 'alert.rules.yml'

        scrape_configs:
          - job_name: 'prometheus'
            scrape_interval: 5s
            static_configs:
              - targets: ['localhost:9090']

          - job_name: 'kubernetes-pods'
            scrape_interval: 5s
            honor_labels: false
            kubernetes_sd_configs:
              - role: pod
                namespaces:
                  names:
                    - openfaas
            relabel_configs:
            - action: labelmap
              regex: __meta_kubernetes_pod_label_(.+)
            - source_labels: [__meta_kubernetes_namespace]
              action: replace
              target_label: kubernetes_namespace
            - source_labels: [__meta_kubernetes_pod_name]
              action: replace
              target_label: kubernetes_pod_name
            - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
              action: keep
              regex: true
            - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
              action: replace
              regex: ([^:]+)(?::\d+)?;(\d+)
              replacement: $1:$2
              target_label: __address__

        alerting:
          alertmanagers:
          - static_configs:
            - targets:
              - alertmanager:9093

