Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [PAYMCLOUD-168] aks module migrate metrics alert to log alerts (#…
…375) * Add custom log alerts for Kubernetes monitoring Introduced a new variable for custom log alerts and integrated azurerm_monitor_scheduled_query_rules_alert resource. Updated README and variables files to include the new configurations and descriptions for log alert criteria. * Update AKS alert action settings Modified the alert action settings to use default values for optional parameters. The email subject and custom webhook payload now have fallback values to ensure proper alert content even when not explicitly set. * Fix typo in variable name for custom logs alerts Renamed variable "custom_log_alerts" to "custom_logs_alerts" to ensure consistency with the rest of the codebase. Updated variable usage to reflect the new name. * Adjust action_group to use toset() for better compatibility Converted the action_group field to use toset() to ensure it handles lists properly and ensures type consistency. This change enhances compatibility with different Terraform configurations and prevents potential type errors. * Disable custom email subject and webhook payload Commented out the `email_subject` and `custom_webhook_payload` parameters in the AKS monitoring alert configuration files. This temporarily disables custom email subjects and webhook payloads for alerts, possibly to standardize notifications or troubleshoot issues. * Refactor alert action configuration and enable email subject. Revise the `action` block to concatenate action group IDs and reinstate optional fields for email subject and custom webhook payload. This improves the flexibility of alert configurations and the manageability of action settings. * Add local log alerts for node readiness and disk usage Replaced previous monitoring alert configurations for node readiness and disk usage with local log alerts to leverage dynamic query construction. This allows more precise alerting based on the Kubernetes cluster ID and other metrics. * Refactor monitoring alert queries to multiline format Convert long queries into multiline format using KQL blocks for better readability and maintainability. Adjusted the `node_not_ready` and `node_disk_usage` queries without changing their logic or functionality. * Fix escape sequences in monitoring alert queries Corrected the escape sequences in the KQL queries for `node_not_ready` and `node_disk_usage` monitoring alerts. This ensures proper evaluation of Kubernetes cluster IDs within the queries. * Fix KQL queries by correcting string escaping Corrected the string escaping in two KQL queries for monitoring alerts in the Terraform script. This change ensures that the KQL queries properly match the intended conditions and improve the reliability of monitoring alerts. * Fix syntax errors in KQL queries for monitoring alerts Removed extraneous quotation marks in KQL queries used for monitoring alerts to ensure proper execution and accurate alerting. This change resolves issues where KQL queries were not interpreted correctly due to syntax errors. * Upgrade `azurerm_monitor_scheduled_query_rules_alert` to v2 Refactor the monitoring alerts to use `azurerm_monitor_scheduled_query_rules_alert_v2`. This includes additional attributes for better alert configuration and updated alert definitions in both the resource and variables files. * Remove `scopes` field from monitoring alerts variable The `scopes` field has been removed from the `99_variables_monitoring_alerts.tf` file as it was required and would force a new resource creation. This update simplifies the configuration and removes the restriction of having exactly one resource ID in the scopes list. * Change variable types in monitoring alerts Modified `window_duration` and `evaluation_frequency` from number to string in the monitoring alerts variables. This ensures compatibility with ISO 8601 duration format and aligns with documented possible values. * Fix incorrect lookup key in AKS monitoring configuration Corrected the key used in the lookup function for workspace_alerts_storage_enabled. This change ensures the configuration correctly retrieves the value from the input map, preventing potential runtime errors. * Reduce alert evaluation periods to improve responsiveness Changed the number of evaluation periods from 3 to 1 for monitoring alerts. This adjustment aims to decrease the time required to trigger alerts, enhancing responsiveness to potential issues. * Reduce minimum failing periods for alert triggering Changed the `minimum_failing_periods_to_trigger_alert` from 3 to 1 in the alert configuration files. This adjustment will allow alerts to trigger more quickly, improving the system's responsiveness to potential issues. * Update evaluation frequency to 5 minutes Set the evaluation frequency of monitoring alerts to 5 minutes for better consistency. This change applies to both the status and avgDiskUsage monitoring alert configurations. * Update metric column names and add KQL aggregation Changed `metric_measure_column` values to include prefixes for clarity. Added aggregation method in KQL query to summarize average disk usage results. * Update metric measure column name in monitoring alerts Changed the metric_measure_column field from "count_Status" to "count_". This adjustment ensures the column name aligns with the updated schema and prevents potential mismatches during data aggregation. * Adjust monitoring alert settings for longer evaluation periods Updated the monitoring alerts KQL queries to extend the time window and evaluation frequency. This helps in reducing the noise from frequent but short-lived issues, providing a more accurate set of alerts for the system's actual status. * Update alert display names for AKS nodes Revised the display names for node readiness and disk usage alerts in the Kubernetes cluster monitoring configuration. Now, the display names include the AKS cluster name for better identification and clarity in alert notifications. * Make alert configuration more resilient. Added lookup functions to provide default values for alert configurations, ensuring they are more robust against missing or undefined values. This improves stability and reduces the probability of runtime errors due to missing configuration fields. * Make alert parameters optional Updated several alert parameters to be optional in `99_variables_monitoring_alerts.tf`. This change allows for more flexible configurations and defaults, improving usability and customization of alerts. * Enable skip_query_validation in AKS monitoring Changed the `skip_query_validation` default to true in the AKS monitoring script. This adjustment is likely to bypass query validation checks, streamlining alert configurations and potentially reducing deployment issues. * Fix Markdown formatting in README.md Corrected the Markdown formatting for several code blocks in the README.md file. This change improves the readability and consistency of the documentation. * Format Markdown tables to improve readability This commit adjusts the formatting of Markdown tables in the README.md file to improve their readability. It removes unnecessary slashes in some table rows, converting them into a more uniform and cleaner format. * Update README.md for consistent Markdown formatting Updated the README.md files for `kubernetes_cluster` and `kubernetes_cluster_udr` to ensure consistent Markdown formatting across all sections. This mainly involved changing line breaks in code blocks to improve readability and maintain a uniform style. * Update alert configurations for disk usage monitoring Renamed dimensions and adjusted alert parameters for disk usage. Changed threshold, window duration, evaluation frequency, and refined the metric to focus on 'Computer' instead of 'AvgDiskUsage' directly. * Fix metric measure column name in monitoring alerts variable Corrected the metric measure column from "any_AvgDiskUsage" to "AvgDiskUsage" in the monitoring alerts configuration. This change ensures the metric measure is correctly referenced, preventing potential errors in alert triggers. * Change alert severity from 1 to 2 Adjusted the severity of the monitoring alert for disk usage. This change re-prioritizes the alert level, likely based on a revised risk assessment or operational need. * Remove deprecated log_alerts_application_insight_id variable Deleted the log_alerts_application_insight_id variable from 99_variables.tf and updated the README accordingly to reflect this change. This variable is no longer needed in our configuration setup. * Add notes on new custom alerts and decommissioned metrics Introduce new variables for custom log alerts and detail mandatory changes due to Azure's decommission of certain metric alerts from May 2024. Specify which metrics will be phased out in version v8.57.0 of the module. * Refactor metric alerts and add OOMKilled log alert. Revised the configuration for metric alerts in the README, consolidating them into `default_metric_alerts` and `custom_metric_alerts` variables. Added a new custom log alert for detecting OOMKilled pods with specific parameters for alerting. * Adjust monitoring alert timings for more frequent evaluations Reduce the window duration from 1 hour to 30 minutes and the evaluation frequency from 15 minutes to 10 minutes. This change enables quicker detection of issues in the Kubernetes cluster. * Add severity to monitoring alerts Added a severity field to the monitoring alerts configuration, allowing more granular control over alert prioritization. Default severity is set to 3, with the ability to customize this value per alert.
- Loading branch information