Skip to content

Commit

Permalink
Refactor alert routing logic for slack and opsgenie.
Browse files Browse the repository at this point in the history
Streamlined the handling of alert routes by consolidating redundant match conditions and modifying specific drop logic. This improves clarity and reduces complexity, particularly for "Unhealthy" and failure-related event filtering. Applied consistent logic across Slack and Opsgenie configurations.
  • Loading branch information
ffppa committed Jan 14, 2025
1 parent 8e1de5c commit a72be9e
Showing 1 changed file with 21 additions and 51 deletions.
72 changes: 21 additions & 51 deletions kubernetes_event_exporter/templates/default.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,64 +38,34 @@ config:
- match:
- receiver: dump
%{ if enable_slack }
- match:
- drop:
- reason: "Unhealthy"
message: ".*OOMKilled.*"
type: "Warning|Error"
route:
- reason: "FailedToUpdateEndpoint"
- reason: "FailedScheduling"
- reason: "EgressBlocked"
- kind: "HorizontalPodAutoscaler"
- kind: "ScaledObjectCheckFailed"
match:
- receiver: "slack"

- match:
- reason: "Unhealthy"
message: ".*CrashLoopBackOff.*"
type: "Warning|Error"
route:
type: "Warning"
- receiver: "slack"

- match:
- drop:
- reason: "Unhealthy"
message: ".*Readiness probe failed.*"

- match:
- drop:
- reason: "Unhealthy"
message: ".*Liveness probe failed.*"

- match:
- reason: "Failed"
type: "Warning|Error"
route:
- receiver:
reason: "*Failed*"
- receiver: "slack"
reason: "NotTriggerScaleUp"
%{ endif }
%{ if enable_opsgenie }
- match:
- drop:
- reason: "Unhealthy"
message: ".*CrashLoopBackOff.*"
type: "Warning|Error"
route:
- reason: "FailedToUpdateEndpoint"
- reason: "FailedScheduling"
- reason: "EgressBlocked"
- kind: "HorizontalPodAutoscaler"
- kind: "ScaledObjectCheckFailed"
match:
- receiver: "${opsgenie_receiver_name}"

- match:
- reason: "Unhealthy"
message: ".*OOMKilled.*"
type: "Warning|Error"
route:
type: "Warning"
- receiver: "${opsgenie_receiver_name}"

- match:
- drop:
- reason: "Unhealthy"
message: ".*Readiness probe failed.*"

- match:
- drop:
- reason: "Unhealthy"
message: ".*Liveness probe failed.*"

- match:
- reason: "Failed"
type: "Warning|Error"
route:
reason: "*Failed*"
- receiver: "${opsgenie_receiver_name}"
reason: "NotTriggerScaleUp"
%{ endif }

0 comments on commit a72be9e

Please sign in to comment.