Monitor Changes to the State of a Metric
/monitoring/monitoring/{idDomainName}/.customer/api/v1/notificationPollingInfo
Request
-
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.
-
X-ID-TENANT-NAME: string
Set to the identity domain ID where the user specified in the Authorization header resides.
Response
- application/json
200 Response
object
-
httpRequestTimeoutHint(optional):
integer(int32)
Suggested client side timeout.
-
pollResult(optional):
object PollResult
-
waitTimeBeforePolling(optional):
integer(int64)
Number of seconds the caller must wait before next poll request.
object
-
canonicalLink(optional):
string(uri)
Notifications polling URL.
object
-
eventStartedOn(optional):
string(date-time)
First occurrence of the event type.
-
eventType(optional):
string
Event type (changedToSatisfied or changedToUnsatisfied)
-
id(optional):
string(uuid)
Read Only:
true
A unique ID representing the event. -
identityDomain(optional):
string
Identity domain ID of the event type.
-
threshold(optional):
object MetricThreshold
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.
Examples
The following example shows how to monitor changes to the state of a metric by submitting a GET request on the REST resource using cURL. See Use cURL.
-
First make a request to get the long poll URL to listen to.
-
Start listening to the long poll URL.
Run the following cURL command to perform the long poll request:
curl -X GET -H "Authorization: Basic d2VibG9naWM6V2VsY29tZTE=" -H "X-ID-TENANT-NAME:mydomain" https://monitoring.us.oraclecloud.com/monitoring/mydomain/.customer/api/v1/notificationPollingInfo HTTP/1.1
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 200 OK Date: Tue, 02 Feb 2016 18:32:30 GMT Content-Type: application/json
Example of Response Body
The following example shows the contents of the response body in JSON format:
{ "notifications": [], "nextLongPollInfo": { "pollResult": { "canonicalLink": "http://monitoring.us.oraclecloud.com:8003/notification/.tpolling/.common/.oracleNotification/v1?accessToken=860C2D6D666FA56E7F6947CCACCCA5D8=0=http%3A%2F%2Fmonitoring.us.oraclecloud.com%3A8003%2Fmonitoring%2Fmydomain%2F.customer%2Fapi%2Fv1%2FnotificationPollingInfo%2FtokenUpdate=e0d33142-044f-4db0-a9e0-b3e0a7b2521f=MTQ1NDQzNjgzOTk1OC0xLTE0NTQ0MzY4Mzk5NTg%3D=1454436839958" }, "waitTimeBeforePolling": 60, "httpRequestTimeoutHint": 300 } }
To receive notification of metric state changes you must iteratively:
-
Wait for
waitTimeBeforePolling
seconds. -
Perform a GET request on the
nextLongPollInfo.pollResult.canonicalLink
.
Run the following cURL command to start listening to the long poll URL:
GET curl -X GET -H "Authorization: Basic d2VibG9naWM6V2VsY29tZTE=" -H "X-ID-TENANT-NAME:mydomain" -H "Content-Type: application/json" http://monitoring.us.oraclecloud.com:8003/notification/.tpolling/.common/.oracleNotification/v1?accessToken=860C2D6D666FA56E7F6947CCACCCA5D8=0=http%3A%2F%2Fslc000xyz.us.oracle.com%3A8003%2Fmonitoring%2Fmydomain%2F.customer%2Fapi%2Fv1%2FnotificationPollingInfo%2FtokenUpdate=e0d33142-044f-4db0-a9e0-b3e0a7b2521f=MTQ1NDQzNjgzOTk1OC0xLTE0NTQ0MzY4Mzk5NTg%3D=1454436839958
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 200 OK Date: Tue, 02 Feb 2016 18:32:30 GMT Content-Type: application/json
Example of Response Body
The following example shows the contents of the response body in JSON format:
{ "notifications": [ { "createdOn": "2016-02-02T18:32:30.239Z", "data": { { "id" : "2b047a03-90a9-2ab3-e053-6a64f10a1d39", "identityDomain" : "mydomain", "eventType" : "changedToSatisfied", "eventStartedOn" : "2016-02-05T16:45:00.000Z", "threshold" : { "id" : "3e803a5d-8c30-4e33-b53e-1a912de0a55e", "target" : { "series" : { "id" : "2af7d08b-059b-61c2-e053-6a64f10ad5d2", "metricType" : { "id" : "compute.CPU.PERCENT", "name" : "cpuPercent", "displayName" : "CPU Percentage", "shortDisplayName" : "CPU", "importName" : "CPU.PERCENT", "unit" : { "id" : "PERCENT" }, "subjectType" : { "id" : "compute.vm" } }, "subject" : { "id" : "2af7d08b-0537-61c2-e053-6a64f10ad5d2", "subjectType" : { "id" : "compute.vm" }, "properties" : [{ "name" : "vmLabel", "value" : "USDEVSS0$403B95B2-45DB-4BB8-A69D-40DC303573D7" }, { "name" : "vmType", "value" : "Compute" }, { "name" : "vmUuid", "value" : "2AF7D08B053761C2E0536A64F10AD5D2" }, { "name" : "vmZone", "value" : "COMPUTE-US2-Z18" } ], "isDeleted" : false } } }, "name" : "VM1 High CPU Alert", "condition" : { "stats" : "avg", "operation" : ">=", "value" : 70.0, "periodDuration" : "PT5M", "periodCountToSatisfy" : 1, "periodCountToUnsatisfy" : 1 }, "alertAction" : { "type" : "postToEndPoint", "url" : "http://example.us.examplecompany.com:8989" } } } }, "notificationTypeId": "default" } ], "nextLongPollInfo": { "pollResult": { "canonicalLink": "http://monitoring.us.oraclecloud.com:8003/notification/.tpolling/.common/.oracleNotification/v1?accessToken=939FAD72573AEA39E6D17613DCBACADC=2261610=http%3A%2F%2Fslc00xyz.us.oracle.com%3A8003%2Fmonitoring%2Facme%2F.customer%2Fapi%2Fv1%2FnotificationPollingInfo%2FtokenUpdate=e0d33142-044f-4db0-a9e0-b3e0a7b2521f=MTQ1NDQzNzk1NDMxMy0xLTE0NTQ0MzgxMTg5OTM%3D=1454437951332" }, "waitTimeBeforePolling": 5, "httpRequestTimeoutHint": 300 }, "canonicalLink": "/notification/.tpolling/.common/.oracleNotification/v1?accessToken=860C2D6D666FA56E7F6947CCACCCA5D8=0=http%3A%2F%2Fmonitoring.us.oraclecloud.com%3A8003%2Fmonitoring%2Facme%2F.customer%2Fapi%2Fv1%2FnotificationPollingInfo%2FtokenUpdate=e0d33142-044f-4db0-a9e0-b3e0a7b2521f=MTQ1NDQzNjgzOTk1OC0xLTE0NTQ0Mzc1ODM3OTc%3D=1454437768932" }
Note:
-
Multiple entries can be returned in the
notifications
list. -
The
threshold
element indicates the threshold associated with the current event. -
By default, there is a limit of 50 thresholds per identity domain.