/api/tree/test

为了调试规则集,可以使用测试端点通过树的规则来运行 TSMeta 对象,并确定叶子在层次结构中的哪个位置。或者找出为什么时间序列与规则集不匹配或与现有时间序列冲突的原因。支持的唯一方法是GET,使用此端点时不会对存储中的实际树进行任何更改。

响应的messages字段包含有关处理期间发生的情况的信息。如果 TSUID 不存在或发生错误,则将在此字段中找到原因。在处理过程中,处理 TSMeta 的每个规则都会生成一条消息。如果在 TSMeta 上匹配的规则成功或失败,则将记录原因。

Verbs

  • GET

Requests

此端点需要以下字段。

NameData TypeRequiredDescriptionDefaultQSRWExample
treeIdIntegerRequired通过 TSMeta 对象传递的树的 ID treeid 1
tsuidsStringRequired要为其获取 TSMeta 的一个或多个 TSUID 的列表。如果要求测试多个 TSUID,则应以逗号分隔。 tsuids 000001000001000001,00000200000200002

Response

成功的响应将返回 JSON 对象的列表,其中包含许多项目,包括 TSMeta 对象,有关已执行的处理步骤的消息以及结果分支。对于每个以 TSUID 作为对象名称的 TSUID,将有一个对象。如果请求的树在系统中不存在,则将返回404并显示一条错误消息。如果提供了无效数据,将返回400错误。

在响应中找到的字段包括:

NameData TypeDescriptionExample
messages字符串数组规则集的每个级别和规则的消息列表See Below
metaObject从存储中加载的 TSMeta 对象See Below
branchObject完整树,如果成功解析See Below

Example Request

Example Response

{
    "000001000001000001000002000002": {
        "messages": [
            "Processing rule: [1:0:0:TAGK]",
            "Matched tagk [host] for rule: [1:0:0:TAGK]",
            "Processing rule: [1:1:0:METRIC]",
            "Depth [3] Adding leaf [name: sys.cpu.0 tsuid: 000001000001000001000002000002] to parent branch [Name: [web-01.lga.mysite.com]]"
        ],
        "meta": {
            "tsuid": "000001000001000001000002000002",
            "metric": {
                "uid": "000001",
                "type": "METRIC",
                "name": "sys.cpu.0",
                "description": "",
                "notes": "",
                "created": 1368979404,
                "custom": null,
                "displayName": ""
            },
            "tags": [
                {
                    "uid": "000001",
                    "type": "TAGK",
                    "name": "host",
                    "description": "",
                    "notes": "",
                    "created": 1368979404,
                    "custom": null,
                    "displayName": ""
                },
                {
                    "uid": "000001",
                    "type": "TAGV",
                    "name": "web-01.lga.mysite.com",
                    "description": "",
                    "notes": "",
                    "created": 1368979404,
                    "custom": null,
                    "displayName": ""
                },
                {
                    "uid": "000002",
                    "type": "TAGK",
                    "name": "type",
                    "description": "",
                    "notes": "",
                    "created": 1368979404,
                    "custom": null,
                    "displayName": ""
                },
                {
                    "uid": "000002",
                    "type": "TAGV",
                    "name": "user",
                    "description": "",
                    "notes": "",
                    "created": 1368979404,
                    "custom": null,
                    "displayName": ""
                }
            ],
            "description": "",
            "notes": "",
            "created": 0,
            "units": "",
            "retention": 0,
            "max": "NaN",
            "min": "NaN",
            "displayName": "",
            "lastReceived": 0,
            "totalDatapoints": 0,
            "dataType": ""
        },
        "branch": {
            "leaves": null,
            "branches": [
                {
                    "leaves": [
                        {
                            "metric": "",
                            "tags": null,
                            "tsuid": "000001000001000001000002000002",
                            "displayName": "sys.cpu.0"
                        }
                    ],
                    "branches": null,
                    "path": {
                        "0": "ROOT",
                        "1": "web-01.lga.mysite.com"
                    },
                    "treeId": 1,
                    "displayName": "web-01.lga.mysite.com",
                    "branchId": "0001247F7202",
                    "numLeaves": 1,
                    "numBranches": 0,
                    "depth": 1
                }
            ],
            "path": {
                "0": "ROOT"
            },
            "treeId": 1,
            "displayName": "ROOT",
            "branchId": "0001",
            "numLeaves": 0,
            "numBranches": 1,
            "depth": 0
        }
    }
}

错误响应示例

{
    "000001000001000001000002000003": {
        "branch": null,
        "messages": [
            "Unable to locate TSUID meta data"
        ],
        "meta": null
    }
}