|
| 1 | +--- |
| 2 | +page_title: "Cockpit Alert Manager Migration Guide" |
| 3 | +--- |
| 4 | + |
| 5 | +# Cockpit Alert Manager Migration Guide |
| 6 | + |
| 7 | +This guide explains how to migrate from the deprecated `enable_managed_alerts` field to the new `preconfigured_alert_ids` field in the `scaleway_cockpit_alert_manager` resource. |
| 8 | + |
| 9 | +## Background |
| 10 | + |
| 11 | +The `enable_managed_alerts` field is being deprecated in favor of a more flexible approach using `preconfigured_alert_ids`. This change provides: |
| 12 | + |
| 13 | +- **Granular control**: Select specific alerts instead of enabling all managed alerts |
| 14 | +- **Better visibility**: Explicitly declare which alerts are enabled in your Terraform configuration |
| 15 | +- **Improved state management**: Terraform accurately tracks which alerts are active |
| 16 | + |
| 17 | +## Migration Steps |
| 18 | + |
| 19 | +### Before Migration (Deprecated) |
| 20 | + |
| 21 | +```terraform |
| 22 | +resource "scaleway_cockpit_alert_manager" "main" { |
| 23 | + project_id = scaleway_account_project.project.id |
| 24 | + enable_managed_alerts = true |
| 25 | +
|
| 26 | + contact_points { |
| 27 | + |
| 28 | + } |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### After Migration (Recommended) |
| 33 | + |
| 34 | +#### Step 1: List Available Preconfigured Alerts |
| 35 | + |
| 36 | +Use the data source to discover available alerts: |
| 37 | + |
| 38 | +```terraform |
| 39 | +data "scaleway_cockpit_preconfigured_alert" "all" { |
| 40 | + project_id = scaleway_account_project.project.id |
| 41 | +} |
| 42 | +
|
| 43 | +output "available_alerts" { |
| 44 | + value = data.scaleway_cockpit_preconfigured_alert.all.alerts |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +Run `terraform apply` and review the output to see available alerts. |
| 49 | + |
| 50 | +#### Step 2: Select Specific Alerts |
| 51 | + |
| 52 | +Choose the alerts you want to enable: |
| 53 | + |
| 54 | +```terraform |
| 55 | +resource "scaleway_cockpit_alert_manager" "main" { |
| 56 | + project_id = scaleway_account_project.project.id |
| 57 | +
|
| 58 | + # Enable specific alerts by product/family |
| 59 | + preconfigured_alert_ids = [ |
| 60 | + for alert in data.scaleway_cockpit_preconfigured_alert.all.alerts : |
| 61 | + alert.preconfigured_rule_id |
| 62 | + if contains(["PostgreSQL", "MySQL"], alert.product_name) |
| 63 | + ] |
| 64 | +
|
| 65 | + contact_points { |
| 66 | + |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +Or use specific alert IDs: |
| 72 | + |
| 73 | +```terraform |
| 74 | +resource "scaleway_cockpit_alert_manager" "main" { |
| 75 | + project_id = scaleway_account_project.project.id |
| 76 | +
|
| 77 | + preconfigured_alert_ids = [ |
| 78 | + "6c6843af-1815-46df-9e52-6feafcf31fd7", # PostgreSQL Too Many Connections |
| 79 | + "eb8a941e-698d-47d6-b62d-4b6c13f7b4b7", # MySQL Too Many Connections |
| 80 | + ] |
| 81 | +
|
| 82 | + contact_points { |
| 83 | + |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +## Filtering Alerts |
| 89 | + |
| 90 | +### By Product Name |
| 91 | + |
| 92 | +```terraform |
| 93 | +preconfigured_alert_ids = [ |
| 94 | + for alert in data.scaleway_cockpit_preconfigured_alert.all.alerts : |
| 95 | + alert.preconfigured_rule_id |
| 96 | + if alert.product_name == "Kubernetes" |
| 97 | +] |
| 98 | +``` |
| 99 | + |
| 100 | +### By Product Family |
| 101 | + |
| 102 | +```terraform |
| 103 | +preconfigured_alert_ids = [ |
| 104 | + for alert in data.scaleway_cockpit_preconfigured_alert.all.alerts : |
| 105 | + alert.preconfigured_rule_id |
| 106 | + if alert.product_family == "Managed Databases" |
| 107 | +] |
| 108 | +``` |
| 109 | + |
| 110 | +### Multiple Criteria |
| 111 | + |
| 112 | +```terraform |
| 113 | +preconfigured_alert_ids = [ |
| 114 | + for alert in data.scaleway_cockpit_preconfigured_alert.all.alerts : |
| 115 | + alert.preconfigured_rule_id |
| 116 | + if alert.product_family == "Load Balancer" && alert.product_name == "LB" |
| 117 | +] |
| 118 | +``` |
| 119 | + |
| 120 | +## Important Notes |
| 121 | + |
| 122 | +### Behavioral Changes |
| 123 | + |
| 124 | +- **No automatic alerts**: Unlike `enable_managed_alerts = true`, the API will not automatically enable additional alerts |
| 125 | +- **Explicit configuration**: You must explicitly list all alerts you want to enable |
| 126 | +- **State accuracy**: Terraform state will only track alerts you've configured |
| 127 | + |
| 128 | +### Compatibility |
| 129 | + |
| 130 | +- The deprecated `enable_managed_alerts` field will be removed in a future major version |
| 131 | +- Both fields can coexist during migration, but `preconfigured_alert_ids` takes precedence |
| 132 | +- If neither field is specified, no preconfigured alerts will be enabled |
| 133 | + |
| 134 | +## Troubleshooting |
| 135 | + |
| 136 | +### "Insufficient permissions" Error |
| 137 | + |
| 138 | +If you see permission errors when using the `scaleway_cockpit_preconfigured_alert` data source, ensure your IAM policy includes: |
| 139 | + |
| 140 | +```json |
| 141 | +{ |
| 142 | + "permission_sets": [ |
| 143 | + { |
| 144 | + "name": "CockpitManager", |
| 145 | + "permissions": [ |
| 146 | + "read:cockpit" |
| 147 | + ] |
| 148 | + } |
| 149 | + ] |
| 150 | +} |
| 151 | +``` |
| 152 | + |
| 153 | +### Unexpected State Changes |
| 154 | + |
| 155 | +If Terraform shows unexpected changes to `preconfigured_alert_ids`: |
| 156 | + |
| 157 | +1. Verify the alert IDs still exist by querying the data source |
| 158 | +2. Check that alerts are in `enabled` or `enabling` state |
| 159 | +3. Ensure no manual changes were made outside Terraform |
| 160 | + |
| 161 | +## Additional Resources |
| 162 | + |
| 163 | +- [Cockpit Alert Manager Resource Documentation](../resources/cockpit_alert_manager.md) |
| 164 | +- [Cockpit Preconfigured Alert Data Source Documentation](../data-sources/cockpit_preconfigured_alert.md) |
| 165 | +- [Scaleway Cockpit Documentation](https://www.scaleway.com/en/docs/observability/cockpit/) |
| 166 | + |
0 commit comments