Skip to content

Create



POST /api/v1/monitor/mute/create

Overview

Create a Mute rule

Body Request Parameters

Parameter Name Type Required Description
muteRanges array Mute ranges
Allow empty: False
name string Rule name
Example: Name A
Allow empty: False
description string Description
Example: Description A
Allow empty: False
Allow empty string: True
tags json Tag set
Allow empty: False
filterString string Event attributes
Allow empty: False
Allow empty string: True
Max length: 2048
notifyTargets array Notification targets
Allow empty: False
notifyMessage string Notification message
Allow empty: False
Max length: 3000
notifyTimeStr string Notification time, %Y/%m/%d %H:%M:%S
Example: 2023/08/21 19:19:00
Allow empty: False
Allow empty string: True
startTime string Start time %Y/%m/%d %H:%M:%S
Example: 2023/08/21 19:19:00
Allow empty: False
endTime string End time %Y/%m/%d %H:%M:%S
Example: 2023/08/21 19:19:00
Allow empty: False
Allow empty string: True
repeatTimeSet int Y Pass 1 for repeat configuration value, pass 0 for single Mute time
Example: 0
Allow empty: False
repeatCrontabSet None Repeat crontab configuration
Allow empty: False
repeatCrontabSet.min string Minute
Example: 10
Allow empty: False
repeatCrontabSet.hour string Hour
Example: 10
Allow empty: False
repeatCrontabSet.day string Day
Example: *
Allow empty: False
repeatCrontabSet.month string Month
Example: *
Allow empty: False
repeatCrontabSet.week string Week
Example: 1,3
Allow empty: False
crontabDuration int End time minus start time, positive integer, unit is s
Example: 3600
Allow empty: False
repeatExpireTime string Repeat end time %Y/%m/%d %H:%M:%S
Example: 0
Allow empty: False
Allow empty string: True
timezone str Y Mute rule timezone
Example: Asia/Shanghai
Allow empty: False
type str Y Mute rule type
Example: custom
Allow empty: False
Optional values: ['checker', 'alertPolicy', 'tag', 'custom']
declaration json Custom declaration information
Allow empty: False

Parameter Supplementary Description

Data description.*

1.Request Parameter Description

Parameter Name type Description
type string Corresponds to Mute rule type Checker:checker, Alert policy:monitor, Checker tag:tag, Custom:custom
muteRanges list Mute ranges, includes Checker, Intelligent Inspection, Self-built Inspection, SLO, Alert policy
name str Rule name
description str Description
tags dict Advanced configuration, Event attributes
filterString str Event attributes (input in expression form)
notifyTargets list to: list is notification targets, type is its notification type
repeatTimeSet int Whether to repeat Mute, 1 means enable repeat Mute, 0 means only once
repeatCrontabSet dict Time configuration for repeat Mute rule
crontabDuration int Represents the duration of Mute after the scheduled task starts, unit is s
notifyTargets list to: list is notification targets, type is its notification type |
notifyTimeStr str Notification time,%Y/%m/%d %H:%M:%S
startTime str Mute start time %Y/%m/%d %H:%M:%S
endTime str Mute end time %Y/%m/%d %H:%M:%S
repeatExpireTime str 0 means repeat forever, repeat Mute expiration time %Y/%m/%d %H:%M:%S
timezone str Corresponding task timezone default Asia/Shanghai
repeatExpire int Repeat Mute expiration time (deprecated on 2023-08-24)
start int Mute start time (deprecated on 2023-08-24)
end int Mute end time (deprecated on 2023-08-24) |
notifyTime int Notification time, second-level timestamp corresponding to the time point, -1 means notify immediately (deprecated on 2023-08-24)
declaration dict Custom declaration information
--------------

2.Mute Range Description

Parameter Name type Required Description
type string Y Corresponds to Mute rule type Checker:checker, Alert policy:monitor, Checker tag:tag, Custom:custom
muteRanges list Y Mute ranges, [] represents select all
tags dict Y Advanced configuration, Event attributes
filterString str Event attributes (input in expression form)

tags configuration supports negative selection configuration, example:

{
    "tags": {
        "-host": [
            "cn-hangzhou"
        ]
    },
    "muteRanges": [],
    "type": "checker"
}

type is checker, Checker type, example:

{
    "tags": {
        "host": [
            "cn-hangzhou"
        ]
    },
    "muteRanges": [
        {
            "name": "Infrastructure liveness detection - type is ReplicaSet- {{Result}}",
            "checkerUUID": "rul_xxxx22",
        },
        {
            "name": "hhh",
            "checkerUUID": "rul_xxxx21",
        }
    ],
    "type": "checker"
}

type is alertPolicy, Alert policy type, example:

{
    "tags": {
        "host": [
            "cn-hangzhou"
        ]
    },
    "muteRanges": [
        {
            "name": "gary-test1234",
            "alertPolicyUUID": "altpl_xxxx26",
        }
    ],
    "type": "alertPolicy",
}

