add prometheus-msteams (#3)
This commit is contained in:
parent
9a061e52f9
commit
c2c3ccabd9
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
apiVersion: v1
|
||||||
|
description: Alertmanager Webhook for Microsoft Teams
|
||||||
|
name: prometheus-msteams
|
||||||
|
version: 1.0.0
|
||||||
|
appVersion: 1.1.5
|
||||||
|
home: https://github.com/bzon/prometheus-msteams
|
||||||
|
sources:
|
||||||
|
- https://github.com/bzon/prometheus-msteams
|
||||||
|
- https://github.com/code-chris/helm-charts
|
||||||
|
keywords:
|
||||||
|
- prometheus
|
||||||
|
- msteams
|
||||||
|
- webhook
|
||||||
|
- alertmanager
|
||||||
|
maintainers:
|
||||||
|
- name: code-chris
|
||||||
|
email: christian.kotzbauer@gmail.com
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
# Prometheus MSTeams
|
||||||
|
|
||||||
|
Alertmanager Webhook for Microsoft Teams
|
||||||
|
|
||||||
|
Learn more: [https://github.com/bzon/prometheus-msteams](https://github.com/bzon/prometheus-msteams)
|
||||||
|
|
||||||
|
## TL;DR;
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ helm install code-chris/prometheus-msteams
|
||||||
|
```
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
This chart creates a Webhook deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Kubernetes 1.9+
|
||||||
|
|
||||||
|
## Installing the Chart
|
||||||
|
|
||||||
|
To install the chart with the release name `my-release`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ helm install --name my-release code-chris/prometheus-msteams
|
||||||
|
```
|
||||||
|
|
||||||
|
The command deploys this Webhook on the Kubernetes cluster using the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
|
||||||
|
|
||||||
|
## Uninstalling the Chart
|
||||||
|
|
||||||
|
To uninstall/delete the `my-release` deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ helm delete my-release
|
||||||
|
```
|
||||||
|
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The following table lists the configurable parameters of the Prometheus MSTeams chart and their default values.
|
||||||
|
|
||||||
|
| Parameter | Description | Default |
|
||||||
|
| -------------------------------------- | ------------------------------------------------- | ----------------------------- |
|
||||||
|
| `replicaCount` | Instance count to deploy | 1 |
|
||||||
|
| `image.repository` | container image repository | `bzon/prometheus-msteams` |
|
||||||
|
| `image.tag` | container image tag | `v1.1.5` |
|
||||||
|
| `image.pullPolicy` | container image pull policy | `IfNotPresent` |
|
||||||
|
| `extraEnvs` | Optional env variables for webhook deployment | `[]` |
|
||||||
|
| `nodeSelector` | node labels for pod assignment | `{}` |
|
||||||
|
| `tolerations` | node tolerations for pod assignment | `[]` |
|
||||||
|
| `affinity` | node affinity for pod assignment | `{}` |
|
||||||
|
| `connectors` | MS Teams Connectors (URLs) | `{}` |
|
||||||
|
| `customCardTemplate` | Customized template for Team cards | `""` |
|
||||||
|
| `podAnnotations` | annotations to add to each pod | `{}` |
|
||||||
|
| `additionalArgs` | additional container arguments | `[]` |
|
||||||
|
| `resources` | pod resource requests & limits | `{}` |
|
||||||
|
| `service.type` | type of service to create | `ClusterIP` |
|
||||||
|
| `service.port` | port for the blackbox http service | `9115` |
|
||||||
|
| `service.externalIPs` | list of external ips | `[]` |
|
||||||
|
| `service.loadBalancerIP` | optional load balancer ip | `""` |
|
||||||
|
| `service.loadBalancerSourceRanges` | optional load balancer source ranges | `[]` |
|
||||||
|
| `service.externalTrafficPolicy` | optional external traffic policy | `""` |
|
||||||
|
|
||||||
|
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ helm install --name my-release \
|
||||||
|
--set key_1=value_1,key_2=value_2 \
|
||||||
|
code-chris/prometheus-msteams
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# example for staging
|
||||||
|
$ helm install --name my-release -f values.yaml code-chris/prometheus-msteams
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Tip**: You can use the default [values.yaml](values.yaml)
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
{{ define "teams.card" }}
|
||||||
|
{
|
||||||
|
"@type": "MessageCard",
|
||||||
|
"@context": "http://schema.org/extensions",
|
||||||
|
"themeColor": "{{- if eq .Status "resolved" -}}2DC72D
|
||||||
|
{{- else if eq .Status "firing" -}}
|
||||||
|
{{- if eq .CommonLabels.severity "critical" -}}8C1A1A
|
||||||
|
{{- else if eq .CommonLabels.severity "warning" -}}FFA500
|
||||||
|
{{- else -}}808080{{- end -}}
|
||||||
|
{{- else -}}808080{{- end -}}",
|
||||||
|
"summary": "{{- if eq .CommonAnnotations.summary "" -}}
|
||||||
|
{{- if eq .CommonAnnotations.message "" -}}
|
||||||
|
{{- .CommonLabels.alertname -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .CommonAnnotations.message -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .CommonAnnotations.summary -}}
|
||||||
|
{{- end -}}",
|
||||||
|
"title": "Prometheus Alert ({{ .Status }})",
|
||||||
|
"sections": [ {{$externalUrl := .ExternalURL}}
|
||||||
|
{{- range $index, $alert := .Alerts }}{{- if $index }},{{- end }}
|
||||||
|
{
|
||||||
|
"activityTitle": "[{{ $alert.Annotations.description }}]({{ $externalUrl }})",
|
||||||
|
"facts": [
|
||||||
|
{{- range $key, $value := $alert.Annotations }}
|
||||||
|
{
|
||||||
|
"name": "{{ reReplaceAll "_" "\\\\_" $key }}",
|
||||||
|
"value": "{{ reReplaceAll "_" "\\\\_" $value }}"
|
||||||
|
},
|
||||||
|
{{- end -}}
|
||||||
|
{{$c := counter}}{{ range $key, $value := $alert.Labels }}{{if call $c}},{{ end }}
|
||||||
|
{
|
||||||
|
"name": "{{ reReplaceAll "_" "\\\\_" $key }}",
|
||||||
|
"value": "{{ reReplaceAll "_" "\\\\_" $value }}"
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
],
|
||||||
|
"markdown": true
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{{ end }}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
** Please be patient while the chart is being deployed **
|
||||||
|
|
||||||
|
To monitor the deployment, execute the following command:
|
||||||
|
|
||||||
|
kubectl get pods -l app={{ template "app.name" . }} --namespace {{ .Release.Namespace }} -w
|
||||||
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "app.name" -}}
|
||||||
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create a default fully qualified app.name.
|
||||||
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||||
|
If release name contains chart name it will be used as a full name.
|
||||||
|
*/}}
|
||||||
|
{{- define "app.fullname" -}}
|
||||||
|
{{- if .Values.fullnameOverride -}}
|
||||||
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||||
|
{{- if contains $name .Release.Name -}}
|
||||||
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create chart name and version as used by the chart label.
|
||||||
|
*/}}
|
||||||
|
{{- define "app.chart" -}}
|
||||||
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for deployment.
|
||||||
|
*/}}
|
||||||
|
{{- define "deployment.apiVersion" -}}
|
||||||
|
{{- if semverCompare ">=1.9-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||||
|
{{- print "apps/v1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apps/v1beta2" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ template "app.name" . }}-config
|
||||||
|
data:
|
||||||
|
connectors.yaml: |
|
||||||
|
{{- with $.Values.connectors }}
|
||||||
|
connectors:
|
||||||
|
{{ toYaml . | indent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ template "app.name" . }}-card-template
|
||||||
|
binaryData:
|
||||||
|
card.tmpl: |-
|
||||||
|
{{- if .Values.customCardTemplate }}
|
||||||
|
{{ .Values.customCardTemplate | b64enc | indent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
{{ .Files.Get "card.tmpl" | b64enc | indent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
apiVersion: {{ template "deployment.apiVersion" . }}
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ template "app.name" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "app.name" . }}
|
||||||
|
chart: {{ template "app.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ template "app.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ template "app.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
{{- if .Values.podAnnotations }}
|
||||||
|
annotations:
|
||||||
|
{{ toYaml .Values.podAnnotations | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: {{ template "app.name" . }}-config
|
||||||
|
- name: card-template-volume
|
||||||
|
configMap:
|
||||||
|
name: {{ template "app.name" . }}-card-template
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 1000
|
||||||
|
containers:
|
||||||
|
- name: {{ .Chart.Name }}
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
env:
|
||||||
|
{{- range $key, $value := $.Values.extraEnvs }}
|
||||||
|
- name: {{ $key }}
|
||||||
|
value: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config
|
||||||
|
- name: card-template-volume
|
||||||
|
mountPath: /etc/template
|
||||||
|
args:
|
||||||
|
- --config=/etc/config/connectors.yaml
|
||||||
|
- --template-file=/etc/template/card.tmpl
|
||||||
|
{{- with .Values.container.additionalArgs }}
|
||||||
|
{{ toYaml . | indent 12 }}
|
||||||
|
{{- end}}
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: {{ .Values.container.port }}
|
||||||
|
protocol: TCP
|
||||||
|
resources:
|
||||||
|
{{ toYaml .Values.resources | indent 12 }}
|
||||||
|
{{- with .Values.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.affinity }}
|
||||||
|
affinity:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.tolerations }}
|
||||||
|
tolerations:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "app.name" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "app.name" . }}
|
||||||
|
chart: {{ template "app.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
{{- if eq .Values.service.type "LoadBalancer" }}
|
||||||
|
{{- if .Values.service.loadBalancerIP }}
|
||||||
|
loadBalancerIP: {{ .Values.service.loadBalancerIP | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.service.loadBalancerSourceRanges }}
|
||||||
|
loadBalancerSourceRanges:
|
||||||
|
{{- range .Values.service.loadBalancerSourceRanges }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.service.externalTrafficPolicy }}
|
||||||
|
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
|
{{- if .Values.service.externalIPs }}
|
||||||
|
externalIPs:
|
||||||
|
{{- toYaml .Values.service.externalIPs | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
selector:
|
||||||
|
app: {{ template "app.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: bzon/prometheus-msteams
|
||||||
|
tag: v1.1.5
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
extraEnvs:
|
||||||
|
|
||||||
|
container:
|
||||||
|
port: 2000
|
||||||
|
additionalArgs: []
|
||||||
|
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 32Mi
|
||||||
|
requests:
|
||||||
|
cpu: 1m
|
||||||
|
memory: 8Mi
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 2000
|
||||||
|
|
||||||
|
nodeSelector: {}
|
||||||
|
|
||||||
|
tolerations: []
|
||||||
|
|
||||||
|
affinity: {}
|
||||||
|
|
||||||
|
# Replace this!
|
||||||
|
connectors:
|
||||||
|
- alertmanager: https://outlook.office.com/webhook/xxxxx/IncomingWebhook/xxxx/xxxxx
|
||||||
|
|
||||||
|
|
||||||
|
## Specify the custom message card template for MS teams
|
||||||
|
# customCardTemplate: |
|
||||||
|
# {{ define "teams.card" }}
|
||||||
|
# {
|
||||||
|
#
|
||||||
|
# }
|
||||||
|
# {{ end }}
|
||||||
Loading…
Reference in New Issue