feat: add disk exporter module and related configurations

- Introduced a new disk exporter module to monitor disk health using SMART data.
- Updated `apps.tf` to include the disk exporter module with necessary parameters.
- Added local variables for smartctl version and checksum in `config.tf`.
- Enhanced `alertmanager.yml` to handle DiskUnhealthy alerts with specific grouping and dispatch settings.
- Created new Prometheus rules for monitoring disk health, including alerts for unhealthy disks.
- Updated Prometheus configuration to scrape metrics from the new disk exporter.
- Enhanced Telegram notification template to include resolved alerts and improved formatting.
- Updated the auth-exporter module to specify the Python image tag correctly.
- Created the disk-exporter module with Kubernetes resources, including deployment, service account, and config map.
- Added necessary Python scripts and requirements for the disk exporter functionality.
This commit is contained in:
2025-10-06 18:41:01 +02:00
parent 0e167d747d
commit 429a94332e
19 changed files with 766 additions and 41 deletions
+28 -23
View File
@@ -1,28 +1,33 @@
{{- /* Resolved alerts (if any) */ -}}
{{- if gt (len .Alerts.Resolved) 1 -}}
<b>{{ len .Alerts.Resolved }} logins resolved</b> on {{ with .CommonLabels.cluster }}<b>{{ . }}</b>{{ else }}<b>unknown host</b>{{ end }}:
{{- range .Alerts.Resolved }}
{{ with .Labels.username }}<b>{{ . }}</b>{{ else }}<i>unknown</i>{{ end }} — Source: <code>{{ with .Labels.source }}{{ . }}{{ else }}?{{ end }}</code>{{ with .Labels.method }}, Method: <code>{{ . }}</code>{{ else }}, Method: <code>?</code>{{ end }}
{{- end }}
{{- else if eq (len .Alerts.Resolved) 1 -}}
{{ $a := index .Alerts.Resolved 0 -}}
<b>Resolved login:</b> {{ with $a.Labels.username }}<b>{{ . }}</b>{{ else }}<i>unknown</i>{{ end }} on <b>{{ $a.Labels.cluster }}</b>
Source: <code>{{ with $a.Labels.source }}{{ . }}{{ else }}?{{ end }}</code>{{ with $a.Labels.method }}, Method: <code>{{ . }}</code>{{ else }}, Method: <code>?</code>{{ end }}
{{- end -}}
{{/* Template enhanced to include resolved alerts while using annotations. */}}
{{ $firingCount := len .Alerts.Firing -}}
{{ $resolvedCount := len .Alerts.Resolved -}}
{{- /* Firing alerts (original logic) */ -}}
{{ if gt (len .Alerts.Firing) 1 -}}
<b>{{ len .Alerts.Firing }} logins</b> on {{ with .CommonLabels.cluster }}<b>{{ . }}</b>{{ else }}<b>unknown host</b>{{ end }}:
{{ if or (gt $firingCount 0) (gt $resolvedCount 0) -}}
{{ if and (gt $firingCount 0) (gt $resolvedCount 0) -}}
<b>{{ $firingCount }} firing</b> / <b>{{ $resolvedCount }} resolved</b>
{{ if gt $firingCount 0 -}}
<b>Firing:</b>
{{- range .Alerts.Firing }}
{{ with .Labels.username }}<b>{{ . }}</b>{{ else }}<i>unknown</i>{{ end }} — Source: <code>{{ with .Labels.source }}{{ . }}{{ else }}?{{ end }}</code>{{ with .Labels.method }}, Method: <code>{{ . }}</code>{{ else }}, Method: <code>?</code>{{ end }}
<b>{{ or .Annotations.summary "No summary" }}</b>{{ with .Annotations.description }}{{ . }}{{ end }}
{{- end }}
{{ else if eq (len .Alerts.Firing) 1 -}}
{{ $a := index .Alerts.Firing 0 -}}
<b>Login:</b> {{ with $a.Labels.username }}<b>{{ . }}</b>{{ else }}<i>unknown</i>{{ end }} on <b>{{ $a.Labels.cluster }}</b>
Source: <code>{{ with $a.Labels.source }}{{ . }}{{ else }}?{{ end }}</code>{{ with $a.Labels.method }}, Method: <code>{{ . }}</code>{{ else }}, Method: <code>?</code>{{ end }}
{{ else -}}
{{- /* If there were resolved alerts above this will still show when no firing alerts exist. */ -}}
{{ if eq (len .Alerts.Resolved) 0 -}}
<b>Login detected</b> — details unavailable.
{{ end -}}
{{ if gt $resolvedCount 0 -}}
<b>Resolved:</b>
{{- range .Alerts.Resolved }}
• <b>{{ or .Annotations.summary "No summary" }}</b>{{ with .Annotations.description }}{{ . }}{{ end }}
{{- end }}
{{ end -}}
{{ else if gt $firingCount 0 -}}
<b>{{ $firingCount }} alert{{ if ne $firingCount 1 }}s{{ end }} firing</b>:
{{- range .Alerts.Firing }}
• <b>{{ or .Annotations.summary "No summary" }}</b>{{ with .Annotations.description }}{{ . }}{{ end }}
{{- end }}
{{ else -}}
<b>{{ $resolvedCount }} alert{{ if ne $resolvedCount 1 }}s{{ end }} resolved</b>:
{{- range .Alerts.Resolved }}
• <b>{{ or .Annotations.summary "No summary" }}</b>{{ with .Annotations.description }}{{ . }}{{ end }}
{{- end }}
{{ end -}}
{{ else -}}
<b>No alert data</b> — nothing firing or recently resolved.
{{ end -}}