IBM Cloud Monitoring Alerts API

Introduction

The IBM Cloud Monitoring Alerts API provides a query-based alerting solution that works with the existing features of the Monitoring service.

In order to set an alert, you must define:

  • An alert rule that describes the metric query to be monitored, the threshold value, and the actions (notification) to take when the threshold is crossed
  • An alert notification that describes how to notify something or someone that the alert rule has been triggered. You can notify through email, PagerDuty, or Webhook.
Base URL
https://metrics.ng.bluemix.net/v1

Reference

Show the alert history for a Bluemix space.

Show the alert history for a Bluemix space.

GET
/alert/history
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Query Parameters

  • The rule name by which to filter the history results.

Example Request

HttpResponse<String> response = Unirest.get("https://metrics.ng.bluemix.net/v1/alert/history?rule=string")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/history?rule=string",
  "method": "GET",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/history?rule=string",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("GET", "/v1/alert/history?rule=string", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request GET \
  --url 'https://metrics.ng.bluemix.net/v1/alert/history?rule=string' \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • The alert level for the rule before the alert state changed.

  • The names of the notification targets that were invoked. You can list one or more notification targets.

  • The name of the alert rule that was triggered.

  • The timestamp of the alert rule that was triggered.

  • The alert level for the rule after the alert state changed.

Status 200

{
  "from_level": "STRING",
  "notifications": "ARRAY",
  "rule": "STRING",
  "timestamp": "STRING",
  "to_level": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Create an alert notification.

Create an alert notification that defines the operation to be executed when an alert rule is triggered.

POST
/alert/notification
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Request Body

  • A brief description of the notification.

  • The details for the alert. The value depends on the notification type. The value can be an email address, a PagerDuty API key or the webhook url.

  • The name of the rule.

  • The type of the alert notification.

Example Request

HttpResponse<String> response = Unirest.post("https://metrics.ng.bluemix.net/v1/alert/notification")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .body("{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notification",
  "method": "POST",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  },
  "processData": false,
  "data": "{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "POST",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notification",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ description: 'string',
  detail: 'string',
  name: 'string',
  type: 'string' }));
req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

payload = "{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}"

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("POST", "/v1/alert/notification", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request POST \
  --url https://metrics.ng.bluemix.net/v1/alert/notification \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string' \
  --data '{"description":"string","detail":"string","name":"string","type":"string"}'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 400

{
  "Code": "STRING",
  "message": "STRING"
}

Status 403

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Status 409

"undefined"

Update an alert notification.

Update some or all of the fields in an alert notification.

PUT
/alert/notification
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Request Body

  • A brief description of the notification.

  • The details for the alert. The value depends on the notification type. The value can be an email address, a PagerDuty API key or the webhook URL.

  • Name of the notification.

  • The type of alert notification.

Example Request

HttpResponse<String> response = Unirest.put("https://metrics.ng.bluemix.net/v1/alert/notification")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .body("{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notification",
  "method": "PUT",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  },
  "processData": false,
  "data": "{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "PUT",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notification",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ description: 'string',
  detail: 'string',
  name: 'string',
  type: 'string' }));
req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

