Skip to content
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

global/prometheus-alertmanager-operated: Added bedrock alerting #7628

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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: 1 addition & 1 deletion global/prometheus-alertmanager-operated/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
type: application
description: Prometheus Alertmanager via operator.
name: prometheus-alertmanager-operated
version: 4.5.2
version: 4.5.3

dependencies:
- alias: prometheus-alertmanager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,44 @@ spec:
matchType: "="
value: compute

- receiver: slack_bedrock_critical
continue: true
matchers:
- name: tier
matchType: "="
value: vmware
- name: severity
matchType: "="
value: critical
- name: region
matchType: "=~"
value: {{ without .Values.regions "qa-de-1" | join "|" }}
- name: support_group
matchType: "="
value: compute
- name: bedrock
matchType: "="
value: true

- receiver: slack_bedrock_warning
continue: true
matchers:
- name: tier
matchType: "="
value: vmware
- name: severity
matchType: "="
value: warning
- name: region
matchType: "=~"
value: {{ without .Values.regions "qa-de-1" | join "|" }}
- name: support_group
matchType: "="
value: compute
- name: bedrock
matchType: "="
value: true

# Test Channel for CC KVM Alerting slack_alert_kvm_test
- receiver: slack_alert_kvm_test
continue: true
Expand Down
2 changes: 1 addition & 1 deletion prometheus-rules/prometheus-vmware-rules/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: A collection of Prometheus alert rules.
name: prometheus-vmware-rules
version: 1.0.9
version: 1.0.10
christophrichtersap marked this conversation as resolved.
Show resolved Hide resolved
dependencies:
- name: owner-info
repository: oci://keppel.eu-de-1.cloud.sap/ccloud-helm
Expand Down
49 changes: 48 additions & 1 deletion prometheus-rules/prometheus-vmware-rules/templates/_helper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,51 @@
{{- $root := index . 1 -}}
{{- $vropshostname := split "." $name -}}
vmware-{{ $vropshostname._0 | trimPrefix "vrops-" }}
{{- end -}}
{{- end -}}

{{- /*
Template around bedrock alerts
Author: <Christoph Richter [email protected]>
Description:
The original alerting rule is then wrapped by a label_replace function.
The label_replace adds a new label "bedrock" with the value "true" if the alert is relevant for bedrock.
The label_replace adds a new label "bedrock" with the value "false" if the alert is not relevant for bedrock.
The mappingKey is dynamically set within values.yaml for each alertname.
*/}}
christophrichtersap marked this conversation as resolved.
Show resolved Hide resolved
{{- define "bedrockConfirm.expr" -}}
{{- $expr := index . 0 -}}
{{- $mappingKey := index . 1 -}}
expr: >
label_replace(
{{ $expr }} unless on({{ $mappingKey }})
(
group by (project, {{ $mappingKey }}) (
viennaa marked this conversation as resolved.
Show resolved Hide resolved
vrops_virtualmachine_system_powered_on{region="eu-de-1", vccluster=~"^productionbb\\d+$"}
)
and on(project)
group by (project) (
label_replace(
limes_project_usage{domain=~"iaas-.*"},
"project", "$$1", "project_id", "(.*)"
)
)
),
"bedrock", "false", "bedrock", "")
or
label_replace(
{{ $expr }} and on({{ $mappingKey }})
(
group by (project, {{ $mappingKey }}) (
vrops_virtualmachine_system_powered_on{region="eu-de-1", vccluster=~"^productionbb\\d+$"}
)
and on(project)
group by (project) (
label_replace(
limes_project_usage{domain=~"iaas-.*"},
"project", "$$1", "project_id", "(.*)"
)
)
),
"bedrock", "true", "bedrock", ""
)
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{{- $root := . }}
{{- $bedrockAlerts := .Values.bedrockAlerts }}
{{- $filteredBedrockAlerts := dict }}
christophrichtersap marked this conversation as resolved.
Show resolved Hide resolved
{{- range $key, $value := $bedrockAlerts }}
{{- if $value }}
{{- $filteredBedrockAlerts = merge $filteredBedrockAlerts (dict $key $value) }}
{{- end }}
{{- end }}
{{- range $target := .Values.global.targets }}
{{- range $path, $bytes := $.Files.Glob "alerts/*.alerts" }}
---
Expand All @@ -11,7 +18,19 @@ metadata:
prometheus: {{ include "prometheusVMware.name" (list $target $root) }}

spec:
{{ printf "%s" $bytes | indent 2 }}

{{- $string := $bytes | toString }}
{{- $string := (regexReplaceAll "\\n\\s+\\n" $string "\n\n") }}
christophrichtersap marked this conversation as resolved.
Show resolved Hide resolved
{{- range $alert := splitList "\n\n" $string }}
{{- $alertname := (regexReplaceAll "[\\s\\S]+?alert: (\\S+)\\n[\\s\\S]+" $alert "${1}") }}
{{- if has $alertname (keys $filteredBedrockAlerts) }}
# Alert expr. templated with bedrock alerts template
{{- $mappingKey := (printf "%s" (get $bedrockAlerts $alertname)) }}
{{ regexReplaceAll "([\\s\\S]+?- alert: \\S+)\\n([\\s\\S]+?expr:[\\s\\S]+)" $alert "${1}" | indent 2 }}
{{ regexReplaceAll "[\\s\\S]+expr.+?(>\\n|\\w|\\|\\n)\\s+([\\s\\S]+?)\\s+\\S+:[\\s\\S]+" $alert (include "bedrockConfirm.expr" (list "$2" $mappingKey)) | indent 6 }}
{{- regexReplaceAll "([\\s\\S]+?expr:[\\s\\S]+?)\\n(\\s+\\S+:[\\s\\S]+)" $alert "${2}" | nindent 2 }}
{{- else }}
{{ printf "%s" $alert | indent 2 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions prometheus-rules/prometheus-vmware-rules/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ owner-info:
- Christopher Hans
- Maximilian Lendrich
helm-chart-url: https://github.com/sapcc/helm-charts/tree/master/prometheus-rules/prometheus-vmware-rules

# Maintained in the regional secrets
# bedrockAlerts:
# DatastoreDisconnectedWithVmsOnIt: hostsystem
viennaa marked this conversation as resolved.
Show resolved Hide resolved
Loading