Introduction
The IBM Cloud™ Monitoring service helps you gain insight into how your apps are performing and consuming resources. You can use the Monitoring service to expand your collection and retention capabilities when working with metrics in the IBM Cloud, and to be able to define rules and alerts that notify you of conditions that require attention.
The Monitoring service provides the following REST APIs:
- A Metrics API that you can use to send and retrieve data from a space domain.
- An Alerts API that you can use to configure alerts on metrics.
- A Dashboards API that you can use to create, read, update, delete, search, and migrate Grafana 4 dashboards.
For details about using the Monitoring service, see the IBM Cloud docs.
Error handling
The Monitoring service uses standard HTTP response codes to indicate whether a method completed successfully. A 200
response always indicates success. A 400
type response is some sort of failure, and a 500
type response usually indicates an internal system error.
Status code | Description | Description |
---|---|---|
200 | OK | Everything worked as expected. |
400 | Bad Request | The request was unsuccessful, often due to a missing required parameter. |
401 | Unauthorized | The parameters were valid but the request failed. |
404 | Not Found | The requested resource doesn't exist. |
500 | Server Error | Something went wrong. |
Methods
Create an alert rule
Create an alert rule.
A rule describes the metric query to be monitored, the threshold value, and the action to take when the threshold is crossed.
The alert system checks every 5 minutes the rules that are enabled in the space.
By default, a rule is enabled when you create it. However, you can define the rule, and disable it, by configuring the field enable to false.
Also, by default, a rule is created with the field allow_no_datapoints set to true. When no datapoints are available, notifications are not sent unless the rule condition is triggered. If you want to receive a notification to inform that no data was found for rule X, you must set the field allow_no_data to false.
POST /alert/rule
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
The definition for this rule
User assigned name for this rule.
Metric expression to be evaluated.
Specifies the beginning range offset. For example: -15min
Specifies the ending range offset. For example: -5min, or now. Defaults to 'now'.
Type of the comparison.
Allowable values: [
above
,below
]Description of the check. (optional)
Set to enable or disable the rule. No alerts will be sent if enabled is set to false. Defaults to true.
Set to not trigger an alert when there are no datapoints for the given expression. Defaults to true.
Default:
true
Scope of the queried values that should be used in the comparison. Defaults to 'last'.
Allowable values: [
last
]Defines how often the check will be performed measured in minutes, hours or days ( ie. 5min, 1h, 7d ). Currently fixed at 1 minute and not configurable. (optional)
Path to the dashboard to perform queries against. (optional)
Name(s) of the alert notification(s) this rule will trigger once the comparison operation resolves to true.
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
The definition for this rule
User assigned name for this rule.
Description of the check. (optional)
Metric expression to be evaluated.
Set to enable or disable the rule. No alerts will be sent if enabled is set to false. Defaults to true.
Set to not trigger alert when there are no datapoints for the given expression. Defaults to true.
Default:
true
Specifies the beginning range offset. For example: -15min
Specifies the ending range offset. For example: -5min, or now. Defaults to 'now'.
Type of the comparison.
Allowable values: [
above
,below
]Scope of the queried values that should be used in the comparison. Defaults to 'last'.
Allowable values: [
last
]Defines how often the check will be performed measured in minutes, hours or days ( ie. 5min, 1h, 7d ). Currently fixed at 1 minute and not configurable. (optional)
Path to the dashboard to perform queries against. (optional)
Name(s) of the alert notification(s) this rule will trigger once the comparison operation resolves to true.
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Path Parameters
The name of the alert rule to be retrieved
Response
User assigned name for this rule.
Metric expression to be evaluated.
Specifies the beginning range offset. For example: -15min
Specifies the ending range offset. For example: -5min, or now. Defaults to 'now'.
Type of the comparison.
Possible values: [
above
,below
]Description of the check. (optional)
Set to enable or disable the rule. No alerts will be sent if enabled is set to false. Defaults to true.
Set to not trigger an alert when there are no datapoints for the given expression. Defaults to true.
Scope of the queried values that should be used in the comparison. Defaults to 'last'.
Possible values: [
last
]Defines how often the check will be performed measured in minutes, hours or days ( ie. 5min, 1h, 7d ). Currently fixed at 1 minute and not configurable. (optional)
Path to the dashboard to perform queries against. (optional)
Name(s) of the alert notification(s) this rule will trigger once the comparison operation resolves to true.
Status Code
Contents of the alert rule for the named alert
The rule was not found
Unexpected service error
{ "expression": "expression", "comparison": "above", "name": "name", "allow_no_data": true, "description": "description", "from": "from", "until": "until", "dashboard_url": "dashboard_url", "enabled": true, "notifications": [ "notifications", "notifications" ], "comparison_scope": "last", "frequency": "frequency" }
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Path Parameters
The name of the alert rule to be deleted
Retrieve all of the defined rules
This API will return an array of json object that each contain the rule definitions for the current scope and project-id passed in the headers.
GET /alert/rules
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Response
User assigned name for this rule.
Metric expression to be evaluated.
Specifies the beginning range offset. For example: -15min
Specifies the ending range offset. For example: -5min, or now. Defaults to 'now'.
Type of the comparison.
Possible values: [
above
,below
]Description of the check. (optional)
Set to enable or disable the rule. No alerts will be sent if enabled is set to false. Defaults to true.
Set to not trigger an alert when there are no datapoints for the given expression. Defaults to true.
Scope of the queried values that should be used in the comparison. Defaults to 'last'.
Possible values: [
last
]Defines how often the check will be performed measured in minutes, hours or days ( ie. 5min, 1h, 7d ). Currently fixed at 1 minute and not configurable. (optional)
Path to the dashboard to perform queries against. (optional)
Name(s) of the alert notification(s) this rule will trigger once the comparison operation resolves to true.
Status Code
Contents of the alert rule for the named alert.
The rule was not found
Unexpected service error
No Sample Response
Create an alert notification
Create an alert notification that defines the operation to be executed when an alert rule is raised
POST /alert/notification
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
The definition for this notification.
User assigned name for this rule.
Type of the alert notification.
Allowable values: [
Email
,PagerDuty
,Webhook
]Details for the alert. The value depends on the type, and could be email address, PagerDuty API key or the webhook url.
Description of the check. (optional)
Indicates whether or not a verified HTTPS request will be made if the 'type' is 'Webhook'.
Update an alert notification
Update some or all fields in an alert notification
PUT /alert/notification
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
The definition for this notification.
User assigned name for this rule.
Description of the check. (optional)
Type of the alert notification.
Allowable values: [
Email
,PagerDuty
,Webhook
]Details for the alert. This depends on type and could be email address, PagerDuty API key or the webhook url.
Indicates whether or not a verified HTTPS request will be made if the 'type' is 'Webhook'.
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Path Parameters
The name of the alert notification to be retrieved
Response
User assigned name for this rule.
Type of the alert notification.
Possible values: [
Email
,PagerDuty
,Webhook
]Details for the alert. The value depends on the type, and could be email address, PagerDuty API key or the webhook url.
Description of the check. (optional)
Indicates whether or not a verified HTTPS request will be made if the 'type' is 'Webhook'.
Status Code
Contents of the alert notification
The notification was not found
Unexpected service error
{ "name": "emailBob", "description": "email Bob when there's a problem", "type": "Email", "detail": "bob@ibm.com" }
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Path Parameters
The name of the alert notification to be deleted
Retrieve all of the defined alert notifications
This API will return an array of json object containing the alert notification definitions for the current scope and project-id passed in the headers.
GET /alert/notifications
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Response
User assigned name for this rule.
Type of the alert notification.
Possible values: [
Email
,PagerDuty
,Webhook
]Details for the alert. The value depends on the type, and could be email address, PagerDuty API key or the webhook url.
Description of the check. (optional)
Indicates whether or not a verified HTTPS request will be made if the 'type' is 'Webhook'.
Status Code
Contents of the alert rule for the named alert
The notification was not found
Unexpected service error
No Sample Response
Test an alert notification
Triggers a test alert for validating the notification is properly setup
POST /alert/notification/test/{name}
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Path Parameters
Name for this alert notification - must be unique for the this scope id
Request
Custom Headers
The UAA token or IAM token. The token or apikey must be prefixed with one of the following values:
apikey
,iam
oruaa
, whereapikey
identifies that the token is an apikeyiam
identifies that the token specified is an IAM generated tokenuaa
identifies that the token specified is an UAA generated token
For example:
X-Auth-User-Token: apikey SomeIAMGeneratedKey
Cloud Foundry space GUID
The GUID must be prefixed with
s-
to identify a spaceThis header is required if using UAA token authentication.
If you use IAM authentication, then this header is optional, in which case the account bound to the token will be used as the domain.
Query Parameters
The rule name by which to filter the history results
Response
Name of the alert rule that was triggered.
Fully expanded metric path that caused the rule to be triggered.
Timestamp of the alert rule that was triggered.
Name(s) of the notification target(s) that were invoked.
Alert level for the rule before the alert state changed.
Possible values: [
OK
,WARN
,ERROR
]Alert level for the rule after the alert state changed.
Possible values: [
OK
,WARN
,ERROR
]
Status Code
Array of the most recent alery history for this account, space or organization
The history for the given rule/notification was not found
Unexpected service error