payload = "{\"description\":\"string\",\"detail\":\"string\",\"name\":\"string\",\"type\":\"string\"}"

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("PUT", "/v1/alert/notification", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request PUT \
  --url https://metrics.ng.bluemix.net/v1/alert/notification \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string' \
  --data '{"description":"string","detail":"string","name":"string","type":"string"}'
Response

No Response Details

This endpoint does not specify any response properties.

Status 200

"undefined"

Status 400

{
  "Code": "STRING",
  "message": "STRING"
}

Status 403

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Test an alert notification.

Test an alert and the notification associated with it.

POST
/alert/notification/test/{name}
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Path Parameters

  • Name for this alert notification - must be unique for the this scope id

Example Request

HttpResponse<String> response = Unirest.post("https://metrics.ng.bluemix.net/v1/alert/notification/test/{name_string}")
  .header("x-auth-scope-id", "string")
  .header("x-auth-service-name", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notification/test/{name_string}",
  "method": "POST",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-service-name": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "POST",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notification/test/{name_string}",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-service-name": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-service-name': "string",
    'x-auth-user-token': "string"
    }

conn.request("POST", "/v1/alert/notification/test/{name_string}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request POST \
  --url https://metrics.ng.bluemix.net/v1/alert/notification/test/{name_string} \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-service-name: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 400

{
  "Code": "STRING",
  "message": "STRING"
}

Status 403

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Delete an alert notification.

Delete an alert notification.

DELETE
/alert/notification/{name}
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Path Parameters

  • The name of the alert notification to be deleted.

Example Request

HttpResponse<String> response = Unirest.delete("https://metrics.ng.bluemix.net/v1/alert/notification/{name_string}")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notification/{name_string}",
  "method": "DELETE",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "DELETE",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notification/{name_string}",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("DELETE", "/v1/alert/notification/{name_string}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request DELETE \
  --url https://metrics.ng.bluemix.net/v1/alert/notification/{name_string} \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Show the details for an alert notification.

Show the details for an alert notification.

GET
/alert/notification/{name}
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Path Parameters

  • The name of the alert notification to be retrieved.

Example Request

HttpResponse<String> response = Unirest.get("https://metrics.ng.bluemix.net/v1/alert/notification/{name_string}")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notification/{name_string}",
  "method": "GET",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notification/{name_string}",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("GET", "/v1/alert/notification/{name_string}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request GET \
  --url https://metrics.ng.bluemix.net/v1/alert/notification/{name_string} \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • the description of the check (optional)

  • the details for the alert - this depends on type and could be email address, PagerDuty API key or the webhook url

  • user assigned name for this rule

  • the type of the alert notification

Status 200

{
  "description": "STRING",
  "detail": "STRING",
  "name": "STRING",
  "type": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Retrieve alert notifications.

Retrieve all of the alert notifications that are defined in a space.

This API will return an array of JSON objects that contain the alert notification definitions for the space that is specified through the headers.

GET
/alert/notifications
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Example Request

HttpResponse<String> response = Unirest.get("https://metrics.ng.bluemix.net/v1/alert/notifications")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/notifications",
  "method": "GET",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/notifications",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("GET", "/v1/alert/notifications", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request GET \
  --url https://metrics.ng.bluemix.net/v1/alert/notifications \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • the description of the check (optional)

  • the details for the alert - this depends on type and could be email address, PagerDuty API key or the webhook url

  • user assigned name for this rule

  • the type of the alert notification

Status 200

{
  "description": "STRING",
  "detail": "STRING",
  "name": "STRING",
  "type": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

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

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Request Body

  • Name of the rule

  • Summary of the rule.

  • Metric query that you want to monitor and send an alert if a threshold is crossed. Valid expressions are: a single metric name, multiple metrics identified with wildcards, or a function on top of one or more metrics. Tip: You can copy a query from Grafana.

  • Describes the status of the rule: Set to true to enable the rule. Set to false to disable the rule. By default, it is set to true.

  • Defines whether a notification is sent when there is not data. By default, the value is set to true.

  • Initial point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'from': '-5min'

  • End point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'until': 'now'

  • Comparison operation that is used to identify what type of check to make. Valid values are: below, and above.

  • Defines the scope of the data that is analyzed. Set to last to look at the last value in the series (the data that is available for your query).

  • Defines how often the check is performed. It is measured in minutes, hours or days, for example, 5min, 1h, 7d. For example, to check every min, you can set 'frequency': '1min'.

  • Defines the URL to a Grafana dashboard where the query that is monitored is defined.

  • One or more notifications, separated by commas, that define the action that you want to trigger for the rule.

Example Request

HttpResponse<String> response = Unirest.post("https://metrics.ng.bluemix.net/v1/alert/rule")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .body("{\"comparison\":\"above\",\"comparison_scope\":\"last\",\"dashboard_url\":\"dashboard local to the environment (i.e. https://metrics.staging.ng.bluemix.net for staging)\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"1min for staging, 5min for production\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/rule",
  "method": "POST",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  },
  "processData": false,
  "data": "{\"comparison\":\"above\",\"comparison_scope\":\"last\",\"dashboard_url\":\"dashboard local to the environment (i.e. https://metrics.staging.ng.bluemix.net for staging)\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"1min for staging, 5min for production\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "POST",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/rule",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ comparison: 'above',
  comparison_scope: 'last',
  dashboard_url: 'dashboard local to the environment (i.e. https://metrics.staging.ng.bluemix.net for staging)',
  description: 'string',
  enabled: true,
  expression: 'string',
  frequency: '1min for staging, 5min for production',
  from: 'string',
  name: 'string',
  notifications: [ null ],
  until: 'string' }));
req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

payload = "{\"comparison\":\"above\",\"comparison_scope\":\"last\",\"dashboard_url\":\"dashboard local to the environment (i.e. https://metrics.staging.ng.bluemix.net for staging)\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"1min for staging, 5min for production\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}"

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("POST", "/v1/alert/rule", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request POST \
  --url https://metrics.ng.bluemix.net/v1/alert/rule \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string' \
  --data '{"comparison":"above","comparison_scope":"last","dashboard_url":"dashboard local to the environment (i.e. https://metrics.staging.ng.bluemix.net for staging)","description":"string","enabled":true,"expression":"string","frequency":"1min for staging, 5min for production","from":"string","name":"string","notifications":[null],"until":"string"}'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 400

{
  "Code": "STRING",
  "message": "STRING"
}

Status 403

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Status 409

{
  "Code": "STRING",
  "message": "STRING"
}

Update an alert rule.

Update some or all of the fields of an alert rule.

PUT
/alert/rule
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Request Body

  • Name of the rule.

  • Summary of the rule.

  • Metric query that you want to monitor and send an alert if a threshold is crossed. Valid expressions are: a single metric name, multiple metrics identified with wildcards, or a function on top of one or more metrics. Tip: You can copy a query from Grafana.

  • Describes the status of the rule: Set to true to enable the rule. Set to false to disable the rule. By default, it is set to true.

  • Defines whether a notification is sent when there is not data. By default, the value is set to true.

  • Initial point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'from': '-5min'

  • End point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'until': 'now'

  • Comparison operation that is used to identify what type of check to make. Valid values are: below, and above.

  • Defines the scope of the data that is analyzed. Set to last to look at the last value in the series (the data that is available for your query).

  • Defines how often the check is performed. It is measured in minutes, hours or days, for example, 5min, 1h, 7d. For example, to check every 5 min, you can set 'frequency': '5min'.

  • Defines the URL to a Grafana dashboard where the query that is monitored is defined.

  • One or more notifications, separated by commas, that define the action that you want to trigger for the rule.

Example Request

HttpResponse<String> response = Unirest.put("https://metrics.ng.bluemix.net/v1/alert/rule")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .body("{\"comparison\":\"string\",\"comparison_scope\":\"string\",\"dashboard_url\":\"string\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"string\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/rule",
  "method": "PUT",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  },
  "processData": false,
  "data": "{\"comparison\":\"string\",\"comparison_scope\":\"string\",\"dashboard_url\":\"string\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"string\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "PUT",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/rule",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ comparison: 'string',
  comparison_scope: 'string',
  dashboard_url: 'string',
  description: 'string',
  enabled: true,
  expression: 'string',
  frequency: 'string',
  from: 'string',
  name: 'string',
  notifications: [ null ],
  until: 'string' }));
