// 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.Error,
body: "EXAMPLE-body-Value",
isNotificationsPerMetricDimensionEnabled: false,
messageFormat: monitoring.models.CreateAlarmDetails.MessageFormat.PrettyJson,
destinations: ["EXAMPLE--Value"],
repeatNotificationDuration: "EXAMPLE-repeatNotificationDuration-Value",
suppression: {
description: "EXAMPLE-description-Value",
timeSuppressFrom: new Date("Sun Apr 03 16:49:23 UTC 2005"),
timeSuppressUntil: new Date("Sun Apr 28 16:59:36 UTC 2024")
},
isEnabled: false,
freeformTags: {
EXAMPLE_KEY_VSXcR: "EXAMPLE_VALUE_Ab4jNb2kLqwkcWroliQs"
},
definedTags: {
EXAMPLE_KEY_EbWCI: {
EXAMPLE_KEY_Clz8C: "EXAMPLE--Value"
}
},
overrides: [
{
pendingDuration: "EXAMPLE-pendingDuration-Value",
severity: monitoring.models.Alarm.Severity.Critical,
body: "EXAMPLE-body-Value",
ruleName: "EXAMPLE-ruleName-Value",
query: "EXAMPLE-query-Value"
}
],
ruleName: "EXAMPLE-ruleName-Value",
notificationVersion: "EXAMPLE-notificationVersion-Value"
};
const createAlarmRequest: monitoring.requests.CreateAlarmRequest = {
createAlarmDetails: createAlarmDetails,
opcRequestId: "E8HIM8UKJX7NWHZPTOND<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);
}
})();