helm-charts/openfaas/templates/prometheus-cfg.yaml

82 lines
2.4 KiB
YAML
Raw Normal View History

2021-01-17 01:09:41 +00:00
{{- $functionNs := default .Release.Namespace .Values.functionNamespace }}
{{- if .Values.prometheus.create }}
---
kind: ConfigMap
apiVersion: v1
metadata:
labels:
app: {{ template "openfaas.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
component: prometheus-config
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: prometheus-config
namespace: {{ .Release.Namespace | quote }}
data:
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:
- {{ .Release.Namespace }}
{{- if ne $functionNs (.Release.Namespace | toString) }}
- {{ $functionNs }}
{{- end }}
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
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{{ "}}" }}"
{{- end }}