From 790ffa175bcf7e07406f16daedd62392a317dde8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Tue, 20 Sep 2022 12:22:49 +0300 Subject: [PATCH] prometheus-operator: Fix Alertmanager integration --- prometheus-operator/README.md | 11 ++++++++++- prometheus-operator/application.yml | 29 +++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/prometheus-operator/README.md b/prometheus-operator/README.md index 18bdd1a..3ee9518 100644 --- a/prometheus-operator/README.md +++ b/prometheus-operator/README.md @@ -9,7 +9,16 @@ kubectl create -n prometheus-operator configmap snmp-exporter --from-file=snmp.y kubectl apply -n prometheus-operator -f application.yml -f node-exporter.yml -f blackbox-exporter.yml -f snmp-exporter.yml -f mikrotik-exporter.yml ``` -# Mikrotik expoeter + +# Slack + +``` + kubectl create -n prometheus-operator secret generic slack-secrets \ + --from-literal=webhook-url=https://hooks.slack.com/services/... +``` + + +# Mikrotik exporter ``` kubectl create -n prometheus-operator secret generic mikrotik-exporter \ diff --git a/prometheus-operator/application.yml b/prometheus-operator/application.yml index 0fe2131..56cae76 100644 --- a/prometheus-operator/application.yml +++ b/prometheus-operator/application.yml @@ -1,4 +1,22 @@ --- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: AlertmanagerConfig +metadata: + name: alertmanager + labels: + app.kubernetes.io/name: alertmanager +spec: + route: + receiver: 'slack-notifications' + receivers: + - name: 'slack-notifications' + slackConfigs: + - channel: '#kube-prod' + sendResolved: true + apiURL: + name: slack-secrets + key: webhook-url +--- apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: @@ -15,6 +33,11 @@ kind: Alertmanager metadata: name: alertmanager spec: + alertmanagerConfigSelector: + matchLabels: + app.kubernetes.io/name: alertmanager + secrets: + - slack-secrets nodeSelector: dedicated: monitoring tolerations: @@ -52,10 +75,8 @@ spec: alerting: alertmanagers: - namespace: prometheus-operator - name: alertmanager - port: http - pathPrefix: "/" - apiVersion: v2 + name: alertmanager-operated + port: web externalUrl: "http://prom.k-space.ee/" replicas: 2 shards: 1