oracle.oci.oci_monitoring_alarm – Manage an Alarm resource in Oracle Cloud Infrastructure

Note

This plugin is part of the oracle.oci collection (version 4.11.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install oracle.oci.

To use it in a playbook, specify: oracle.oci.oci_monitoring_alarm.

New in version 2.9.0: of oracle.oci

Synopsis

  • This module allows the user to create, update and delete an Alarm resource in Oracle Cloud Infrastructure

  • For state=present, creates a new alarm in the specified compartment. For important limits information, see Limits on Monitoring.

  • This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, or transactions, per second (TPS) for a given tenancy.

  • This resource has the following action operations in the oracle.oci.oci_monitoring_alarm_actions module: change_compartment, remove_alarm_suppression.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter Choices/Defaults Comments
alarm_id
string
The OCID of an alarm.
Required for update using state=present when environment variable OCI_USE_NAME_AS_IDENTIFIER is not set.
Required for delete using state=absent when environment variable OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: id
api_user
string
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_ID environment variable, if any, is used. This option is required if the user is not specified through a configuration file (See config_file_location). To get the user's OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_fingerprint
string
Fingerprint for the key pair being used. If not set, then the value of the OCI_USER_FINGERPRINT environment variable, if any, is used. This option is required if the key fingerprint is not specified through a configuration file (See config_file_location). To get the key pair's fingerprint value please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_key_file
string
Full path and filename of the private key (in PEM format). If not set, then the value of the OCI_USER_KEY_FILE variable, if any, is used. This option is required if the private key is not specified through a configuration file (See config_file_location). If the key is encrypted with a pass-phrase, the api_user_key_pass_phrase option must also be provided.
api_user_key_pass_phrase
string
Passphrase used by the key referenced in api_user_key_file, if it is encrypted. If not set, then the value of the OCI_USER_KEY_PASS_PHRASE variable, if any, is used. This option is required if the key passphrase is not specified through a configuration file (See config_file_location).
auth_purpose
string
    Choices:
  • service_principal
The auth purpose which can be used in conjunction with 'auth_type=instance_principal'. The default auth_purpose for instance_principal is None.
auth_type
string
    Choices:
  • api_key ←
  • instance_principal
  • instance_obo_user
  • resource_principal
The type of authentication to use for making API requests. By default auth_type="api_key" based authentication is performed and the API key (see api_user_key_file) in your config file will be used. If this 'auth_type' module option is not specified, the value of the OCI_ANSIBLE_AUTH_TYPE, if any, is used. Use auth_type="instance_principal" to use instance principal based authentication when running ansible playbooks within an OCI compute instance.
body
string
The human-readable content of the notification delivered. Oracle recommends providing guidance to operators for resolving the alarm condition. Consider adding links to standard runbook practices. Avoid entering confidential information.
Example: `High CPU usage alert. Follow runbook instructions for resolution.`
This parameter is updatable.
cert_bundle
string
The full path to a CA certificate bundle to be used for SSL verification. This will override the default CA certificate bundle. If not set, then the value of the OCI_ANSIBLE_CERT_BUNDLE variable, if any, is used.
compartment_id
string
The OCID of the compartment containing the alarm.
Required for create using state=present.
Required for update when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
Required for delete when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
This parameter is updatable.
config_file_location
string
Path to configuration file. If not set then the value of the OCI_CONFIG_FILE environment variable, if any, is used. Otherwise, defaults to ~/.oci/config.
config_profile_name
string
The profile to load from the config file referenced by config_file_location. If not set, then the value of the OCI_CONFIG_PROFILE environment variable, if any, is used. Otherwise, defaults to the "DEFAULT" profile in config_file_location.
defined_tags
dictionary
Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"Operations": {"CostCenter": "42"}}`
This parameter is updatable.
destinations
list / elements=string
A list of destinations to which the notifications for this alarm will be delivered. Each destination is represented by an OCID related to the supported destination service. For example, a destination using the Notifications service is represented by a topic OCID. Supported destination services: Notifications Service. Limit: One destination per supported destination service.
Required for create using state=present.
This parameter is updatable.
display_name
string
A user-friendly name for the alarm. It does not have to be unique, and it's changeable. Avoid entering confidential information.
This name is sent as the title for notifications related to this alarm.
Example: `High CPU Utilization`
Required for create using state=present.
Required for update, delete when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
This parameter is updatable when OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: name
force_create
boolean
    Choices:
  • no ←
  • yes
Whether to attempt non-idempotent creation of a resource. By default, create resource is an idempotent operation, and doesn't create the resource if it already exists. Setting this option to true, forcefully creates a copy of the resource, even if it already exists.This option is mutually exclusive with key_by.
freeform_tags
dictionary
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"Department": "Finance"}`
This parameter is updatable.
is_enabled
boolean
    Choices:
  • no
  • yes
