Skip to content

Commit 2e5722d

Browse files
authored
matrix-alertmanager-receiver (#10)
* relese matrix-alertmanager-receiver
1 parent 07276c3 commit 2e5722d

File tree

7 files changed

+243
-0
lines changed

7 files changed

+243
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
helm repo add code-tool https://code-tool.github.io/matrix-stack/
88
```
99

10+
1011
## Charts overview
1112

1213
1. `synapse` - for setting up matrix workers, MAS, sliding-sync, admin component
1314
1. `ldap` - for setting up LDAP proxy
1415
1. `sentry-webhook` - for webhook from sentry to matrix chat
1516
1. `webhook` - for webhook from slack-compatible clients to matrix chat
17+
1. `matrix-alertmanager-receiver` - for webhook from Prometheus Alertmanager to matrix chat
1618

1719

1820
## Visualisation
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: matrix-alertmanager-receiver
3+
version: 0.0.1
4+
sources:
5+
- https://github.com/metio/matrix-alertmanager-receiver
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: matrix-alertmanager-receiver
6+
labels:
7+
app: synapse
8+
component: matrix-alertmanager-receiver
9+
data:
10+
matrix-alertmanager-receiver.yaml: |
11+
12+
http:
13+
port: {{ .Values.service.targetPort }}
14+
alerts-path-prefix: /alerts
15+
metrics-path: /metrics
16+
metrics-enabled: true
17+
18+
matrix:
19+
homeserver-url: {{ .Values.matrix.homeserverUrl }}
20+
user-id: {{ .Values.matrix.userId | quote }}
21+
access-token: {{ .Values.matrix.accessToken }}
22+
room-mapping:
23+
{{- range $k, $v := .Values.matrix.roomMapping }}
24+
{{ $k }}: {{ $v | quote }}
25+
{{- end }}
26+
27+
templating:
28+
{{- if .Values.templating.externalUrlMapping }}
29+
external-url-mapping:
30+
{{- range $k, $v := .Values.templating.externalUrlMapping }}
31+
{{ $k | quote }}: {{ $v }}
32+
{{- end }}
33+
{{- end }}
34+
35+
{{- if .Values.templating.generatorUrlMapping }}
36+
generator-url-mapping:
37+
{{- range $k, $v := .Values.templating.generatorUrlMapping }}
38+
{{ $k | quote }}: {{ $v }}
39+
{{- end }}
40+
{{- end }}
41+
42+
{{- if .Values.templating.computedValues }}
43+
computed-values:
44+
{{ toYaml .Values.templating.computedValues | nindent 8 }}
45+
{{- end }}
46+
47+
# template for alerts in status 'firing'
48+
firing-template: '
49+
<p>
50+
<strong><font color="{{`{{ .ComputedValues.color }}`}}">{{`{{ .Alert.Status | ToUpper }}`}}</font></strong>
51+
{{`{{ if .Alert.Labels.name }}`}}
52+
{{`{{ .Alert.Labels.name }}`}}
53+
{{`{{ else if .Alert.Labels.alertname }}`}}
54+
{{`{{ .Alert.Labels.alertname }}`}}
55+
{{`{{ end }}`}}
56+
>>
57+
{{`{{ if .Alert.Labels.severity }}`}}
58+
{{`{{ .Alert.Labels.severity | ToUpper }}`}}:
59+
{{`{{ end }}`}}
60+
{{`{{ if .Alert.Annotations.description }}`}}
61+
{{`{{ .Alert.Annotations.description }}`}}
62+
{{`{{ else if .Alert.Annotations.summary }}`}}
63+
{{`{{ .Alert.Annotations.summary }}`}}
64+
{{`{{ end }}`}}
65+
>>
66+
{{`{{ if .Alert.Annotations.runbook }}`}}
67+
<a href="{{`{{ .Alert.Annotations.runbook }}`}}">Runbook</a> |
68+
{{`{{ end }}`}}
69+
{{`{{ if .Alert.Annotations.dashboard }}`}}
70+
<a href="{{`{{ .Alert.Annotations.dashboard }}`}}">Dashboard</a> |
71+
{{`{{ end }}`}}
72+
<a href="{{`{{ .SilenceURL }}`}}">Silence</a>
73+
</p>'
74+
75+
# template for alerts in status 'resolved', if not specified will use the firing-template
76+
resolved-template: '
77+
<strong><font color="{{`{{ .ComputedValues.color }}`}}">{{`{{ .Alert.Status | ToUpper }}`}}</font></strong>{{`{{ .Alert.Labels.name }}`}}'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: matrix-alertmanager-receiver
6+
labels:
7+
app: matrix-alertmanager-receiver
8+
spec:
9+
replicas: {{ .Values.replicas }}
10+
selector:
11+
matchLabels:
12+
app: matrix-alertmanager-receiver
13+
template:
14+
metadata:
15+
labels:
16+
app: matrix-alertmanager-receiver
17+
spec:
18+
containers:
19+
- name: matrix-alertmanager-receiver
20+
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
21+
imagePullPolicy: {{ .Values.image.pullPolicy }}
22+
args: [
23+
"--config-path",
24+
"/etc/matrix-alertmanager-receiver.yaml",
25+
"--log-level",
26+
{{ .Values.logLevel | quote }}
27+
]
28+
resources:
29+
{{ toYaml .Values.resources | nindent 10 }}
30+
env:
31+
ports:
32+
- containerPort: {{ .Values.service.targetPort }}
33+
name: http
34+
protocol: TCP
35+
volumeMounts:
36+
- name: config
37+
mountPath: /etc/matrix-alertmanager-receiver.yaml
38+
subPath: matrix-alertmanager-receiver.yaml
39+
terminationGracePeriodSeconds: 10
40+
{{- if .Values.nodeSelector }}
41+
nodeSelector:
42+
{{ toYaml .Values.nodeSelector | nindent 8 }}
43+
{{- end }}
44+
{{- if .Values.tolerations }}
45+
tolerations:
46+
{{ toYaml .Values.tolerations | nindent 8 }}
47+
{{- end }}
48+
{{- if .Values.affinity }}
49+
affinity:
50+
{{ toYaml .Values.affinity | nindent 8 }}
51+
{{- end }}
52+
volumes:
53+
- name: config
54+
configMap:
55+
name: matrix-alertmanager-receiver
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.ingress.enabled }}
2+
---
3+
apiVersion: networking.k8s.io/v1
4+
kind: Ingress
5+
metadata:
6+
name: matrix-alertmanager-receiver
7+
spec:
8+
{{- if .Values.ingress.ingressClassName }}
9+
ingressClassName: {{ .Values.ingress.ingressClassName }}
10+
{{- end }}
11+
{{- if .Values.ingress.tls }}
12+
tls: {{ toYaml .Values.ingress.tls | nindent 4 }}
13+
{{- end }}
14+
rules:
15+
- host: {{ .Values.ingress.host }}
16+
http:
17+
paths:
18+
- pathType: ImplementationSpecific
19+
backend:
20+
service:
21+
name: matrix-alertmanager-receiver
22+
port:
23+
number: 80
24+
path: /
25+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: matrix-alertmanager-receiver
6+
spec:
7+
selector:
8+
app: matrix-alertmanager-receiver
9+
ports:
10+
- name: http
11+
port: 80
12+
targetPort: {{ .Values.service.targetPort }}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
replicas: 1
2+
3+
logLevel: 'info' # error, warn, debug, info
4+
5+
image:
6+
repository: 'jushcherbak/matrix-alertmanager-receiver'
7+
tag: '2024.10.16'
8+
pullPolicy: IfNotPresent
9+
10+
service:
11+
targetPort: 12345
12+
13+
# configuration for the Matrix connection
14+
matrix:
15+
# FQDN of the homeserver
16+
homeserverUrl: '' # https://matrix.example.com
17+
# ID of the user used by this service
18+
userId: '' # "@user:matrix.example.com"
19+
# Access token for the user ID
20+
accessToken: '' # secret
21+
# define short names for Matrix room ID
22+
roomMapping: {}
23+
# simple-name: "!qohfwef7qwerf:example.com"
24+
25+
templating:
26+
# mapping of ExternalURL values
27+
externalUrlMapping: {}
28+
# key is the original value taken from the Alertmanager payload
29+
# value is the mapped value which will be available as '.ExternalURL' in templates
30+
# "http://alertmanager:9093": https://alertmanager.example.com
31+
# mapping of GeneratorURL values
32+
generatorUrlMapping: {}
33+
# key is the original value taken from the Alertmanager payload
34+
# value is the mapped value which will be available as '.GeneratorURL' in templates
35+
# "http://prometheus:8080": https://prometheus.example.com
36+
# computation of arbitrary values based on matching alert annotations, labels, or status
37+
# values will be evaluated top to bottom, last entry wins
38+
computedValues:
39+
- values: # always set 'color' to 'yellow'
40+
color: yellow
41+
- values: # set 'color' to 'orange' when alert label 'severity' is 'warning'
42+
color: orange
43+
when-matching-labels:
44+
severity: warning
45+
- values: # set 'color' to 'red' when alert label 'severity' is 'critical'
46+
color: red
47+
when-matching-labels:
48+
severity: critical
49+
- values: # set 'color' to 'green' when alert status is 'resolved'
50+
color: green
51+
when-matching-status: resolved
52+
53+
54+
resources: {}
55+
nodeSelector: {}
56+
tolerations: []
57+
affinity: {}
58+
59+
ingress:
60+
enabled: false
61+
host: ""
62+
ingressClassName: ""
63+
tls: []
64+
#tls:
65+
# - hosts:
66+
# - {{ .Values.ingress.host }}
67+
# secretName: {{ .Values.ingress.host }}

0 commit comments

Comments
 (0)