Help Center > > API Reference> APIs> Monitoring> Adding Threshold Rules

Adding Threshold Rules

Updated at: Feb 22, 2019 17:34

Function

This API is used to add a threshold rule.

URI

POST /v1/{project_id}/ams/alarms

Request Message

Request Parameter

Table 1 lists the request parameters.

Table 1 Request parameters

Parameter

Mandatory

Type

Value Range

Description

project_id

Yes

string

-

Project ID that a tenant applies for from IAM. In normal cases, it is a string consisting of 32 characters.

statistic

Yes

string

"maximum", "minimum", "average", "sum", "sampleCount"

Measurement method.

namespace

Yes

string

-

Namespace.

metricName

Yes

string

1–255 characters

Metric name.

period

Yes

int

-

Statistical cycle.

alarmLevel

Yes

int

-

Alarm severity

evaluationPeriods

Yes

int

-

Consecutive periods.

comparisonOperator

Yes

string

-

Threshold condition expression.

threshold

Yes

string

-

Threshold.

alarmName

Yes

string

-

Threshold name.

dimensions

Yes

string

-

Metric dimension.

unit

Yes

string

-

Metric unit.

actionEnabled

No

boolean

-

Whether an alarm is enabled.

alarmActions

No

array

-

Alarm action.

alarmAdvice

No

string

-

Alarm clearing suggestion.

alarmDescription

No

string

-

Threshold rule description.

insufficientDataActions

No

array

-

Action when data is insufficient.

okActions

No

array

-

Recovery action.

Header Description

Table 2 lists request headers.

Table 2 Header description

Header

Mandatory

Description

X-Auth-Token

Yes

User token obtained from the IAM service.

Content-Type

Yes

Specifies the content type. Its value is application/json.

Example Request

{ 
    "actionEnabled": false, 
    "alarmActions": [], 
    "alarmAdvice": "", 
    "alarmDescription": "", 
    "alarmLevel": 3, 
    "alarmName": "aaaaaaaa", 
    "comparisonOperator": ">=", 
    "dimensions": [ 
        { 
            "name": "appName", 
            "value": "rhm-broker" 
        } 
    ], 
    "evaluationPeriods": 1, 
    "insufficientDataActions": [], 
    "metricName": "cpuCoreLimit", 
    "namespace": "PAAS.CONTAINER", 
    "okActions": [], 
    "period": 60000, 
    "statistic": "average", 
    "threshold": 0, 
    "unit": "Core" 
}

Response Message

Response Parameter

Table 3 lists response parameters.

Table 3 Response parameters

Parameter

Type

Description

errorCode

string

Response code.

errorMessage

string

Response message description.

alarmId

long

Threshold rule code.

Example Response

{ 
    "errorCode": "SVCSTG.AMS.2000", 
    "errorMessage": "success", 
    "alarmId": 12345678 
}

Status Code

  • Normal

    Table 4 lists the status code.

Table 4 Status code

Status Code

Description

200

Alarm query success.

  • Abnormal

    Table 5 lists status codes. For details about more status codes, see Status Code.

Table 5 Status code

Status Code

Description

400 Bad Request

The server failed to process the request.

401 Unauthorized

You must enter a username and password to access the requested page.

403 Forbidden

You are forbidden to access the requested page.

500 Internal Server Error

Failed to complete the request because of an internal service error.

503 Service Unavailable

Failed to complete the request because the service is unavailable.

Error Codes

Table 6 Error codes

Error Code

Error Message

Solution

SVCSTG_AMS_4000101

Alarm name is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000102

Alarm has been existed

The threshold name already exists. Change the name and create another one.

SVCSTG_AMS_4000103

Alarm description is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000104

Alarm threshold is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000105

Alarm period is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000106

Alarm mailSend list is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000107

Alarm reached the maximum number

The number of thresholds has reached the maximum. If capacity expansion is required, contact the administrator.

SVCSTG_AMS_4000108

Alarm query time range is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000109

Request projectId is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000115

Request param is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000118

Alarm repeat time is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000119

Alarm statistic is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000120

Alarm comparison operator is invalid

Check whether the parameters meet the requirements.

SVCSTG_AMS_4000121

Alarm is not exist

Check whether the threshold rule exists on the GUI.

SVCSTG_AMS_5000000

Internal server error

Contact the administrator.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel