Create a Metric Threshold
/monitoring/monitoring/{idDomainName}/.customer/api/v1/metricThresholds
For some Oracle Cloud services, service administrators can configure rules to generate alerts when metrics exceed or are under specified thresholds for a specific time period.
You can specify thresholds to monitor and receive alerts about specific metrics for specific instances. The resulting alert can be either an email to the service administrator or a notification message to the process that's polling for changes in the state of the alert threshold.
The specified alert action (email or notification message) is triggered in the following situations:
- The metric being monitored has crossed the defined threshold and has remained in that state for the period specified in the alert condition.
- The metric has returned to a value that's within the threshold and has remained in that state for the period specified in the alert condition.
Request
- application/json
-
idDomainName: string
Identity domain ID for the Oracle Monitoring Cloud Service account.
-
Authorization: string
Basic Authentication credentials. The user must be located in the identity domain name specified by the header X-ID-TENANT-NAME.
-
Content-Type: string
Must be set to "application/json". The content in an HTTP request body must be encoded in JavaScript Object Notation (JSON).
-
X-ID-TENANT-NAME: string
Set to the identity domain ID where the user specified in the Authorization header resides.
object
-
alertAction(optional):
object MetricThresholdAlertAction
-
canonicalLink(optional):
string(uri)
Read Only:
true
Relative path to the resource. -
condition(optional):
object MetricThresholdCondition
-
id(optional):
string(uuid)
Read Only:
true
Unique ID of the metric threshold. -
name(optional):
string
Specify a name for the metric threshold.
-
target(optional):
object MetricTarget
object
-
channelType(optional):
string
Specify the type of alert notification to be sent. By default, the
channelType
attribute is set toNOTIFICATION_MESSAGE
. In this case, an email notification is sent to the service administrator of the requested resource when an event occurs.
ThechannelType
attribute can also be set toPUSH_TO_CLIENT
. In this case, notification messages are delivered to the process polling for state changes. -
type(optional):
string
Specify the alert action type.
object
-
operation(optional):
string
Specify the operation (>, <, <=, >=, =).
-
periodCountToSatisfy(optional):
integer(int32)
Enter the number of consecutive times the metric must meet the criteria specified by you to trigger an alert.
-
periodCountToUnsatisfy(optional):
integer(int32)
Enter the number of consecutive times that the metric must be within the threshold limit to trigger an alert.
-
periodDuration(optional):
string
Specify the time period for which you want to monitor the metric.
Note: You must use the iCalendar Duration format. For example,PT10M
.
By defaultperiodDuration
is set toPT5M
. The minimum accepted value forperiodDuration
isPT5M
. -
stats(optional):
string
Specify the statistic to monitor (avg, count, min, max, sum).
-
value(optional):
number(double)
Specify the threshold value.
object
-
canonicalLink(optional):
string(uri)
Relative path to the resource.
-
id(optional):
string(uuid)
A unique ID representing a metric type for a specific metric subject. For example, 821ce631-691e-494e-ba69-526739e086e2.
-
isDeleted(optional):
boolean
Default Value:
false
Indicates whether the referenced object has been deleted. -
metricType(optional):
object MetricType
-
subject(optional):
object MetricSubject
object
-
canonicalLink(optional):
string(uri)
Relative path to the resource.
-
description(optional):
string
Description of the metric type.
-
displayName(optional):
string
Display name of the metric type.
-
id(optional):
string
Unique ID of the metric type. For example, compute.CPU.PERCENT.
-
name(optional):
string
Short name of the metric type. For example, cpuPercent.
-
shortDisplayName(optional):
string
Short display name for the metric type.
-
subjectType(optional):
object MetricSubjectType
-
unit(optional):
object MetricUnit
object
-
canonicalLink(optional):
string(uri)
Relative path to the resource.
-
displayName(optional):
string
Display name of the metric subject.
-
id(optional):
string(uuid)
Unique ID of the metric subject. For example, bbdce636-691e-494e-ba69-526739e086e0.
-
isDeleted(optional):
boolean
Default Value:
false
Indicates whether the referenced object has been deleted. -
properties(optional):
array properties
Properties of the subject.
-
subjectType(optional):
object MetricSubjectType
object
-
id(optional):
string
Unique ID of the metric unit. For example, compute.vm.
object
-
canonicalLink(optional):
string(uri)
Relative path to the resource.
-
displayName(optional):
string
Display name of the metric unit.
-
id(optional):
string
Unique ID of the metric unit. For example, BYTES.
-
shortDisplayName(optional):
string
Short display name for the metric unit.
object
-
name(optional):
string
The name of the metric property. For example, vmUuid.
-
value(optional):
string
The value of the metric property. For example, 11da4f96-e95e-4998-810c-198d5df034c4 for the vmUuid property.
Response
- application/json
201 Response
Examples
The following example shows how to create a metric threshold by submitting a POST request on the REST resource using cURL. See Use cURL.
curl -X POST -u joe@example.com:Mypassword1! -H "Authorization: Basic d2VibG9naWM6V2VsY29tZTE=" -H "X-ID-TENANT-NAME:mydomain" -H "Content-Type:application/json" -d "@requestbody.json" https://monitoring.us.oraclecloud.com/monitoring/mydomain/.customer/api/v1/metricThresholds
Example of Request Body
The following shows an example of the request body content in the requestbody.json
file.
{ "name" : "VM1 High Cpu", "target" : { "series" : { "id" : "13123123-43242342-234234234" } }, "condition" : { "stats" : "avg", "operation" : ">=", "value" : 70, "periodDuration" : "PT10M", "periodCountToSatisfy" : 3, "periodCountToUnsatisfy" : 2 }, "alertAction" : { "type" : "notification" } }
In the above example, an alert is sent when:
-
The average CPU usage is at or over 70% for three consecutive 10-minute periods.
-
The average CPU usage falls back to below 70% for two consecutive 10-minute periods.
-
If a metric remains above the threshold for more than 3 consecutive 10-minute periods and there is no change in the threshold state.
-
If a metric remains below or is within the threshold for more than 2 consecutive 10-minute periods and there is no change in the threshold state.
Time | Metric Value | Alert Sent (Y/N) |
---|---|---|
10:00 |
Threshold Created |
N |
10:10 |
66 |
N |
10:20 |
75 |
N |
10:30 |
84 |
N |
10:40 |
82 |
Y (Avg>=70 for 3 consecutive 10-minute periods) |
10:50 |
84 |
N |
11:00 |
83 |
N |
11:10 |
81 |
N |
11:20 |
65 |
N |
11:30 |
60 |
Y (Avg<70 for 2 consecutive 10-minute periods) |
11:40 |
63 |
N |
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 201 Created Date: Tue, 08 Mar 2016 12:20:49 GMT Content-Type: application/json