Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kube-prometheus-stack): use native alertmanager telegram integration #1821

Closed

Conversation

martinohmann
Copy link
Owner

No description provided.

@github-actions github-actions bot added area/kubernetes Changes made in the kubernetes directory cluster/main labels Jan 19, 2025
Copy link

kustomization changes in kubernetes/main

--- kubernetes/main/apps/monitoring/alertmanager-telegram/app Kustomization: flux-system/alertmanager-telegram HelmRelease: monitoring/alertmanager-telegram

+++ kubernetes/main/apps/monitoring/alertmanager-telegram/app Kustomization: flux-system/alertmanager-telegram HelmRelease: monitoring/alertmanager-telegram

@@ -1,61 +0,0 @@

----
-apiVersion: helm.toolkit.fluxcd.io/v2
-kind: HelmRelease
-metadata:
-  labels:
-    app.kubernetes.io/name: alertmanager-telegram
-    kustomize.toolkit.fluxcd.io/name: alertmanager-telegram
-    kustomize.toolkit.fluxcd.io/namespace: flux-system
-  name: alertmanager-telegram
-  namespace: monitoring
-spec:
-  chart:
-    spec:
-      chart: app-template
-      sourceRef:
-        kind: HelmRepository
-        name: bjw-s
-        namespace: flux-system
-      version: 3.6.1
-  install:
-    remediation:
-      retries: 3
-  interval: 2h
-  maxHistory: 2
-  uninstall:
-    keepHistory: false
-  upgrade:
-    cleanupOnFail: true
-    remediation:
-      retries: 3
-      strategy: uninstall
-  values:
-    controllers:
-      alertmanager-telegram:
-        containers:
-          app:
-            envFrom:
-            - secretRef:
-                name: alertmanager-telegram
-            image:
-              repository: ghcr.io/janw/alertmanager-telegram
-              tag: edge@sha256:f15f5c620872a4e38fe9af7ba3d3ddc56195ae0660ebb83526805e909f2ceb86
-            resources:
-              limits:
-                memory: 200Mi
-              requests:
-                cpu: 5m
-                memory: 60Mi
-        pod:
-          securityContext:
-            runAsGroup: 568
-            runAsUser: 568
-        replicas: 1
-        strategy: RollingUpdate
-    service:
-      app:
-        controller: alertmanager-telegram
-        ports:
-          http:
-            port: 8080
-
--- kubernetes/main/apps/monitoring/kube-prometheus-stack/app Kustomization: flux-system/kube-prometheus-stack AlertmanagerConfig: monitoring/alertmanager

+++ kubernetes/main/apps/monitoring/kube-prometheus-stack/app Kustomization: flux-system/kube-prometheus-stack AlertmanagerConfig: monitoring/alertmanager

@@ -21,15 +21,32 @@

     - matchType: =
       name: severity
       value: warning
   receivers:
   - name: 'null'
   - name: telegram
-    webhookConfigs:
-    - sendResolved: true
-      url: http://alertmanager-telegram.monitoring.svc.cluster.local:8080/alerts
+    telegramConfigs:
+    - botToken:
+        key: token
+        name: alertmanager-telegram
+      chatID: ..PLACEHOLDER_SECRET_ALERTMANAGER_TELEGRAM_CHAT_ID..
+      message: "{{- $root := . -}}\n{{ if eq .Status \"firing\" -}}\n\U0001F469\u200D\
+        \U0001F692\n{{- else -}}\n\U0001F37B\n{{- end -}}\n<b>{{ .Status | title }}:\
+        \ {{ .CommonLabels.alertname }} ({{ .Alerts | len }})</b>\n{{- if and (eq\
+        \ .Status \"firing\") (eq .CommonLabels.severity \"critical\") }} \u203C\uFE0F\
+        \n{{- end }}\n{{ if .CommonAnnotations.summary }}\n{{ .CommonAnnotations.summary\
+        \ | trimSpace }}\n{{ end -}}\n{{ range .CommonAnnotations.SortedPairs }}\n\
+        {{- if ne .Name \"summary\" }}\n<b>{{ .Name }}:</b> {{ .Value }}\n{{- end\
+        \ -}}\n{{- end }}\n{{ range .CommonLabels.SortedPairs }}\n{{- if ne .Name\
+        \ \"alertname\" }}\n<b>{{ .Name }}:</b> <code>{{ .Value }}</code>\n{{- end\
+        \ -}}\n{{- end }}\n{{ range .Alerts }}\n{{- $annotations := .Annotations.Remove\
+        \ $root.CommonAnnotations.Names -}}\n{{- range $annotations.SortedPairs }}\n\
+        <b>{{ .Name }}:</b> {{ .Value }}\n{{- end }}\n{{- $labels := .Labels.Remove\
+        \ $root.CommonLabels.Names -}}\n{{- range $labels.SortedPairs }}\n<b>{{ .Name\
+        \ }}:</b> <code>{{ .Value }}</code>\n{{- end }}\n\n<a href=\"{{ .GeneratorURL\
+        \ }}\">Go to source</a>\n{{ end }}\n<a href=\"{{ .ExternalURL }}\">Go to Alertmanager</a>\n"
   route:
     groupBy:
     - alertname
     - job
     groupInterval: 10m
     groupWait: 1m