req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

payload = "{\"comparison\":\"string\",\"comparison_scope\":\"string\",\"dashboard_url\":\"string\",\"description\":\"string\",\"enabled\":true,\"expression\":\"string\",\"frequency\":\"string\",\"from\":\"string\",\"name\":\"string\",\"notifications\":[null],\"until\":\"string\"}"

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("PUT", "/v1/alert/rule", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request PUT \
  --url https://metrics.ng.bluemix.net/v1/alert/rule \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string' \
  --data '{"comparison":"string","comparison_scope":"string","dashboard_url":"string","description":"string","enabled":true,"expression":"string","frequency":"string","from":"string","name":"string","notifications":[null],"until":"string"}'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 400

{
  "Code": "STRING",
  "message": "STRING"
}

Status 403

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Delete an alert rule.

Delete an alert rule.

DELETE
/alert/rule/{name}
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Path Parameters

  • The name of the alert rule to be deleted.

Example Request

HttpResponse<String> response = Unirest.delete("https://metrics.ng.bluemix.net/v1/alert/rule/{name_string}")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/rule/{name_string}",
  "method": "DELETE",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "DELETE",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/rule/{name_string}",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("DELETE", "/v1/alert/rule/{name_string}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request DELETE \
  --url https://metrics.ng.bluemix.net/v1/alert/rule/{name_string} \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • Status code.

  • Description of the message associated with the code.

Status 200

{
  "Code": "STRING",
  "message": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Show the details for an alert rule.

Show the details for an alert rule.

GET
/alert/rule/{name}
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Path Parameters

  • The name of the alert rule for which you want to see the details.

Example Request

HttpResponse<String> response = Unirest.get("https://metrics.ng.bluemix.net/v1/alert/rule/{name_string}")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/rule/{name_string}",
  "method": "GET",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/rule/{name_string}",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("GET", "/v1/alert/rule/{name_string}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request GET \
  --url https://metrics.ng.bluemix.net/v1/alert/rule/{name_string} \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • Comparison operation that is used to identify what type of check to make. Valid values are: below, and above.

  • Defines the scope of the data that is analyzed. Set to last to look at the last value in the series (the data that is available for your query).

  • Defines the URL to a Grafana dashboard where the query that is monitored is defined.

  • Summary of the rule.

  • Describes the status of the rule: Set to true to enable the rule. Set to false to disable the rule.

  • Metric query that you want to monitor and send an alert if a threshold is crossed. Valid expressions are: a single metric name, multiple metrics identified with wildcards, or a function on top of one or more metrics. Tip: You can copy a query from Grafana.

  • Defines how often the check is performed.
    It is measured in minutes, hours or days, for example, 5min, 1h, 7d.
    For example, to check every min, you can set `'frequency': '1min'`.
  • Initial point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'from': '-5min'

  • Name of the rule.

  • List of notification that define the actions that you want to trigger for the rule.

  • End point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'until': 'now'

Status 200

{
  "comparison": "STRING",
  "comparison_scope": "STRING",
  "dashboard_url": "STRING",
  "description": "STRING",
  "enabled": "BOOLEAN",
  "expression": "STRING",
  "frequency": "STRING",
  "from": "STRING",
  "name": "STRING",
  "notifications": "ARRAY",
  "until": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}

Retrieve all of the rules that are defined in a space.

Retrieve all of the rules that are defined in a space.

This API returns an array of JSON objects. Each array entry contains the rule definitions for the space.

GET
/alert/rules
Request

Custom Headers

  • Set this field to the space GUID. The GUID must be prefixed with s- to identify a space.

  • UAA token, IAM token, or API key used for authentication. A token or API key must be prefixed with one of the following values: apikey, iam or uaa For example: X-Auth-User-Token: apikey SomeIAMGeneratedKey

Example Request

HttpResponse<String> response = Unirest.get("https://metrics.ng.bluemix.net/v1/alert/rules")
  .header("x-auth-scope-id", "string")
  .header("x-auth-user-token", "string")
  .asString();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://metrics.ng.bluemix.net/v1/alert/rules",
  "method": "GET",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "metrics.ng.bluemix.net",
  "port": null,
  "path": "/v1/alert/rules",
  "headers": {
    "x-auth-scope-id": "string",
    "x-auth-user-token": "string"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("metrics.ng.bluemix.net")

headers = {
    'x-auth-scope-id': "string",
    'x-auth-user-token': "string"
    }

conn.request("GET", "/v1/alert/rules", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
curl --request GET \
  --url https://metrics.ng.bluemix.net/v1/alert/rules \
  --header 'x-auth-scope-id: string' \
  --header 'x-auth-user-token: string'
Response

Response Body

  • Comparison operation that is used to identify what type of check to make. Valid values are: below, and above.

  • Defines the scope of the data that is analyzed. Set to last to look at the last value in the series (the data that is available for your query).

  • Defines the URL to a Grafana dashboard where the query that is monitored is defined.

  • Summary of the rule.

  • Describes the status of the rule: Set to true to enable the rule. Set to false to disable the rule.

  • Metric query that you want to monitor and send an alert if a threshold is crossed. Valid expressions are: a single metric name, multiple metrics identified with wildcards, or a function on top of one or more metrics. Tip: You can copy a query from Grafana.

  • Defines how often the check is performed. It is measured in minutes, hours or days, for example, 5min, 1h, 7d. For example, to check every min, you can set 'frequency': '1min'.

  • Initial point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'from': '-5min'

  • Name of the rule.

  • List of notifications that define the action that you want to trigger for the rule.

  • End point in time that is used to analyze the data based on the threshold values that you set for the query that you define in the expression field. For example: 'until': 'now'

Status 200

{
  "comparison": "STRING",
  "comparison_scope": "STRING",
  "dashboard_url": "STRING",
  "description": "STRING",
  "enabled": "BOOLEAN",
  "expression": "STRING",
  "frequency": "STRING",
  "from": "STRING",
  "name": "STRING",
  "notifications": "ARRAY",
  "until": "STRING"
}

Status 404

{
  "Code": "STRING",
  "message": "STRING"
}