Whether the alarm is enabled.
Example: `true`
Required for create using state=present.
This parameter is updatable.
is_notifications_per_metric_dimension_enabled
boolean
    Choices:
  • no
  • yes
When set to `true`, splits notifications per metric stream. When set to `false`, groups notifications across metric streams. Example: `true`
This parameter is updatable.
key_by
list / elements=string
The list of attributes of this resource which should be used to uniquely identify an instance of the resource. By default, all the attributes of a resource are used to uniquely identify a resource.
message_format
string
    Choices:
  • RAW
  • PRETTY_JSON
  • ONS_OPTIMIZED
The format to use for notification messages sent from this alarm. The formats are: * `RAW` - Raw JSON blob. Default value. * `PRETTY_JSON`: JSON with new lines and indents. * `ONS_OPTIMIZED`: Simplified, user-friendly layout. Applies only to messages sent through the Notifications service to the following subscription types: Email.
This parameter is updatable.
metric_compartment_id
string
The OCID of the compartment containing the metric being evaluated by the alarm.
Required for create using state=present.
This parameter is updatable.
metric_compartment_id_in_subtree
boolean
    Choices:
  • no
  • yes
When true, the alarm evaluates metrics from all compartments and subcompartments. The parameter can only be set to true when metricCompartmentId is the tenancy OCID (the tenancy is the root compartment). A true value requires the user to have tenancy-level permissions. If this requirement is not met, then the call is rejected. When false, the alarm evaluates metrics from only the compartment specified in metricCompartmentId. Default is false.
Example: `true`
This parameter is updatable.
namespace
string
The source service or application emitting the metric that is evaluated by the alarm.
Example: `oci_computeagent`
Required for create using state=present.
This parameter is updatable.
pending_duration
string
The period of time that the condition defined in the alarm must persist before the alarm state changes from "OK" to "FIRING". For example, a value of 5 minutes means that the alarm must persist in breaching the condition for five minutes before the alarm updates its state to "FIRING".
The duration is specified as a string in ISO 8601 format (`PT10M` for ten minutes or `PT1H` for one hour). Minimum: PT1M. Maximum: PT1H. Default: PT1M.
Under the default value of PT1M, the first evaluation that breaches the alarm updates the state to "FIRING".
The alarm updates its status to "OK" when the breaching condition has been clear for the most recent minute.
Example: `PT5M`
This parameter is updatable.
query
string
The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of the Monitoring service interprets results for each returned time series as Boolean values, where zero represents false and a non-zero value represents true. A true value means that the trigger rule condition has been met. The query must specify a metric, statistic, interval, and trigger rule (threshold or absence). Supported values for interval depend on the specified time range. More interval values are supported for smaller time ranges. You can optionally specify dimensions and grouping functions. Supported grouping functions: `grouping()`, `groupBy()`. For details about Monitoring Query Language (MQL), see L(Monitoring Query Language (MQL) Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). For available dimensions, review the metric definition for the supported service. See Supported Services.
Example of threshold alarm:
-----
CpuUtilization[1m]{availabilityDomain="cumS:PHX-AD-1"}.groupBy(availabilityDomain).percentile(0.9) > 85
-----
Example of absence alarm:
-----
CpuUtilization[1m]{availabilityDomain="cumS:PHX-AD-1"}.absent()
-----
Required for create using state=present.
This parameter is updatable.
region
string
The Oracle Cloud Infrastructure region to use for all OCI API requests. If not set, then the value of the OCI_REGION variable, if any, is used. This option is required if the region is not specified through a configuration file (See config_file_location). Please refer to https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm for more information on OCI regions.
repeat_notification_duration
string
The frequency at which notifications are re-submitted, if the alarm keeps firing without interruption. Format defined by ISO 8601. For example, `PT4H` indicates four hours. Minimum: PT1M. Maximum: P30D.
Default value: null (notifications are not re-submitted).
Example: `PT2H`
This parameter is updatable.
resolution
string
The time between calculated aggregation windows for the alarm. Supported value: `1m`
This parameter is updatable.
resource_group
string
Resource group that you want to match. A null value returns only metric data that has no resource groups. The alarm retrieves metric data associated with the specified resource group only. Only one resource group can be applied per metric. A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($). Avoid entering confidential information.
Example: `frontend-fleet`
This parameter is updatable.
severity
string
The perceived type of response required when the alarm is in the "FIRING" state.
Example: `CRITICAL`
Required for create using state=present.
This parameter is updatable.
state
string
    Choices:
  • present ←
  • absent
