Menu
myezbrew
  • Privacy Policy
  • prometheus documentation
myezbrew

Prometheus Alertmanager

Posted on August 13, 2023August 20, 2023 by Andy Jenkins
Follow us on Social Media
linkedin

using:

  • flux api
  • helm api
  • kustomize

TODO:

  • separate baseoverlay
  • create gitlab helm repository
  • split repo prometheus-community-lcars
    • k3d createdestroy
    • kustomizefluxhelm
  • Flux UIs / GUIs
  • wasdx
  • wasdx
  •  

Additional links:

  • Additional Scrape Configuration
  • Grafana Alertmanager blog
  • alermanager bug no slack api
  • helm.toolkit.fluxcd.io/v2beta1
  • flux/helm/values
  • kube-prometheus-stack hacks
  • HelmReleaseSpec
  • fluxcd.io: are-there-two-kustomization-types
  • flux troubleshooting cheatsheet
  • fluxcd.io:Manage Helm Releases
  • kuztomise: configMapGenerator
  • kuztomize-configmap-generatorsCustomizing Slack notifications
  • sync_prometheus_rules.py
  • Slack app support ?
  • Customizing Slack notifications
  • prom avatar
  • opsgenie_config
  • we
  •  
  • lcars
  • we

Create a confige map for the  kube-stack-prometheus-values.yaml using kustomize: configMapGenerator.

 

				
					❯ cat ./base/kustomization.yaml 
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- name: kube-prometheus-stack-values
  namespace: prometheus
  files:
  - ./kube-prometheus-stack-values.yaml
 ❯ kustomize build ./base/ | kubectl apply -f - 
configmap/kube-prometheus-stack-values-2799bk595k created
# proposed dir structure:
├── base
│   ├── deployment.yaml
│   ├── kustomization.yaml
│   └── service.yaml
└── overlays
    ├── dev
    │   ├── deployment-dev.yaml
    │   ├── kustomization.yaml
    │   └── service-dev.yaml
    ├── generators
    │   ├── deployment.yaml
    │   ├── files
    │   │   └── index.html
    │   ├── kustomization.yaml
    │   └── service.yaml
    └── prod
        ├── deployment-prod.yaml
        ├── kustomization.yaml
        └── service-prod.yaml
				
			

Sending a manual alert

				
					curl -H 'Content-Type: application/json' -d '[{"labels":{"alertname":"demo-alert","namespace":"demo","service":"Demo alert"}}]' http://alertmanager.localhost/api/v1/alerts
{"status":"success"}%
❯ curl -H 'Content-Type: application/json' -d '[{"labels":{"alertname":"InstanceDown","namespace":"kube-system","service":"Demo alert", "severity":"critical"}}]' http://alertmanager.localhost/api/v1/alerts
{"status":"success"}%
				
			

Fancy slack message

				
					global:
  resolve_timeout: 1m
  slack_api_url: 'https://hooks.slack.com/services/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'
route:
  receiver: 'slack-notifications'
receivers:
- name: 'slack-notifications'
  slack_configs:
  - channel: '#monitoring-instances'
    send_resolved: true
    icon_url: https://avatars3.githubusercontent.com/u/3380462
    title: |-
     [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}
     {{- if gt (len .CommonLabels) (len .GroupLabels) -}}
       {{" "}}(
       {{- with .CommonLabels.Remove .GroupLabels.Names }}
         {{- range $index, $label := .SortedPairs -}}
           {{ if $index }}, {{ end }}
           {{- $label.Name }}="{{ $label.Value -}}"
         {{- end }}
       {{- end -}}
       )
     {{- end }}
    text: >-
     {{ range .Alerts -}}
     *Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
     *Description:* {{ .Annotations.description }}
     *Details:*
       {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
       {{ end }}
     {{ end }}
				
			

Recent Posts

  • HAOS – Notes
  • Vger: Docker Images
  • Project: Duplicate Terraform Cloud Global Variable
  • PowerShell Crash Day
  • vger: Using a man in the middle terraform module

Recent Comments

    Archives

    • October 2023
    • September 2023
    • August 2023
    • March 2023
    • February 2023
    • November 2022
    • May 2022
    • April 2022
    • December 2021
    • October 2021
    • September 2021

    Categories

    • devops
    • docker images
    • prometheus
    • Prometheus Alerting
    • Uncategorized
    • vger

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    ©2025 myezbrew | WordPress Theme by Superb Themes