fix(alertmanager-matrix): add flow for logging operator

This commit is contained in:
WrenIX 2023-11-29 10:32:40 +01:00
parent b8589f83e7
commit 35b90df760
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
6 changed files with 85 additions and 15 deletions

View file

@ -2,8 +2,8 @@ apiVersion: v2
name: alertmanager-matrix
description: Service for managing and receiving Alertmanager alerts on Matrix
type: application
version: 0.1.3
version: 0.1.4
appVersion: "latest"
keywords:
- matrix
- alertmanager
- alertmanager

View file

@ -1,6 +1,6 @@
# alertmanager-matrix
![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 0.1.4](https://img.shields.io/badge/Version-0.1.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
Service for managing and receiving Alertmanager alerts on Matrix
@ -60,7 +60,7 @@ helm uninstall alertmanager-matrix-release
| bot.messageType | string | `"m.notice"` | |
| bot.showLabels | bool | `false` | |
| bot.template.html | string | `"{{ range .Alerts }}\n <font color=\"{{.StatusString|color}}\">\n {{.StatusString|icon}}\n <b>{{.StatusString|upper}}</b>\n {{.AlertName}}:\n </font>\n {{.Summary}}\n {{if ne .Fingerprint \"\"}}\n ({{.Fingerprint}})\n {{end}}\n {{if $.ShowLabels}}\n <br/>\n <b>Labels:</b>\n <code>{{.LabelString}}</code>\n {{end}}\n <br/>\n{{- end -}}\n"` | |
| bot.template.text | string | `"{{ range .Alerts }}\n {{.StatusString|icon}}\n {{.StatusString|upper}}\n {{.AlertName}}:\n {{.Summary}}\n {{if ne .Fingerprint \"\"}}\n ({{.Fingerprint}})\n {{end}}\n {{if $.ShowLabels}}\n , labels:\n {{.LabelString}}\n {{end}}\n \\n\n{{ end -}}\n"` | |
| bot.template.text | string | `"{{ range .Alerts }}\n {{- .StatusString|icon}} {{ .StatusString|upper }}{{ .AlertName }}: {{ .Summary }} {{ if ne .Fingerprint \"\" -}}\n ({{.Fingerprint}})\n {{- end}}\n {{- if $.ShowLabels -}}\n , labels:\n {{- .LabelString}}\n {{- end }}\n{{ end -}}\n"` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.registry | string | `"docker.io"` | |
@ -74,6 +74,11 @@ helm uninstall alertmanager-matrix-release
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| logging.additionalFilters | list | `[]` | Add other filters to Flow |
| logging.dedot | string | `nil` | if an filter (here or global) for dedot is active - for disable set `null` |
| logging.enabled | bool | `false` | Deploy Flow for [Logging-Operator](https://kube-logging.github.io/docs/) |
| logging.globalOutputRefs | list | `["default"]` | Flows globalOutputRefs for use of ClusterOutputs |
| logging.localOutputRefs | list | `[]` | Flows localOutputRefs for use of Outputs |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |

View file

@ -50,6 +50,19 @@ app.kubernetes.io/name: {{ include "alertmanager-matrix.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Selector Log labels
*/}}
{{- define "alertmanager-matrix.selectorLogLabels" -}}
{{- if .Values.logging.dedot }}
app{{.Values.logging.dedot }}kubernetes{{.Values.logging.dedot }}io/name: {{ include "alertmanager-matrix.name" . }}
app{{.Values.logging.dedot }}kubernetes{{.Values.logging.dedot }}io/instance: {{ .Release.Name }}
{{- else }}
{{ include "alertmanager-matrix.selectorLabels" . }}
{{- end }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}

View file

@ -0,0 +1,41 @@
{{- with .Values.logging }}
{{- if .enabled }}
---
apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
name: {{ include "alertmanager-matrix.fullname" $ }}
spec:
match:
- select:
labels:
{{- include "alertmanager-matrix.selectorLogLabels" $ | nindent 10 }}
container_names:
- "{{ $.Chart.Name }}"
filters:
- parser:
reserve_data: true
remove_key_name_field: true
parse:
type: "multi_format"
patterns:
- format: "regexp"
expression: '^(?<time>\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2})\s(?<message>.*)'
time_key: "time"
time_type: "string"
time_format: "%Y/%m/%d %H:%M:%S"
- format: "none"
{{- with .additionalFilters }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .globalOutputRefs }}
globalOutputRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .localOutputRefs }}
localOutputRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -56,18 +56,13 @@ bot:
template:
text: >
{{ range .Alerts }}
{{.StatusString|icon}}
{{.StatusString|upper}}
{{.AlertName}}:
{{.Summary}}
{{if ne .Fingerprint ""}}
{{- .StatusString|icon}} {{ .StatusString|upper }}{{ .AlertName }}: {{ .Summary }} {{ if ne .Fingerprint "" -}}
({{.Fingerprint}})
{{end}}
{{if $.ShowLabels}}
{{- end}}
{{- if $.ShowLabels -}}
, labels:
{{.LabelString}}
{{end}}
\n
{{- .LabelString}}
{{- end }}
{{ end -}}
html: >
{{ range .Alerts }}
@ -88,6 +83,22 @@ bot:
<br/>
{{- end -}}
# Logging
# This Helm chart could also deploy Flow for the logging-operator
logging:
# -- Deploy Flow for [Logging-Operator](https://kube-logging.github.io/docs/)
enabled: false
# -- if an filter (here or global) for dedot is active - for disable set `null`
dedot:
# -- Add other filters to Flow
additionalFilters: []
# -- Flows localOutputRefs for use of Outputs
localOutputRefs: []
# -- Flows globalOutputRefs for use of ClusterOutputs
globalOutputRefs:
- "default"
serviceAccount:
# Specifies whether a service account should be created
create: true

View file

@ -6,7 +6,6 @@ helm-docs -t ./README.md.gotmpl -t _docs.gotmpl
for p in * ; do
if \
[ $p == "alertmanager-matrix" ] || \
[ $p == "alertmanager-ntfy" ] || \
[ $p == "conduit" ] || \
[ $p == "forgejo-runner" ] || \
@ -15,6 +14,7 @@ for p in * ; do
[ $p == "hydrogen-web" ] || \
[ $p == "miniserve" ] || \
[ $p == "monitoring" ] || \
[ $p == "postgresql" ] || \
[ "1" != "1" ] \
; then
continue