The state of the Alarm.
Use state=present to create or update an Alarm.
Use state=absent to delete an Alarm.
suppression
dictionary
The configuration details for suppressing an alarm.
This parameter is updatable.
description
string
Human-readable reason for suppressing alarm notifications. It does not have to be unique, and it's changeable. Avoid entering confidential information.
Oracle recommends including tracking information for the event or associated work, such as a ticket number.
Example: `Planned outage due to change IT-1234.`
time_suppress_from
string / required
The start date and time for the suppression to take place, inclusive. Format defined by RFC3339.
Example: `2019-02-01T01:02:29.600Z`
time_suppress_until
string / required
The end date and time for the suppression to take place, inclusive. Format defined by RFC3339.
Example: `2019-02-01T02:02:29.600Z`
tenancy
string
OCID of your tenancy. If not set, then the value of the OCI_TENANCY variable, if any, is used. This option is required if the tenancy OCID is not specified through a configuration file (See config_file_location). To get the tenancy OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm
wait
boolean
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout
integer
Time, in seconds, to wait when wait=yes. Defaults to 1200 for most of the services but some services might have a longer wait timeout.

Examples

- name: Create alarm
  oci_monitoring_alarm:
    # required
    display_name: display_name_example
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    metric_compartment_id: "ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx"
    namespace: namespace_example
    query: query_example
    severity: severity_example
    destinations: [ "destinations_example" ]
    is_enabled: true

    # optional
    metric_compartment_id_in_subtree: true
    resource_group: resource_group_example
    resolution: resolution_example
    pending_duration: pending_duration_example
    body: body_example
    is_notifications_per_metric_dimension_enabled: true
    message_format: RAW
    repeat_notification_duration: repeat_notification_duration_example
    suppression:
      # required
      time_suppress_from: time_suppress_from_example
      time_suppress_until: time_suppress_until_example

      # optional
      description: description_example
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Update alarm
  oci_monitoring_alarm:
    # required
    alarm_id: "ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx"

    # optional
    display_name: display_name_example
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    metric_compartment_id: "ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx"
    metric_compartment_id_in_subtree: true
    namespace: namespace_example
    resource_group: resource_group_example
    query: query_example
    resolution: resolution_example
    pending_duration: pending_duration_example
    severity: severity_example
    body: body_example
    is_notifications_per_metric_dimension_enabled: true
    message_format: RAW
    destinations: [ "destinations_example" ]
    repeat_notification_duration: repeat_notification_duration_example
    suppression:
      # required
      time_suppress_from: time_suppress_from_example
      time_suppress_until: time_suppress_until_example

      # optional
      description: description_example
    is_enabled: true
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Update alarm using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set)
  oci_monitoring_alarm:
    # required
    display_name: display_name_example
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"

    # optional
    metric_compartment_id: "ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx"
    metric_compartment_id_in_subtree: true
    namespace: namespace_example
    resource_group: resource_group_example
    query: query_example
    resolution: resolution_example
    pending_duration: pending_duration_example
    severity: severity_example
    body: body_example
    is_notifications_per_metric_dimension_enabled: true
    message_format: RAW
    destinations: [ "destinations_example" ]
    repeat_notification_duration: repeat_notification_duration_example
    suppression:
      # required
      time_suppress_from: time_suppress_from_example
      time_suppress_until: time_suppress_until_example

      # optional
      description: description_example
    is_enabled: true
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Delete alarm
  oci_monitoring_alarm:
    # required
    alarm_id: "ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx"
    state: absent

