// 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).
import * as monitoring from "oci-monitoring";
import common = require("oci-common");
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new monitoring.MonitoringClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const createAlarmDetails = {
displayName: "EXAMPLE-displayName-Value",
compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
metricCompartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-metricCompartmentId-Value",
metricCompartmentIdInSubtree: false,
namespace: "EXAMPLE-namespace-Value",
resourceGroup: "EXAMPLE-resourceGroup-Value",
query: "EXAMPLE-query-Value",
resolution: "EXAMPLE-resolution-Value",
pendingDuration: "EXAMPLE-pendingDuration-Value",
severity: monitoring.models.Alarm.Severity.Warning,
body: "EXAMPLE-body-Value",
isNotificationsPerMetricDimensionEnabled: true,
messageFormat: monitoring.models.CreateAlarmDetails.MessageFormat.OnsOptimized,
destinations: ["EXAMPLE--Value" ],
repeatNotificationDuration: "EXAMPLE-repeatNotificationDuration-Value",
suppression: {
description: "EXAMPLE-description-Value",
timeSuppressFrom: new Date("Sat Aug 31 14:30:40 UTC 2013"),
timeSuppressUntil: new Date("Sun Nov 04 23:09:21 UTC 2035"),
}
,
isEnabled: false,
freeformTags: {
EXAMPLE_KEY_RfSgE :"EXAMPLE_VALUE_Ku3EXmnur7ekt7oAzsUX"
},
definedTags: {
EXAMPLE_KEY_6M7RO :{
EXAMPLE_KEY_IWDKY :"EXAMPLE--Value"
}
},
overrides: [{
pendingDuration: "EXAMPLE-pendingDuration-Value",
severity: monitoring.models.Alarm.Severity.Warning,
body: "EXAMPLE-body-Value",
ruleName: "EXAMPLE-ruleName-Value",
query: "EXAMPLE-query-Value",
}
],
ruleName: "EXAMPLE-ruleName-Value",
notificationVersion: "EXAMPLE-notificationVersion-Value",
notificationTitle: "EXAMPLE-notificationTitle-Value",
evaluationSlackDuration: "EXAMPLE-evaluationSlackDuration-Value",
alarmSummary: "EXAMPLE-alarmSummary-Value",
}
const createAlarmRequest: monitoring.requests.CreateAlarmRequest = {
createAlarmDetails: createAlarmDetails,
opcRequestId: "5VUCADGMZ8VODEKQJJKP<unique_ID>",
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
};
// Send request to the Client.
const createAlarmResponse = await client.createAlarm(createAlarmRequest);
}
catch (error) {
console.log("createAlarm Failed with error " + error);
}
})();