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.

    1. Open the navigation menu and click Observability & Management. Under Monitoring, click Alarm Definitions.
    2. Click the alarm that you want to update.
    3. Go to Actions on the right side, and then click Edit alarm.
    4. 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: 

      IopsRead[1m]{compartmentId="ocid1.compartment.oc1.phx..oldcompartmentexampleuniqueID"}.grouping().max()
    5. If the old compartment is specified in the query, then update the query to reference the new compartment: 
      1. Click Switch to Advanced Mode to view the alarm query as a Monitoring Query Language (MQL) expression.
      2. In the Query code editor box, update the query to reference the new compartment.

        View example

        Original query:

        IopsRead[1m]{compartmentId="ocid1.compartment.oc1.phx..oldcompartmentexampleuniqueID"}.grouping().max()

        Updated query:

        Read[1m]{compartmentId="ocid1.compartment.oc1.phx..newcompartmentexampleuniqueID"}.grouping().max()

        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.

    6. 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 <mql_expression_not_specifying_old_compartment> [...]

    For a complete list of parameters and values for CLI commands, see the Command Line Reference for Monitoring.

  • Run the UpdateAlarm operation to update an alarm to query metrics in the resource's new compartment.

    When defining details for UpdateAlarmDetails, set metricCompartmentId to the resource's new compartment, and ensure that the old compartment isn't specified in query.