Updating an Alarm After Moving a Resource
Update an alarm in Monitoring after you move a monitored resource.
After you move a resource that's emitting metrics monitored by the alarm, update the metric compartment of related alarms. For example, if you move a block volume to another compartment, then the associated alarm must be updated if you want to continue monitoring metrics from the moved block volume.
Inherent policies in the destination compartment apply immediately and affect access to the moved resource through the Console. For more information about moving resources, see Moving Resources to a Different Compartment.
For alarm troubleshooting, see Troubleshooting Alarms.
- Open the navigation menu and click Observability & Management. Under Monitoring, click Alarm Definitions.
- Click the alarm that you want to update.
- Go to Actions on the right side, and then click Edit alarm.
Update the metric compartment: On the Edit alarm page, under Metric description (or Metric description, dimensions, and trigger rule for Advanced Mode), change the Compartment to the compartment where the resource has been moved.
The chart under the Define alarm section dynamically updates according to the selected compartment, displaying the last six hours of emitted metrics. Very small or large values are indicated by International System of Units (SI units), such as M for mega (10 to the sixth power).
If the chart isn't showing the expected data, then the old compartment might be specified in the query (MQL), as in the following example:
- If the old compartment is specified in the query, then update the query to reference the new compartment:
- Click Switch to Advanced Mode to view the alarm query as a Monitoring Query Language (MQL) expression.
In the Query code editor box, update the query to reference the new compartment.View example
For information about MQL queries, see Monitoring Query Language (MQL) Reference.
The chart under the Define alarm section dynamically updates according to the updated query, displaying the last six hours of emitted metrics. Very small or large values are indicated by International System of Units (SI units), such as M for mega (10 to the sixth power).
If the chart isn't showing the expected data, then confirm that every compartment reference (Compartment, the Query code editor box) points to the new compartment.
Click Save alarm.
The alarm now monitors metrics from the new compartment.
Use the oci monitoring alarm update command and required parameters to update an alarm to query metrics in the resource's new compartment. Ensure that the query doesn't specify the resource's old compartment.
oci monitoring alarm update --metric-compartment-id <resource_compartment_ocid> --query-text
For a complete list of flags and variable options for CLI commands, see the Command Line Reference for Monitoring.