Skip to content

Create



POST /api/v1/slo/add

Overview

Body Request Parameters

Parameter Type Required Description
status integer Status: 0 enabled (default), 2 disabled
Allow empty: False
Allowed values: [0, 2]
sliType string SLI type: monitor (default) or metric; cannot be modified after creation
Allow empty: False
Allowed values: ['monitor', 'metric']
checkRange integer Statistics period in seconds, only 7 or 30 days; default 604800
Allow empty: False
Allowed values: [604800, 2592000]
metricQueries object Required for metric type. total/good each contain dql, queryType (dql/promql), promqlType (PromQL accepts instantQuery/rangeQuery, but is always unified to instantQuery), and editor (echo object). Editable; queries and permissions are re-validated on save.
Allow empty: False
name string Y SLO name
Allow empty: False
Max length: 256
interval string Y Check frequency
Allow empty: False
Allowed values: ['5m', '10m']
Example: 5m
goal float Y SLO expected target. Value range: 0-100, excluding 0 and 100
Allow empty: False
Allowed values greater than: 0
Allowed values less than: 100
Example: 90.0
minGoal float Y SLO minimum target. Value range: 0-100, excluding 0 and 100, and less than goal
Allow empty: False
Allowed values greater than: 0
Allowed values less than: 100
Example: 85.0
sliUUIDs array List of SLI UUIDs
Allow empty: False
Example: ['rul-aaaaaa', 'rul-bbbbbb']
describe string SLO group description
Example: This is an example
Allow empty: False
Allow empty string: True
Max length: 3000
alertPolicyUUIDs array Alert Policy UUIDs
Allow empty: False
tags array Tag names for filtering
Allow empty: False
Example: ['xx', 'yy']
groupBy array SLO calculation dimensions; only project, env, and service are supported; the DQL by dimension remains consistent with this field; default []
Allow empty: False
Example: ['project', 'env']
ignoreBadGroupEvents boolean Whether to ignore abnormal group events when SLO is configured with groupBy; default true; no effect when groupBy is not configured
Allow empty: False
Example: True

Additional Parameter Notes

  • sliUUIDs, list of SLI UUIDs. Reference: Monitoring - Monitors - Get Monitor List (you can specify the search parameter to search by monitor name and omit other parameters), then take the monitor uuid field.
  • alertOpt[#].alertTarget, alert notification target. Reference: Monitoring - Notification Targets - Get Notification Targets List.

Request Example

curl 'https://openapi.guance.com/api/v1/slo/add' \
-H 'Content-Type: application/json' \
-H 'DF-API-KEY:  <DF-API-KEY>' \
--data '{"name":"LWC-Test-2024-08-06-002","interval":"10m","goal":90,"minGoal":60,"sliUUIDs":["rul_xxxxx","rul_9eb745xx"],"describe":"LWCTestOpenAPI","tags":[],"alertPolicyUUIDs":["altpl_d8db4xxxx"],"groupBy":["project","env"],"ignoreBadGroupEvents":true}'

Response

{
    "code": 200,
    "content": {
        "alertOpt": {},
        "config": {
            "checkRange": 604800,
            "describe": "LWCTestOpenAPI",
            "goal": 90,
            "interval": "10m",
            "minGoal": 60,
            "sli_infos": [
                {
                    "id": "rul_7xxxx",
                    "name": "lml-tes",
                    "status": 0
                },
                {
                    "id": "rul_9xxxx",
                    "name": "whytest-Feedback Problem Verification",
                    "status": 2
                }
            ]
        },
        "createAt": 1722913524,
        "creator": "wsak_a2d5xxx",
        "creatorInfo": {
            "uuid": "xx",
            "status": 0,
            "username": "xx",
            "name": "xx",
            "iconUrl": "",
            "email": "xx",
            "acntWsNickname": "xx"
        },
        "declaration": {
            "asd": "aa,bb,cc,1,True",
            "asdasd": "dawdawd",
            "business": "aaa",
            "fawf": "afawf",
            "organization": "64fe7b4062f74d0007b46676"
        },
        "deleteAt": -1,
        "id": null,
        "name": "LWC-Test-2024-08-06-002",
        "score": 0,
        "status": 0,
        "type": "slo",
        "updateAt": 1706152340,
        "updator": "xx",
        "updatorInfo": {
            "uuid": "xx",
            "status": 0,
            "username": "xx",
            "name": "xx",
            "iconUrl": "",
            "email": "xx",
            "acntWsNickname": "xx"
        },
        "uuid": "monitor_5exxxxx",
        "workspaceUUID": "wksp_4b57cxxxx"
    },
    "errorCode": "",
    "message": "",
    "success": true,
    "traceId": "12912524534614287758"
} 

Feedback

Is this page helpful?