首页 / API 文档 / 运维中心 / 告警模板 / 创建告警模板

创建告警模板

请求信息

请求行

POST /apis/aiops.alauda.io/v1beta1/alerttemplates

创建一个告警模板。

请求参数

名称 类型 是否必填项 描述
dryRun string 当该参数出现时,表示不应该持久化修改。一个无效的或无法识别的 dryRun 指令将导致错误响应,并且不会进一步处理请求。有效值为:All,将处理所有的试运行阶段。
fieldManager string fieldManager 是与正在进行这些更改的参与者或实体相关联的名称。值必须少于 128 字符,且仅包含可打印字符,参见 https://golang.org/pkg/unicode/#IsPrint
pretty string 如果为 true,则会将返回结果输出成适合打印的格式。

请求体

Content-Type application/json, application/yaml

请求体示例

AlertTemplate 是 AlertTemplate API 的结构。

{
   "apiVersion": "aiops.alauda.io/v1beta1",
   "kind": "AlertTemplate",
   "metadata": {
     "name": "ad",
     "namespace": "default"
   },
   "spec": {
     "templates": [
       {
         "compare": "\u003e",
         "metric": {
           "queries": [
             {
               "aggregator": "min",
               "labels": [
                 {
                   "name": "severity",
                   "value": "High"
                 }
               ],
               "range": 1
             }
           ]
         },
         "name": "cluster.cpu.utilization-q9ld6",
         "notifications": [
           {
             "name": "xyz",
             "namespace": "ehg",
             "uuid": "35c6d8ef-7f6a-4721-899c-818fdbd0a1b1"
           }
         ],
         "threshold": 1,
         "unit": "",
         "wait": 1
       }
     ]
   }
 }

请求体说明

名称 类型 是否必填项 描述
apiVersion string 查看公共参数
kind string 查看公共参数
metadata object 查看公共参数
spec object spec 包含了模板资源的规范参数。
字段路径:spec
spec.templates array 告警模板的列表。
字段路径:spec.templates
spec.templates[] object 模板项。
字段路径:spec.templates[]
templates[].compare string 模板对比信息。
字段路径:spec.templates[].compare
templates[].metric object 告警的指标信息。
字段路径:spec.templates[].metric
metric.queries array 指标的查询条件。
字段路径:spec.templates[].metric.queries
metric.queries[] object 查询项。
字段路径:spec.templates[].metric.queries[]
queries[].aggregator string 聚合方式。⽀持以下几种⽅方式:avg:平均值;max:最⼤值;min:最小值。
字段路径:spec.templates[].metric.queries[].aggregator
queries[].labels array 告警对象的标签。由键、值组成的监控数据查询条件。
字段路径:spec.templates[].metric.queries[].labels
queries[].labels[] object 查询到的标签项。
字段路径:spec.templates[].metric.queries[].labels[]
labels[].name string 组合查询条件中包含的键。
字段路径:spec.templates[].metric.queries[].labels[].name
labels[].value string 组合查询条件中键对应的值,为资源对象的实际属性值。
字段路径:spec.templates[].metric.queries[].labels[].value
queries[].range integer 聚合时间,单位:秒。与聚合算法配合使用,默认为 60s,即使用查询时间前 60 秒内数据进行聚合。
字段路径:spec.templates[].metric.queries[].range
templates[].name string 告警范围。
字段路径:spec.templates[].name
templates[].notifications array 被该告警触发的通知的信息。
字段路径:spec.templates[].notifications
templates[].notifications[] object 通知策略记录。
字段路径:spec.templates[].notifications[]
notifications[].name string 通知的名称。
字段路径:spec.templates[].notifications[].name
notifications[].namespace string 通知所在的命名空间。
字段路径:spec.templates[].notifications[].namespace
notifications[].uuid string 通知的 id。
字段路径:spec.templates[].notifications[].uuid
templates[].threshold number 告警阈值。
字段路径:spec.templates[].threshold
templates[].unit string 告警阈值的单位。
字段路径:spec.templates[].unit
templates[].wait integer 持续时间,单位:秒。
字段路径:spec.templates[].wait

返回信息

Content-Type application/json, application/yaml

状态码: 201

Created

返回体示例

AlertTemplate 是 AlertTemplate API 的结构。

{
   "apiVersion": "aiops.alauda.io/v1beta1",
   "kind": "AlertTemplate",
   "metadata": {
     "name": "ad",
     "namespace": "default"
   },
   "spec": {
     "templates": [
       {
         "compare": "\u003e",
         "metric": {
           "queries": [
             {
               "aggregator": "min",
               "labels": [
                 {
                   "name": "severity",
                   "value": "High"
                 }
               ],
               "range": 1
             }
           ]
         },
         "name": "cluster.cpu.utilization-q9ld6",
         "notifications": [
           {
             "name": "xyz",
             "namespace": "ehg",
             "uuid": "35c6d8ef-7f6a-4721-899c-818fdbd0a1b1"
           }
         ],
         "threshold": 1,
         "unit": "",
         "wait": 1
       }
     ]
   }
 }

返回体说明

名称 类型 描述
apiVersion string 查看公共参数
kind string 查看公共参数
metadata object 查看公共参数
spec object spec 包含了模板资源的规范参数。
字段路径:spec
spec.templates array 告警模板的列表。
字段路径:spec.templates
spec.templates[] object 模板项。
字段路径:spec.templates[]
templates[].compare string 模板对比信息。
字段路径:spec.templates[].compare
templates[].metric object 告警的指标信息。
字段路径:spec.templates[].metric
metric.queries array 指标的查询条件。
字段路径:spec.templates[].metric.queries
metric.queries[] object 查询项。
字段路径:spec.templates[].metric.queries[]
queries[].aggregator string 聚合方式。⽀持以下几种⽅方式:avg:平均值;max:最⼤值;min:最小值。
字段路径:spec.templates[].metric.queries[].aggregator
queries[].labels array 告警对象的标签。由键、值组成的监控数据查询条件。
字段路径:spec.templates[].metric.queries[].labels
queries[].labels[] object 查询到的标签项。
字段路径:spec.templates[].metric.queries[].labels[]
labels[].name string 组合查询条件中包含的键。
字段路径:spec.templates[].metric.queries[].labels[].name
labels[].value string 组合查询条件中键对应的值,为资源对象的实际属性值。
字段路径:spec.templates[].metric.queries[].labels[].value
queries[].range integer 聚合时间,单位:秒。与聚合算法配合使用,默认为 60s,即使用查询时间前 60 秒内数据进行聚合。
字段路径:spec.templates[].metric.queries[].range
templates[].name string 告警范围。
字段路径:spec.templates[].name
templates[].notifications array 被该告警触发的通知的信息。
字段路径:spec.templates[].notifications
templates[].notifications[] object 通知策略记录。
字段路径:spec.templates[].notifications[]
notifications[].name string 通知的名称。
字段路径:spec.templates[].notifications[].name
notifications[].namespace string 通知所在的命名空间。
字段路径:spec.templates[].notifications[].namespace
notifications[].uuid string 通知的 id。
字段路径:spec.templates[].notifications[].uuid
templates[].threshold number 告警阈值。
字段路径:spec.templates[].threshold
templates[].unit string 告警阈值的单位。
字段路径:spec.templates[].unit
templates[].wait integer 持续时间,单位:秒。
字段路径:spec.templates[].wait

其他状态码

状态码: 200

OK

状态码: 202

Accepted

状态码: 401

Unauthorized