Files
feedc0de 5acc3b0154
Publish PHP Apache image / Build, test and push (push) Successful in 1m10s
Add Apache status monitoring to Helm chart
2026-09-10 20:49:26 +02:00

50 lines
3.0 KiB
YAML

{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule") }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "php-homepage.fullname" . }}
labels:
{{- include "php-homepage.labels" . | nindent 4 }}
{{- with .Values.metrics.prometheusRule.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.metrics.prometheusRule.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
groups:
- name: {{ include "php-homepage.fullname" . }}.apache
rules:
{{- if .Values.metrics.prometheusRule.exporterDown.enabled }}
- alert: ApacheExporterDown
expr: up{namespace={{ .Release.Namespace | quote }},service={{ include "php-homepage.fullname" . | quote }},endpoint="metrics"} == 0
for: {{ .Values.metrics.prometheusRule.exporterDown.for }}
labels:
severity: {{ .Values.metrics.prometheusRule.exporterDown.severity | quote }}
annotations:
summary: {{ printf "Apache exporter for %s is unavailable" (include "php-homepage.fullname" .) | quote }}
description: {{ printf "Prometheus has not been able to scrape the Apache exporter in namespace %s." .Release.Namespace | quote }}
{{- end }}
{{- if .Values.metrics.prometheusRule.apacheDown.enabled }}
- alert: ApacheDown
expr: apache_up{namespace={{ .Release.Namespace | quote }},service={{ include "php-homepage.fullname" . | quote }}} == 0
for: {{ .Values.metrics.prometheusRule.apacheDown.for }}
labels:
severity: {{ .Values.metrics.prometheusRule.apacheDown.severity | quote }}
annotations:
summary: {{ printf "Apache for %s is unavailable" (include "php-homepage.fullname" .) | quote }}
description: {{ printf "The exporter cannot read Apache server-status in namespace %s." .Release.Namespace | quote }}
{{- end }}
{{- if .Values.metrics.prometheusRule.workerSaturation.enabled }}
- alert: ApacheWorkerSaturation
expr: (sum(apache_workers{namespace={{ .Release.Namespace | quote }},service={{ include "php-homepage.fullname" . | quote }},state="busy"}) / clamp_min(sum(apache_workers{namespace={{ .Release.Namespace | quote }},service={{ include "php-homepage.fullname" . | quote }}}), 1)) > {{ .Values.metrics.prometheusRule.workerSaturation.threshold }}
for: {{ .Values.metrics.prometheusRule.workerSaturation.for }}
labels:
severity: {{ .Values.metrics.prometheusRule.workerSaturation.severity | quote }}
annotations:
summary: {{ printf "Apache workers for %s are nearly exhausted" (include "php-homepage.fullname" .) | quote }}
description: {{ printf "The ratio of busy to available Apache workers has exceeded the configured threshold (%v) for the configured duration." .Values.metrics.prometheusRule.workerSaturation.threshold | quote }}
{{- end }}
{{- end }}