diff --git a/README.md b/README.md index 11cd956..b8aa6a5 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,14 @@ helm repo add code-tool https://code-tool.github.io/matrix-stack/ ``` + ## Charts overview 1. `synapse` - for setting up matrix workers, MAS, sliding-sync, admin component 1. `ldap` - for setting up LDAP proxy 1. `sentry-webhook` - for webhook from sentry to matrix chat 1. `webhook` - for webhook from slack-compatible clients to matrix chat +1. `matrix-alertmanager-receiver` - for webhook from Prometheus Alertmanager to matrix chat ## Visualisation diff --git a/charts/matrix-alertmanager-receiver/Chart.yaml b/charts/matrix-alertmanager-receiver/Chart.yaml new file mode 100644 index 0000000..01e3ad6 --- /dev/null +++ b/charts/matrix-alertmanager-receiver/Chart.yaml @@ -0,0 +1,5 @@ +--- +name: matrix-alertmanager-receiver +version: 0.0.1 +sources: + - https://github.com/metio/matrix-alertmanager-receiver diff --git a/charts/matrix-alertmanager-receiver/templates/configmap.yaml b/charts/matrix-alertmanager-receiver/templates/configmap.yaml new file mode 100644 index 0000000..223ab50 --- /dev/null +++ b/charts/matrix-alertmanager-receiver/templates/configmap.yaml @@ -0,0 +1,77 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: matrix-alertmanager-receiver + labels: + app: synapse + component: matrix-alertmanager-receiver +data: + matrix-alertmanager-receiver.yaml: | + + http: + port: {{ .Values.service.targetPort }} + alerts-path-prefix: /alerts + metrics-path: /metrics + metrics-enabled: true + + matrix: + homeserver-url: {{ .Values.matrix.homeserverUrl }} + user-id: {{ .Values.matrix.userId | quote }} + access-token: {{ .Values.matrix.accessToken }} + room-mapping: + {{- range $k, $v := .Values.matrix.roomMapping }} + {{ $k }}: {{ $v | quote }} + {{- end }} + + templating: + {{- if .Values.templating.externalUrlMapping }} + external-url-mapping: + {{- range $k, $v := .Values.templating.externalUrlMapping }} + {{ $k | quote }}: {{ $v }} + {{- end }} + {{- end }} + + {{- if .Values.templating.generatorUrlMapping }} + generator-url-mapping: + {{- range $k, $v := .Values.templating.generatorUrlMapping }} + {{ $k | quote }}: {{ $v }} + {{- end }} + {{- end }} + + {{- if .Values.templating.computedValues }} + computed-values: + {{ toYaml .Values.templating.computedValues | nindent 8 }} + {{- end }} + + # template for alerts in status 'firing' + firing-template: ' +

+ {{`{{ .Alert.Status | ToUpper }}`}} + {{`{{ if .Alert.Labels.name }}`}} + {{`{{ .Alert.Labels.name }}`}} + {{`{{ else if .Alert.Labels.alertname }}`}} + {{`{{ .Alert.Labels.alertname }}`}} + {{`{{ end }}`}} + >> + {{`{{ if .Alert.Labels.severity }}`}} + {{`{{ .Alert.Labels.severity | ToUpper }}`}}: + {{`{{ end }}`}} + {{`{{ if .Alert.Annotations.description }}`}} + {{`{{ .Alert.Annotations.description }}`}} + {{`{{ else if .Alert.Annotations.summary }}`}} + {{`{{ .Alert.Annotations.summary }}`}} + {{`{{ end }}`}} + >> + {{`{{ if .Alert.Annotations.runbook }}`}} + Runbook | + {{`{{ end }}`}} + {{`{{ if .Alert.Annotations.dashboard }}`}} + Dashboard | + {{`{{ end }}`}} + Silence +

