|
| 1 | +apiVersion: "monitoring.coreos.com/v1" |
| 2 | +kind: PrometheusRule |
| 3 | +metadata: |
| 4 | + name: alert-pseudo-service |
| 5 | + namespace: dapla-stat |
| 6 | + labels: |
| 7 | + team: dapla-stat |
| 8 | + cluster: "{{cluster}}" |
| 9 | +spec: |
| 10 | + groups: |
| 11 | + - name: dapla-stat |
| 12 | + rules: |
| 13 | + # This alert checks if no replicas of pseudo-service are available, indicating the service is unavailable. |
| 14 | + - alert: PseudoServiceUnavailable |
| 15 | + expr: kube_deployment_status_replicas_available{deployment="pseudo-service"} == 0 |
| 16 | + for: 1m |
| 17 | + annotations: |
| 18 | + title: "Pseudo-service is unavailable" |
| 19 | + consequence: "The service is unavailable to users. Immediate investigation required." |
| 20 | + action: "Check the deployment status and logs for issues." |
| 21 | + labels: |
| 22 | + service: pseudo-service |
| 23 | + namespace: dapla-stat |
| 24 | + severity: critical |
| 25 | + alertmanager_custom_config: dapla-stat |
| 26 | + alert_type: custom |
| 27 | + |
| 28 | + # This alert detects high CPU usage by calculating the CPU time used over 5 minutes. |
| 29 | + - alert: HighCPUUsage |
| 30 | + expr: rate(process_cpu_seconds_total{app="pseudo-service"}[5m]) > 0.8 |
| 31 | + for: 5m |
| 32 | + annotations: |
| 33 | + title: "High CPU usage detected" |
| 34 | + consequence: "The service might experience performance degradation." |
| 35 | + action: "Investigate the cause of high CPU usage and optimize if necessary." |
| 36 | + labels: |
| 37 | + service: pseudo-service |
| 38 | + namespace: dapla-stat |
| 39 | + severity: warning |
| 40 | + alertmanager_custom_config: dapla-stat |
| 41 | + alert_type: custom |
| 42 | + |
| 43 | + # This alert checks if memory usage exceeds 90% of the 12GB limit, which could cause instability. |
| 44 | + - alert: HighMemoryUsage |
| 45 | + expr: sum by (namespace, pod) (container_memory_working_set_bytes{namespace="dapla-stat", pod=~"pseudo-service-.*"}) > 0.9 * sum by (namespace, pod) (kube_pod_container_resource_limits_memory_bytes{namespace="dapla-stat", pod=~"pseudo-service-.*"}) |
| 46 | + for: 5m |
| 47 | + annotations: |
| 48 | + title: "High memory usage detected" |
| 49 | + consequence: "The service might experience instability due to high memory usage." |
| 50 | + action: "Check memory utilization and consider increasing resources or optimizing the service." |
| 51 | + labels: |
| 52 | + service: pseudo-service |
| 53 | + namespace: dapla-stat |
| 54 | + severity: warning |
| 55 | + alertmanager_custom_config: dapla-stat |
| 56 | + alert_type: custom |
| 57 | + |
| 58 | + # This alert detects a high number of error logs in pseudo-service. |
| 59 | + - alert: HighNumberOfErrors |
| 60 | + expr: (100 * sum by (app, namespace) (rate(log_messages_errors{app="pseudo-service", level=~"Error"}[3m])) / sum by (app, namespace) (rate(log_messages_total{app="pseudo-service"}[3m]))) > 10 |
| 61 | + for: 3m |
| 62 | + annotations: |
| 63 | + title: "High number of errors logged in pseudo-service" |
| 64 | + consequence: "The application is logging a significant number of errors." |
| 65 | + action: "Check the service logs for errors and address the root cause." |
| 66 | + labels: |
| 67 | + service: pseudo-service |
| 68 | + namespace: dapla-stat |
| 69 | + severity: critical |
| 70 | + alertmanager_custom_config: dapla-stat |
| 71 | + alert_type: custom |
| 72 | + |
| 73 | + # This alert monitors the number of pod restarts for pseudo-service and triggers if more than 3 restarts occur within 15 minutes. |
| 74 | + - alert: HighPodRestarts |
| 75 | + expr: increase(kube_pod_container_status_restarts_total{namespace="dapla-stat", app="pseudo-service"}[15m]) > 3 |
| 76 | + for: 15m |
| 77 | + annotations: |
| 78 | + title: "High number of pod restarts" |
| 79 | + consequence: "The service may be unstable or misconfigured." |
| 80 | + action: "Investigate the cause of pod restarts and fix configuration or resource issues." |
| 81 | + labels: |
| 82 | + service: pseudo-service |
| 83 | + namespace: dapla-stat |
| 84 | + severity: warning |
| 85 | + alertmanager_custom_config: dapla-stat |
| 86 | + alert_type: custom |
0 commit comments