--- kubernetes/main/apps Kustomization: flux-system/cluster-apps Kustomization: flux-system/alertmanager-telegram

+++ kubernetes/main/apps Kustomization: flux-system/cluster-apps Kustomization: flux-system/alertmanager-telegram

@@ -1,32 +0,0 @@

----
-apiVersion: kustomize.toolkit.fluxcd.io/v1
-kind: Kustomization
-metadata:
-  labels:
-    kustomize.toolkit.fluxcd.io/name: cluster-apps
-    kustomize.toolkit.fluxcd.io/namespace: flux-system
-  name: alertmanager-telegram
-  namespace: flux-system
-spec:
-  commonMetadata:
-    labels:
-      app.kubernetes.io/name: alertmanager-telegram
-  decryption:
-    provider: sops
-    secretRef:
-      name: sops-age
-  interval: 2h
-  path: ./kubernetes/main/apps/monitoring/alertmanager-telegram/app
-  postBuild:
-    substituteFrom:
-    - kind: Secret
-      name: cluster-secrets
-  prune: true
-  retryInterval: 1m
-  sourceRef:
-    kind: GitRepository
-    name: home-kubernetes
-  targetNamespace: monitoring
-  timeout: 5m
-  wait: false
-

Copy link

helmrelease changes in kubernetes/main

--- HelmRelease: monitoring/alertmanager-telegram Service: monitoring/alertmanager-telegram

+++ HelmRelease: monitoring/alertmanager-telegram Service: monitoring/alertmanager-telegram

@@ -1,22 +0,0 @@

----
-apiVersion: v1
-kind: Service
-metadata:
-  name: alertmanager-telegram
-  labels:
-    app.kubernetes.io/instance: alertmanager-telegram
-    app.kubernetes.io/managed-by: Helm
-    app.kubernetes.io/name: alertmanager-telegram
-    app.kubernetes.io/service: alertmanager-telegram
-spec:
-  type: ClusterIP
-  ports:
-  - port: 8080
-    targetPort: 8080
-    protocol: TCP
-    name: http
-  selector:
-    app.kubernetes.io/component: alertmanager-telegram
-    app.kubernetes.io/instance: alertmanager-telegram
-    app.kubernetes.io/name: alertmanager-telegram
-
--- HelmRelease: monitoring/alertmanager-telegram Deployment: monitoring/alertmanager-telegram

+++ HelmRelease: monitoring/alertmanager-telegram Deployment: monitoring/alertmanager-telegram

@@ -1,50 +0,0 @@

----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  name: alertmanager-telegram
-  labels:
-    app.kubernetes.io/component: alertmanager-telegram
-    app.kubernetes.io/instance: alertmanager-telegram
-    app.kubernetes.io/managed-by: Helm
-    app.kubernetes.io/name: alertmanager-telegram
-spec:
-  revisionHistoryLimit: 3
-  replicas: 1
-  strategy:
-    type: RollingUpdate
-  selector:
-    matchLabels:
-      app.kubernetes.io/component: alertmanager-telegram
-      app.kubernetes.io/name: alertmanager-telegram
-      app.kubernetes.io/instance: alertmanager-telegram
-  template:
-    metadata:
-      labels:
-        app.kubernetes.io/component: alertmanager-telegram
-        app.kubernetes.io/instance: alertmanager-telegram
-        app.kubernetes.io/name: alertmanager-telegram
-    spec:
-      enableServiceLinks: false
-      serviceAccountName: default
-      automountServiceAccountToken: true
-      securityContext:
-        runAsGroup: 568
-        runAsUser: 568
-      hostIPC: false
-      hostNetwork: false
-      hostPID: false
-      dnsPolicy: ClusterFirst
-      containers:
-      - envFrom:
-        - secretRef:
-            name: alertmanager-telegram
-        image: ghcr.io/janw/alertmanager-telegram:edge@sha256:f15f5c620872a4e38fe9af7ba3d3ddc56195ae0660ebb83526805e909f2ceb86
-        name: app
-        resources:
-          limits:
-            memory: 200Mi
-          requests:
-            cpu: 5m
-            memory: 60Mi
-

@martinohmann
Copy link
Owner Author

Maybe another day

@martinohmann martinohmann deleted the kube-prometheus-stack/native-alertmanager-telegram branch January 19, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes Changes made in the kubernetes directory cluster/main
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant