Skip to content

Commit

Permalink
feat: add variable for additional alerts labels
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Jan 26, 2024
1 parent 8de7829 commit 9dbf9aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions charts/longhorn/templates/prometheus-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornVolumeStatusCritical
annotations:
description: {{"Longhorn volume {{$labels.volume}} on {{$labels.node}} is Fault for more than 2 minutes."}}
Expand All @@ -27,6 +30,9 @@ spec:
for: 5m
labels:
severity: critical
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornVolumeStatusWarning
annotations:
description: {{"Longhorn volume {{$labels.volume}} on {{$labels.node}} is Degraded for more than 5 minutes."}}
Expand All @@ -35,6 +41,9 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornNodeStorageWarning
annotations:
description: {{"The used storage of node {{$labels.node}} is at {{$value}}% capacity for more than 5 minutes."}}
Expand All @@ -43,6 +52,9 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornDiskStorageWarning
annotations:
description: {{"The used storage of disk {{$labels.disk}} on node {{$labels.node}} is at {{$value}}% capacity for more than 5 minutes."}}
Expand All @@ -51,6 +63,9 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornNodeDown
annotations:
description: {{"There are {{$value}} Longhorn nodes which have been offline for more than 5 minutes."}}
Expand All @@ -59,6 +74,9 @@ spec:
for: 5m
labels:
severity: critical
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornIntanceManagerCPUUsageWarning
annotations:
description: {{"Longhorn instance manager {{$labels.instance_manager}} on {{$labels.node}} has CPU Usage / CPU request is {{$value}}% for more than 5 minutes."}}
Expand All @@ -67,6 +85,9 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: LonghornNodeCPUUsageWarning
annotations:
description: {{"Longhorn node {{$labels.node}} has CPU Usage / CPU capacity is {{$value}}% for more than 5 minutes."}}
Expand All @@ -75,5 +96,8 @@ spec:
for: 5m
labels:
severity: warning
{{- with $.Values.servicemonitor.additionalAlertLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}

{{- end -}}
1 change: 1 addition & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ locals {
}
servicemonitor = {
enabled = var.enable_service_monitor
additionalAlertLabels = var.additional_alert_labels
}
automaticFilesystemTrim = {
enabled = var.automatic_filesystem_trim.enabled
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ variable "enable_service_monitor" {
default = false
}

variable "additional_alert_labels" {
description = "Additional labels to add to Longhorn alerts."
type = map(string)
default = {}
}

variable "enable_dashboard_ingress" {
description = "Boolean to enable the creation of an ingress for the Longhorn's dashboard. **If enabled, you must provide a value for `base_domain`.**"
type = bool
Expand Down

0 comments on commit 9dbf9aa

Please sign in to comment.