' + + # template for alerts in status 'resolved', if not specified will use the firing-template + resolved-template: ' + {{`{{ .Alert.Status | ToUpper }}`}}{{`{{ .Alert.Labels.name }}`}}' diff --git a/charts/matrix-alertmanager-receiver/templates/deployment.yaml b/charts/matrix-alertmanager-receiver/templates/deployment.yaml new file mode 100644 index 0000000..d19785a --- /dev/null +++ b/charts/matrix-alertmanager-receiver/templates/deployment.yaml @@ -0,0 +1,55 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: matrix-alertmanager-receiver + labels: + app: matrix-alertmanager-receiver +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app: matrix-alertmanager-receiver + template: + metadata: + labels: + app: matrix-alertmanager-receiver + spec: + containers: + - name: matrix-alertmanager-receiver + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: [ + "--config-path", + "/etc/matrix-alertmanager-receiver.yaml", + "--log-level", + {{ .Values.logLevel | quote }} + ] + resources: + {{ toYaml .Values.resources | nindent 10 }} + env: + ports: + - containerPort: {{ .Values.service.targetPort }} + name: http + protocol: TCP + volumeMounts: + - name: config + mountPath: /etc/matrix-alertmanager-receiver.yaml + subPath: matrix-alertmanager-receiver.yaml + terminationGracePeriodSeconds: 10 + {{- if .Values.nodeSelector }} + nodeSelector: + {{ toYaml .Values.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: + {{ toYaml .Values.tolerations | nindent 8 }} + {{- end }} + {{- if .Values.affinity }} + affinity: + {{ toYaml .Values.affinity | nindent 8 }} + {{- end }} + volumes: + - name: config + configMap: + name: matrix-alertmanager-receiver diff --git a/charts/matrix-alertmanager-receiver/templates/ingress.yaml b/charts/matrix-alertmanager-receiver/templates/ingress.yaml new file mode 100644 index 0000000..c942feb --- /dev/null +++ b/charts/matrix-alertmanager-receiver/templates/ingress.yaml @@ -0,0 +1,25 @@ +{{- if .Values.ingress.enabled }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: matrix-alertmanager-receiver +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: {{ toYaml .Values.ingress.tls | nindent 4 }} + {{- end }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - pathType: ImplementationSpecific + backend: + service: + name: matrix-alertmanager-receiver + port: + number: 80 + path: / +{{- end }} diff --git a/charts/matrix-alertmanager-receiver/templates/service.yaml b/charts/matrix-alertmanager-receiver/templates/service.yaml new file mode 100644 index 0000000..6c75346 --- /dev/null +++ b/charts/matrix-alertmanager-receiver/templates/service.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: matrix-alertmanager-receiver +spec: + selector: + app: matrix-alertmanager-receiver + ports: + - name: http + port: 80 + targetPort: {{ .Values.service.targetPort }} diff --git a/charts/matrix-alertmanager-receiver/values.yaml b/charts/matrix-alertmanager-receiver/values.yaml new file mode 100644 index 0000000..81498d6 --- /dev/null +++ b/charts/matrix-alertmanager-receiver/values.yaml @@ -0,0 +1,67 @@ +replicas: 1 + +logLevel: 'info' # error, warn, debug, info + +image: + repository: 'jushcherbak/matrix-alertmanager-receiver' + tag: '2024.10.16' + pullPolicy: IfNotPresent + +service: + targetPort: 12345 + +# configuration for the Matrix connection +matrix: + # FQDN of the homeserver + homeserverUrl: '' # https://matrix.example.com + # ID of the user used by this service + userId: '' # "@user:matrix.example.com" + # Access token for the user ID + accessToken: '' # secret + # define short names for Matrix room ID + roomMapping: {} + # simple-name: "!qohfwef7qwerf:example.com" + +templating: + # mapping of ExternalURL values + externalUrlMapping: {} + # key is the original value taken from the Alertmanager payload + # value is the mapped value which will be available as '.ExternalURL' in templates + # "http://alertmanager:9093": https://alertmanager.example.com + # mapping of GeneratorURL values + generatorUrlMapping: {} + # key is the original value taken from the Alertmanager payload + # value is the mapped value which will be available as '.GeneratorURL' in templates + # "http://prometheus:8080": https://prometheus.example.com + # computation of arbitrary values based on matching alert annotations, labels, or status + # values will be evaluated top to bottom, last entry wins + computedValues: + - values: # always set 'color' to 'yellow' + color: yellow + - values: # set 'color' to 'orange' when alert label 'severity' is 'warning' + color: orange + when-matching-labels: + severity: warning + - values: # set 'color' to 'red' when alert label 'severity' is 'critical' + color: red + when-matching-labels: + severity: critical + - values: # set 'color' to 'green' when alert status is 'resolved' + color: green + when-matching-status: resolved + + +resources: {} +nodeSelector: {} +tolerations: [] +affinity: {} + +ingress: + enabled: false + host: "" + ingressClassName: "" + tls: [] + #tls: + # - hosts: + # - {{ .Values.ingress.host }} + # secretName: {{ .Values.ingress.host }}