# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
from datetime import datetime
import oci
# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()
# Initialize service client with default config file
monitoring_client = oci.monitoring.MonitoringClient(config)
# Send the request to service, some parameters are not required, see API
# doc for more info
create_alarm_response = monitoring_client.create_alarm(
create_alarm_details=oci.monitoring.models.CreateAlarmDetails(
display_name="EXAMPLE-displayName-Value",
compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
metric_compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-metricCompartmentId-Value",
namespace="EXAMPLE-namespace-Value",
query="EXAMPLE-query-Value",
severity="ERROR",
destinations=["EXAMPLE--Value"],
is_enabled=True,
metric_compartment_id_in_subtree=False,
resource_group="EXAMPLE-resourceGroup-Value",
resolution="EXAMPLE-resolution-Value",
pending_duration="EXAMPLE-pendingDuration-Value",
body="EXAMPLE-body-Value",
is_notifications_per_metric_dimension_enabled=True,
message_format="RAW",
repeat_notification_duration="EXAMPLE-repeatNotificationDuration-Value",
suppression=oci.monitoring.models.Suppression(
time_suppress_from=datetime.strptime(
"2008-03-03T08:49:47.056Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
time_suppress_until=datetime.strptime(
"2012-06-12T06:10:39.114Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
description="EXAMPLE-description-Value"),
freeform_tags={
'EXAMPLE_KEY_fpyLh': 'EXAMPLE_VALUE_dXiQr31akZoyixRfSgEK'},
defined_tags={
'EXAMPLE_KEY_nur7e': {
'EXAMPLE_KEY_u3EXm': 'EXAMPLE--Value'}},
overrides=[
oci.monitoring.models.AlarmOverride(
pending_duration="EXAMPLE-pendingDuration-Value",
severity="CRITICAL",
body="EXAMPLE-body-Value",
rule_name="EXAMPLE-ruleName-Value",
query="EXAMPLE-query-Value")],
rule_name="EXAMPLE-ruleName-Value",
notification_version="EXAMPLE-notificationVersion-Value",
notification_title="EXAMPLE-notificationTitle-Value",
evaluation_slack_duration="EXAMPLE-evaluationSlackDuration-Value",
alarm_summary="EXAMPLE-alarmSummary-Value"),
opc_request_id="T7OAZSUXIWDKY6M7ROL5<unique_ID>",
opc_retry_token="EXAMPLE-opcRetryToken-Value")
# Get the data from response
print(create_alarm_response.data)