Help Center> Cloud Eye> API Reference> API V1> Alarm Rules> Querying Custom Alarm Templates
Updated on 2023-08-15 GMT+08:00

Querying Custom Alarm Templates

Function

This API is used to query the custom alarm templates.

Debugging

You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.

URI

GET /V1.0/{project_id}/alarm-template

  • Parameter description
    Table 1 Parameter description

    Parameter

    Type

    Mandatory

    Description

    project_id

    String

    Yes

    Specifies the project ID.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    alarmTemplateId

    String

    No

    Specifies the ID of the custom alarm template, for example, at1603330892378wkDm77y6B.

    namespace

    String

    No

    Specifies the resource namespace. For example, the ECS resource namespace is SYS.ECS. To view the namespace of each service, see Services Interconnected with Cloud Eye.

    dname

    String

    No

    Specifies the resource dimension selected for the custom alarm template. For example, the ECS dimension is instance_id. For details about the dimensions of each service, see Services Interconnected with Cloud Eye.

    start

    String

    No

    Specifies the start value of pagination. The value is an integer. The default value is 0.

    limit

    String

    No

    Specifies the maximum number of the custom alarm template that can be queried at a time. The value range is (0,100] and the default value is 100.

  • Example
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/alarms/alarm-template

Request

None

Response

  • Response parameters

    Parameter

    Type

    Mandatory

    Description

    alarm_templates

    Array of objects

    No

    Provides supplementary information about the custom alarm template.

    For details, see Table 2.

    meta_data

    MetaData object

    No

    Specifies the metadata of query results, including the pagination information.

    For details, see Table 5.

    Table 2 alarm_templates data structure description

    Parameter

    Type

    Mandatory

    Description

    template_name

    String

    No

    Specifies the custom alarm template name, for example, alarmTemplate-Test01.

    template_description

    String

    No

    Provides supplementary information about the custom alarm template.

    namespace

    String

    No

    Specifies the resource namespace. For example, the ECS namespace is SYS.ECS. To view the namespace of each service, see Services Interconnected with Cloud Eye.

    dimension_name

    String

    No

    Specifies the resource dimension selected for the custom alarm template. For example, the ECS dimension is instance_id. For details about the dimensions of each service, see Services Interconnected with Cloud Eye.

    template_items

    Array of objects

    No

    Specifies the alarm policy or alarm policies added to the custom alarm template.

    For details, see Table 3.

    template_id

    String

    No

    Specifies the ID of the custom alarm template, for example, at1603330892378wkDm77y6B.

    Table 3 template_items data structure description

    Parameter

    Type

    Mandatory

    Description

    metric_name

    String

    Yes

    Specifies the metric you add to the custom alarm template. For example, you can add ECS cpu_util. To view metrics of each resource, see Services Interconnected with Cloud Eye.

    condition

    Condition object

    Yes

    Specifies the alarm policy you created for the custom alarm template.

    For details, see Table 4.

    alarm_level

    Integer

    No

    Specifies the alarm severity, which can be 1 (critical), 2 (major), 3 (minor), or 4 (informational).

    Table 4 condition data structure description

    Parameter

    Type

    Mandatory

    Description

    period

    Integer

    Yes

    Specifies how often Cloud Eye aggregates data.

    Possible values:

    • 1: Cloud Eye performs no aggregation and displays raw data.
    • 300: Cloud Eye aggregates data every 5 minutes.
    • 1200: Cloud Eye aggregates data every 20 minutes.
    • 3600: Cloud Eye aggregates data every 1 hour.
    • 14400: Cloud Eye aggregates data every 4 hours.
    • 86400: Cloud Eye aggregates data every 24 hours.

    filter

    String

    Yes

    Specifies the data rollup method. The following methods are supported:

    • average: Cloud Eye calculates the average value of metric data within a rollup period.
    • max: Cloud Eye calculates the maximum value of metric data within a rollup period.
    • min: Cloud Eye calculates the minimum value of metric data within a rollup period.
    • sum: Cloud Eye calculates the sum of metric data within a rollup period.
    • variance: Cloud Eye calculates the variance value of metric data within a rollup period.

    comparison_operator

    String

    Yes

    Specifies the alarm threshold operator, which can be >, =, <, , or .

    value

    Double

    Yes

    Specifies the alarm threshold. Supported range: 0 to Number. MAX_VALUE (1.7976931348623157e+108) For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80.

    unit

    String

    No

    Specifies the data unit, which can contain up to 32 characters.

    count

    Integer

    Yes

    Specifies the number of consecutive occurrence times that the alarm policy was met. Supported range: 1 to 5

    suppress_duration

    Integer

    No

    Specifies the interval for triggering an alarm if the alarm persists.

    Possible intervals are as follows:

    0: Cloud Eye triggers the alarm only once.

    300: Cloud Eye triggers the alarm every 5 minutes.

    600: Cloud Eye triggers the alarm every 10 minutes.

    900: Cloud Eye triggers the alarm every 15 minutes.

    1800: Cloud Eye triggers the alarm every 30 minutes.

    3600: Cloud Eye triggers the alarm every 1 hour.

    10800: Cloud Eye triggers the alarm every 3 hours.

    21600: Cloud Eye triggers the alarm every 6 hours.

    43200: Cloud Eye triggers the alarm every 12 hours.

    86400: Cloud Eye triggers the alarm every day.

    Table 5 meta_data data structure description

    Parameter

    Type

    Mandatory

    Description

    total

    Integer

    Yes

    Specifies the total number of query results.

    count

    Integer

    Yes

    Specifies the number of returned results.

    marker

    String

    Yes

    Specifies the pagination marker.

    • Response example
      {
       "alarm_templates": [
         {
           "template_name": "alarmTemplate-Test01",
           "template_description": "Querying custom templates",
           "namespace": "SYS.ECS",
           "dimension_name": "instance_id",
           "template_items": [
             {
               "metric_name": "cpu_util",
               "condition": {
                 "period": 1,
                 "filter": "average",
                 "comparison_operator": ">=",
                 "value": 90,
                 "unit": "%",
                 "count": 3,
                 "suppress_duration": 300
               },
               "alarm_level": 2
             },
             {
               "metric_name": "mem_util",
               "condition": {
                 "period": 1,
                 "filter": "average",
                 "comparison_operator": ">=",
                 "value": 90,
                 "unit": "%",
                 "count": 3,
                 "suppress_duration": 600
               },
               "alarm_level": 2
             }
           ],
           "template_id": "at1604474818207Jo7o7R4Nj"
         }
       ],
       "meta_data": {
         "count": 1,
         "marker": "",
         "total": 1
       }
      }

Returned Value

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    Access to the requested page is forbidden.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

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

    503 Service Unavailable

    The service is currently unavailable.

Error Codes

See Error Codes.