Skip to content

matrix-alertmanager-receiver #10

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

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions charts/matrix-alertmanager-receiver/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: matrix-alertmanager-receiver
version: 0.0.1
sources:
- https://github.com/metio/matrix-alertmanager-receiver
77 changes: 77 additions & 0 deletions charts/matrix-alertmanager-receiver/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -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: '
<p>
<strong><font color="{{`{{ .ComputedValues.color }}`}}">{{`{{ .Alert.Status | ToUpper }}`}}</font></strong>
{{`{{ 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 }}`}}
<a href="{{`{{ .Alert.Annotations.runbook }}`}}">Runbook</a> |
{{`{{ end }}`}}
{{`{{ if .Alert.Annotations.dashboard }}`}}
<a href="{{`{{ .Alert.Annotations.dashboard }}`}}">Dashboard</a> |
{{`{{ end }}`}}
<a href="{{`{{ .SilenceURL }}`}}">Silence</a>
</p>'

# template for alerts in status 'resolved', if not specified will use the firing-template
resolved-template: '
<strong><font color="{{`{{ .ComputedValues.color }}`}}">{{`{{ .Alert.Status | ToUpper }}`}}</font></strong>{{`{{ .Alert.Labels.name }}`}}'
55 changes: 55 additions & 0 deletions charts/matrix-alertmanager-receiver/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions charts/matrix-alertmanager-receiver/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/matrix-alertmanager-receiver/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
67 changes: 67 additions & 0 deletions charts/matrix-alertmanager-receiver/values.yaml
Original file line number Diff line number Diff line change
@@ -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 }}