- name: Delete alarm using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set)
  oci_monitoring_alarm:
    # required
    display_name: display_name_example
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
alarm
complex
on success
Details of the Alarm resource acted upon by the current operation

Sample:
{'body': 'body_example', 'compartment_id': 'ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx', 'defined_tags': {'Operations': {'CostCenter': 'US'}}, 'destinations': [], 'display_name': 'display_name_example', 'freeform_tags': {'Department': 'Finance'}, 'id': 'ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx', 'is_enabled': True, 'is_notifications_per_metric_dimension_enabled': True, 'lifecycle_state': 'ACTIVE', 'message_format': 'RAW', 'metric_compartment_id': 'ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx', 'metric_compartment_id_in_subtree': True, 'namespace': 'namespace_example', 'pending_duration': 'pending_duration_example', 'query': 'query_example', 'repeat_notification_duration': 'repeat_notification_duration_example', 'resolution': 'resolution_example', 'resource_group': 'resource_group_example', 'severity': 'CRITICAL', 'suppression': {'description': 'description_example', 'time_suppress_from': '2013-10-20T19:20:30+01:00', 'time_suppress_until': '2013-10-20T19:20:30+01:00'}, 'time_created': '2013-10-20T19:20:30+01:00', 'time_updated': '2013-10-20T19:20:30+01:00'}
 
body
string
on success
The human-readable content of the notification delivered. Oracle recommends providing guidance to operators for resolving the alarm condition. Consider adding links to standard runbook practices.
Example: `High CPU usage alert. Follow runbook instructions for resolution.`

Sample:
body_example
 
compartment_id
string
on success
The OCID of the compartment containing the alarm.

Sample:
ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx
 
defined_tags
dictionary
on success
Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"Operations": {"CostCenter": "42"}}`

Sample:
{'Operations': {'CostCenter': 'US'}}
 
destinations
list / elements=string
on success
A list of destinations to which the notifications for this alarm will be delivered. Each destination is represented by an OCID related to the supported destination service. For example, a destination using the Notifications service is represented by a topic OCID. Supported destination services: Notifications Service. Limit: One destination per supported destination service.

 
display_name
string
on success
A user-friendly name for the alarm. It does not have to be unique, and it's changeable.
This name is sent as the title for notifications related to this alarm.
Example: `High CPU Utilization`

Sample:
display_name_example
 
freeform_tags
dictionary
on success
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"Department": "Finance"}`

Sample:
{'Department': 'Finance'}
 
id
string
on success
The OCID of the alarm.

Sample:
ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
 
is_enabled
boolean
on success
Whether the alarm is enabled.
Example: `true`

Sample:
True
 
is_notifications_per_metric_dimension_enabled
boolean
on success
When set to `true`, splits notifications per metric stream. When set to `false`, groups notifications across metric streams. Example: `true`

Sample:
True
 
lifecycle_state
string
on success
The current lifecycle state of the alarm.
Example: `DELETED`

Sample:
ACTIVE
 
message_format
string
on success
The format to use for notification messages sent from this alarm. The formats are: * `RAW` - Raw JSON blob. Default value. * `PRETTY_JSON`: JSON with new lines and indents. * `ONS_OPTIMIZED`: Simplified, user-friendly layout. Applies only to messages sent through the Notifications service to the following subscription types: Email.

Sample:
RAW
 
metric_compartment_id
string
on success
The OCID of the compartment containing the metric being evaluated by the alarm.

Sample:
ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx
 
metric_compartment_id_in_subtree
boolean
on success
When true, the alarm evaluates metrics from all compartments and subcompartments. The parameter can only be set to true when metricCompartmentId is the tenancy OCID (the tenancy is the root compartment). A true value requires the user to have tenancy-level permissions. If this requirement is not met, then the call is rejected. When false, the alarm evaluates metrics from only the compartment specified in metricCompartmentId. Default is false.
Example: `true`

