Create Alarm

Overview

  • Create an alarm.
  • This API performs the same function as "OpenStack Telemetry API: POST /v2/alarms".

Classification

  • Create

API Operation Object

  • Alarm

Synchronous / Asynchronous

  • Synchronous

Request

HTTP Request Method

  • POST

HTTP Request Path

{api_endpoint}/v2/alarms

HTTP Request Header

Content-Type: application/json
Accept: application/json
X-Auth-Token: <token_id>

HTTP Request Body

Format

{
    "name": "<alarm_name>",
    "description": "<alarm_description>",
    "enabled": <enabled>,
    "repeat_actions": <repeat_actions>,
    "severity": "<severity>",
    "alarm_actions": ["<alarm_actions>",<<repeat>>],
    "ok_actions": ["<ok_actions>",<<repeat>>],
    "type": "threshold",
    "threshold_rule": {
        "meter_name": "<meter_name>",
        "period": <period>,
        "query": [{
            "field": "resource_id",
            "op": "eq",
            "type": "string",
            "value": "<resource_id>"
        }],
        "evaluation_periods": <evaluation_periods>,
        "evaluation_type": "<evaluation_type>",
        "comparison_operator": "<comparison_operator>",
        "statistic": "<statistics>",
        "threshold": <threshold>
    }
}

Request Parameter

name style format description required/optional default value action for invalid parameter response code for invalid parameter
(data) Body Alarm an alarm within the request body required - Terminate 400, 401, 404, 409
token_id Header authentication token string authentication token required - Terminate 401

Response

Response Header

Format

HTTP/1.1 <response_code> <status>       (ex. 200 OK)
  • <response_code>: see "Response Code" section
  • <status>: message based on the response code

注釈

skip auto-insert fields such as "Content-Length" and "Date"

Response Code

response code status condition message
200 ok normal end  
400 bad request invalid value Invalid value for parameter.
    invalid value Resource not found.
401 unauthorized authentication failure The request you have made requires authentication.
404 not found invalid meter name Meter not found.
409 conflict the same alarm name Alarm already exists.
500 internal server error internal server error The request processing has failed due to some unknown error, exception or failure.

Response Body

Format

{
    "alarm_id": "<alarm_id>",
    "project_id": "<tenant_id>",
    "user_id": "<user_id>",
    "name": "<alarm_name>",
    "description": "<alarm_description>",
    "enabled": <enabled>,
    "state": "<state>",
    "repeat_actions": <repeat_actions>,
    "severity": "<severity>",
    "time_constraints": [],
    "alarm_actions": ["<alarm_actions>",<<repeat>>],
    "ok_actions": ["<ok_actions>",<<repeat>>],
    "insufficient_data_actions": [],
    "type": "threshold",
    "threshold_rule": {
        "meter_name": "<meter_name>",
        "period": <period>,
        "query": [{
            "field": "resource_id",
            "op": "eq",
            "type": "string",
            "value": "<resource_id>"
        }],
        "exclude_outliers": false,
        "evaluation_periods": <evaluation_periods>,
        "evaluation_type": "<evaluation_type>",
        "comparison_operator": "<comparison_operator>",
        "statistic": "<statistics>",
        "threshold": <threshold>
    },
    "timestamp": "<timestamp>",
    "state_timestamp": "<state_timestamp>",
    "resource_name": "<resource_name>",
    "deleted": <deleted>
}

Response Parameter

item format description
(data) Alarm an alarm created by the request

Sample Request and Response

Sample API Request

Request URL

POST /v2/alarms

Request Header

Content-Type: application/json
Accept: application/json
X-Auth-Token: e8c788fbaeb14964ae19759eb1df4ff1

Request Body

{
    "name": "alarm-test",
    "description": "alarm-test-description",
    "enabled": true,
    "repeat_actions": false,
    "severity": "moderate",
    "alarm_actions": ["http://example.com"],
    "ok_actions": ["http://example.com"],
    "type": "threshold",
    "threshold_rule": {
        "meter_name": "nova.hv.status.bool",
        "period": 300,
        "query": [{
            "field": "resource_id",
            "op": "eq",
            "type": "string",
            "value": "nova_5dd5bfe5-aee8-4663-86e4-e76d032d318e"
        }],
        "evaluation_periods": 1,
        "evaluation_type": "0",
        "comparison_operator": "gt",
        "statistic": "max",
        "threshold": 1
    }
}

Sample API Response

Response Header

HTTP/1.1 200 OK

Response Body

{
    "alarm_id": "638c3bfe-9435-45f5-9fbb-9d6d380c17ba",
    "project_id": "26574d10673044dbb03ffc8facc7ab7a",
    "user_id": "a9de93f5a7604707a2870d8b95f74eda",
    "name": "alarm-test",
    "description": "alarm-test-description",
    "enabled": true,
    "state": "ok",
    "repeat_actions": false,
    "severity": "moderate",
    "time_constraints": [],
    "alarm_actions": ["http://example.com"],
    "ok_actions": ["http://example.com"],
    "insufficient_data_actions": [],
    "type": "threshold",
    "threshold_rule": {
        "meter_name": "nova.hv.status.bool",
        "period": 300,
        "query": [{
            "field": "resource_id",
            "op": "eq",
            "type": "string",
            "value": "nova_5dd5bfe5-aee8-4663-86e4-e76d032d318e"
        }],
        "exclude_outliers": false,
        "evaluation_periods": 1,
        "evaluation_type": "0",
        "comparison_operator": "gt",
        "statistic": "max",
        "threshold": 1
    },
    "timestamp": "2015-11-23T04:35:08+00:00",
    "state_timestamp": "2015-11-20T07:05:10+00:00",
    "resource_name": "test-vm",
    "deleted": false
}

Sample Error Response

POST /v2/alarms
User-Agent: curl/7.19.7
Content-Type: application/json
Accept: application/json
X-Auth-Token: 61389973e52b49c394ba3b89179b290b

HTTP Response

HTTP/1.1 400 Bad Request
Date: Wed, 02 Dec 2015 10:41:34 GMT
Server: Apache
Cache-Control: no-cache
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Status: 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{"error":{"code":400,"message":"Invalid value for parameter.","title":"Bad Request"}}