feat: added basic alert for pvc 95% full to kube-prometheus score

This commit is contained in:
Willem 2025-05-05 15:38:37 -04:00
parent fbd466a85c
commit e7cfbf914a

View File

@ -6,6 +6,27 @@ use crate::modules::helm::chart::HelmChartScore;
pub fn kube_prometheus_score(ns: &str) -> HelmChartScore { pub fn kube_prometheus_score(ns: &str) -> HelmChartScore {
//TODO this should be make into a rule with default formatting that can be easily passed as a vec
//to the overrides or something leaving the user to deal with formatting here seems bad
let values = r#"
additionalPrometheusRules:
- name: kubelet-alerts
groups:
- name: pvc-alerts
rules:
- alert: 'PVC Fill Over 95 Percent In 2 Days'
annotations:
description: The PVC {{ $labels.persistentvolumeclaim }} in namespace {{
$labels.namespace }} is predicted to fill over 95% in less than 2 days.
title: PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace
}} will fill over 95% in less than 2 days
expr: "(\n kubelet_volume_stats_used_bytes \n / \n kubelet_volume_stats_capacity_bytes\n)
> 0.95\nAND\npredict_linear(kubelet_volume_stats_used_bytes[2d], 2 * 24
* 60 * 60)\n/\nkubelet_volume_stats_capacity_bytes\n> 0.95\n"
for: 5m
labels:
severity: warning
"#;
HelmChartScore { HelmChartScore {
namespace: Some(NonBlankString::from_str(ns).unwrap()), namespace: Some(NonBlankString::from_str(ns).unwrap()),
release_name: NonBlankString::from_str("kube-prometheus").unwrap(), release_name: NonBlankString::from_str("kube-prometheus").unwrap(),