type is tag, Checker tag, example:

{
    "tags": {
        "service": [
            "kodo.nsq.consumer"
        ]
    },
    "muteRanges": [
        {
            "name": "zyl_test",
            "tagUUID": "tag_xxxx23",
        },
        {
            "name": "0306",
            "tagUUID": "tag_xxxx28",
        }
    ],
    "type": "tag"
}

type is custom, Custom type, example:

{
    "tags": {
        "service": [
            "kodo.nsq.consumer"
        ]
    },
    "muteRanges": [
        {
            "name": "Checker optimization verification - update2",
            "checkerUUID": "rul_xxxx22",
        },
        {
            "name": "0306",
            "tagUUID": "tag_xxxx25",
        },
        {
            "name": "slo_test",
            "sloUUID": "monitor_xxxx25",
        }
    ],
    "type": "custom",
}

filterString is the new version event attributes, syntax follows Explorer syntax, currently the interface also supports tags as the old version event attributes, priority is given to the value of filterString, for example:

{
    "filterString": "df_status:ok OR host:web001",
    "muteRanges": [],
    "type": "checker"
}


3.Mute Time Description

Mute time is divided into, single Mute, repeat Mute


Single Mute parameter configuration:

Parameter Name type Description
repeatTimeSet int Whether to repeat Mute, 1 means enable repeat Mute, 0 means only once
startTime str Mute start time %Y/%m/%d %H:%M:%S
endTime str Mute end time %Y/%m/%d %H:%M:%S
timezone str Corresponding task timezone default Asia/Shanghai

repeatTimeSet is 0, single Mute, example:

{
    "startTime": "2024/03/27 14:06:57",
    "endTime": "2024/03/27 15:06:57",
    "timezone": "Asia/Shanghai",
    "repeatTimeSet": 0
}


Repeat Mute parameter configuration:

Parameter Name type Description
repeatTimeSet int Whether to repeat Mute, 1 means enable repeat Mute, 0 means only once
repeatCrontabSet dict Repeat Mute rule time configuration , used to group start Crontab (Crontab syntax)
crontabDuration int Represents the duration of Mute after the scheduled task starts, unit is s
repeatExpireTime str 0 means repeat forever, repeat Mute expiration time %Y/%m/%d %H:%M:%S
timezone str Corresponding task timezone default Asia/Shanghai

repeatTimeSet is 1, repeat Mute, example:

{
    "timezone": "Asia/Shanghai",
    "repeatTimeSet": 1,
    "repeatCrontabSet": {
        "min": "0",
        "hour": "0",
        "day": "*",
        "month": "*",
        "week": "1,2"
    },
    "crontabDuration": 18000,
    "repeatExpireTime": "0"
}


Request Example

curl 'https://openapi.truewatch.com/api/v1/monitor/mute/create' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  --data-raw '{"name":"nameA","description":"descA","startTime":"2023/08/23 14:00:07","endTime":"2023/08/23 14:31:07","notifyTargets":[{"to":["acnt_xxxx32"],"type":"mail"}],"tags":{},"muteRanges":[{"name":"The Memory usage rate of the Aerospike cluster [{{cluster_name}}] space [{{ns}}] is too high","checkerUUID":"rul_xxxx32","type":"checker"}],"type":"checker","timezone":"Asia/Shanghai","notifyMessage":"cjkackcnkjcklasc","notifyTimeStr":"2023/08/23 13:45:07","repeatTimeSet":0}' \
  --compressed \
  --insecure

Response

{
    "code": 200,
    "content": {
        "createAt": 1692771116,
        "creator": "acnt_xxxx32",
        "crontab": "",
        "crontabDuration": 0,
        "deleteAt": -1,
        "description": "descA",
        "end": 1692772267,
        "endTime": "2023/08/23 14:31:07",
        "id": 643,
        "muteRanges": [
            {
                "checkerUUID": "rul_xxxx32",
                "name": "The Memory usage rate of the Aerospike cluster [{{cluster_name}}] space [{{ns}}] is too high",
                "type": "checker"
            }
        ],
        "name": "nameA",
        "notifyMessage": "cjkackcnkjcklasc",
        "notifyTargets": [
            {
                "to": [
                    "acnt_xxxx32"
                ],
                "type": "mail"
            }
        ],
        "notifyTime": 1692769507,
        "notifyTimeStr": "2023/08/23 13:45:07",
        "repeatExpire": -1,
        "repeatExpireTime": "-1",
        "start": 1692770407,
        "startTime": "2023/08/23 14:00:07",
        "status": 0,
        "tags": {},
        "timezone": "Asia/Shanghai",
        "type": "checker",
        "updateAt": 1692771117,
        "updator": "acnt_xxxx32",
        "uuid": "mute_xxxx32",
        "workspaceUUID": "wksp_xxxx32"
    },
    "errorCode": "",
    "message": "",
    "success": true,
    "traceId": "TRACE-C5BE0235-BB41-437E-801E-F925E98F8616"
}