Sample:
True
 
namespace
string
on success
The source service or application emitting the metric that is evaluated by the alarm.
Example: `oci_computeagent`

Sample:
namespace_example
 
pending_duration
string
on success
The period of time that the condition defined in the alarm must persist before the alarm state changes from "OK" to "FIRING". For example, a value of 5 minutes means that the alarm must persist in breaching the condition for five minutes before the alarm updates its state to "FIRING".
The duration is specified as a string in ISO 8601 format (`PT10M` for ten minutes or `PT1H` for one hour). Minimum: PT1M. Maximum: PT1H. Default: PT1M.
Under the default value of PT1M, the first evaluation that breaches the alarm updates the state to "FIRING".
The alarm updates its status to "OK" when the breaching condition has been clear for the most recent minute.
Example: `PT5M`

Sample:
pending_duration_example
 
query
string
on success
The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of the Monitoring service interprets results for each returned time series as Boolean values, where zero represents false and a non-zero value represents true. A true value means that the trigger rule condition has been met. The query must specify a metric, statistic, interval, and trigger rule (threshold or absence). Supported values for interval depend on the specified time range. More interval values are supported for smaller time ranges. You can optionally specify dimensions and grouping functions. Supported grouping functions: `grouping()`, `groupBy()`. For details about Monitoring Query Language (MQL), see L(Monitoring Query Language (MQL) Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). For available dimensions, review the metric definition for the supported service. See Supported Services.
Example of threshold alarm:
-----
CpuUtilization[1m]{availabilityDomain="cumS:PHX-AD-1"}.groupBy(availabilityDomain).percentile(0.9) > 85
-----
Example of absence alarm:
-----
CpuUtilization[1m]{availabilityDomain="cumS:PHX-AD-1"}.absent()
-----

Sample:
query_example
 
repeat_notification_duration
string
on success
The frequency at which notifications are re-submitted, if the alarm keeps firing without interruption. Format defined by ISO 8601. For example, `PT4H` indicates four hours. Minimum: PT1M. Maximum: P30D.
Default value: null (notifications are not re-submitted).
Example: `PT2H`

Sample:
repeat_notification_duration_example
 
resolution
string
on success
The time between calculated aggregation windows for the alarm. Supported value: `1m`

Sample:
resolution_example
 
resource_group
string
on success
Resource group to match for metric data retrieved by the alarm. A resource group is a custom string that you can match when retrieving custom metrics. Only one resource group can be applied per metric. A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).
Example: `frontend-fleet`

Sample:
resource_group_example
 
severity
string
on success
The perceived type of response required when the alarm is in the "FIRING" state.
Example: `CRITICAL`

Sample:
CRITICAL
 
suppression
complex
on success
The configuration details for suppressing an alarm.

   
description
string
on success
Human-readable reason for suppressing alarm notifications. It does not have to be unique, and it's changeable. Avoid entering confidential information.
Oracle recommends including tracking information for the event or associated work, such as a ticket number.
Example: `Planned outage due to change IT-1234.`

Sample:
description_example
   
time_suppress_from
string
on success
The start date and time for the suppression to take place, inclusive. Format defined by RFC3339.
Example: `2019-02-01T01:02:29.600Z`

Sample:
2013-10-20T19:20:30+01:00
   
time_suppress_until
string
on success
The end date and time for the suppression to take place, inclusive. Format defined by RFC3339.
Example: `2019-02-01T02:02:29.600Z`

Sample:
2013-10-20T19:20:30+01:00
 
time_created
string
on success
The date and time the alarm was created. Format defined by RFC3339.
Example: `2019-02-01T01:02:29.600Z`

Sample:
2013-10-20T19:20:30+01:00
 
time_updated
string
on success
The date and time the alarm was last updated. Format defined by RFC3339.
Example: `2019-02-03T01:02:29.600Z`

Sample:
2013-10-20T19:20:30+01:00


Authors

  • Oracle (@oracle)