跳转至

指标树归因分析查询

接口说明

指标树归因分析报告查询

接口请求地址

POST Http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/metric/tree/attribution/report/query

anymetrics_host:anymetrics_port 获取方式请参考:调用方式

请求参数

公共请求参数(HEADERS)

参数 类型 是否必选 最大长度 描述
tenant-id String 32 租户ID,用于指标查询内容所在的租户
auth-type String 32 认证方式,用于设置身份认证方式 UID:使用 UID 进行身份认证TOKEN:使用 TOKEN 进行身份认证
auth-value String 32 UID或者TOKEN值,与auth-type 类型选择一致

公共参数获取方式

tenant-id 与 auth-value:在 Aloudata CAN 顶部导航栏选择指标应用,左边菜单栏选择 API 集成。在 API 集成界面获取取到tenant-id 与auth-value。

请求参数

Map 类型 是否必选 描述
attributionRange Map 归因范围,更多详情请参考:attributionRange 参数说明
metricTree Map metricTree定义了指标之间的层级关系和计算逻辑。每个节点代表一个指标,包含其计算表达式和引用的指标ID。更多详情请参考:metricTree 参数说明
metrics Map metrics 部分详细定义了每个指标的具体信息,包括其唯一标识和代码。
filters List 筛选器

attributionRange 参数说明

参数 类型 是否必选 描述
granularity String 时间粒度:DAY,WEEK,MONTH,QUARTER,YEAR
currentFilter String 当前时间:

<br>"currentFilter": {<br> "type": "EXPR",<br> "expr": "DateTrunc([metric_time], \"DAY\")=\"2024-12-25\""<br> }<br>
comparisonType String 对比类型:CUSTOM,DOD,YOY,MOM,QOQ,WOW
endDateTime String 当对比类型为 CUSTOM 时,需要指定startDateTime 和endDateTime
startDateTime String

metricTree(指标树)

说明:metricTree 定义了指标之间的层级关系和计算逻辑。每个节点代表一个指标,包含其计算表达式和引用的指标ID。

节点信息

请为每个节点填写以下信息:

参数路径 类型 必填 示例值 说明
metricTree.{节点名称} Object { "expr": "[子指标1]+[子指标2]", "refId": "METRIC_001" } 每个节点的名称(例如 RootNode),包含计算表达式和引用的指标ID。
metricTree.{节点名称}.expr String "[MetricA]+[MetricB]" 指标的计算表达式。若为空,表示该节点不进行进一步的指标拆分。
metricTree.{节点名称}.refId String "METRIC_001" 引用的指标ID,用于关联 metrics 中的具体指标。
示例节点填写
节点名称 expr refId 说明
RootNode "[MetricA]+[MetricB]" METRIC_001 定义根节点,通过加法将 MetricAMetricB 两个子指标相加得到。
MetricA "" METRIC_002 不进行进一步拆分,直接引用具体指标。
MetricB "" METRIC_003 不进行进一步拆分,直接引用具体指标。

metrics(指标定义)

说明:metrics 部分详细定义了每个指标的具体信息,包括其唯一标识和代码。

指标信息

请为每个指标填写以下信息:

参数路径 类型 必填 示例值 说明
metrics.{指标ID} Object { "id": "METRIC_002", "code": "Sales" } 每个指标的唯一标识和代码。
metrics.{指标ID}.id String "METRIC_002" 指标的唯一ID。
metrics.{指标ID}.code String "Sales" 指标的代码或名称,用于唯一标识该指标。
示例指标填写
指标ID code 说明
METRIC_001 TotalSales 计算后的总销售额。
METRIC_002 Sales 具体的销售指标。
METRIC_003 Returns 退货指标。

综合模板

{
    "metricTree": {
        "RootNode": {
            "expr": "[MetricA]+[MetricB]",
            "refId": "METRIC_001"
        },
        "MetricA": {
            "expr": "",
            "refId": "METRIC_002"
        },
        "MetricB": {
            "expr": "",
            "refId": "METRIC_003"
        }
    },
    "metrics": {
        "METRIC_001": {
            "id": "METRIC_001",
            "code": "TotalSales"
        },
        "METRIC_002": {
            "id": "METRIC_002",
            "code": "Sales"
        },
        "METRIC_003": {
            "id": "METRIC_003",
            "code": "Returns"
        }
    },
    "filters": [
        "IN(['dim'],\"a\")"

    ],
    "attributionRange": {
        "granularity": "DAY",
        "comparisonType": "DOD",
        "currentFilter": {
            "type": "EXPR",
            "expr": "DateTrunc([metric_time], 'DAY') = '2024-11-30'"
        }
    }
}

响应参数

参数 类型 是否必选 最大长度 描述 示例值
code String 32 接口响应码 200
errorMsg String 512 报错信息 null
success boolean 是否请求成功 true
traceId String 128 traceId fdde343f9ff2dcd70.292.16857691758642861
data List 返回结果,具体参数说明参见:4.1 data
detailErrorMsg String 512 报错详情 null

data

参数 子参数 类型 是否必选 描述 示例值
{指标 id} currentValue Double 当前值 123
comparisonValue Double 对比值 100
growth Double 增长值 -23
growthRate Double 增长率 0.23
contributionRate Double 贡献率 0.23

请求示例

{
    "metricTree": {
        "sMkWfXTOQGqPIhMr": {
            "expr": "[VjhkQrQJRqZaAAdw]+[PoMpVMKjYnCXWrht]",
            "refId": "METRIC___SELF___BsZregkgzIWKeLlQ"
        },
        "VjhkQrQJRqZaAAdw": {
            "expr": "",
            "refId": "METRIC_mc056ea4a8aaf875414852edfdf152a3"
        },
        "PoMpVMKjYnCXWrht": {
            "expr": "",
            "refId": "METRIC_34ad74cd0b0542079f45b9873a7870d5"
        }
    },
    "metrics": {
        "METRIC_34ad74cd0b0542079f45b9873a7870d5": {
            "id": "METRIC_34ad74cd0b0542079f45b9873a7870d5",
            "code": "chixubaoyou"
        },
        "METRIC___SELF___BsZregkgzIWKeLlQ": {
            "id": "METRIC___SELF___BsZregkgzIWKeLlQ",
            "code": "lhdb_BYKH"
        },
        "METRIC_mc056ea4a8aaf875414852edfdf152a3": {
            "id": "METRIC_mc056ea4a8aaf875414852edfdf152a3",
            "code": "lhdb_ceshi6"
        }
    },
    "filters": [],
    "attributionRange": {
        "granularity": "DAY",
        "comparisonType": "DOD",
        "currentFilter": {
            "type": "EXPR",
            "expr": "DateTrunc([metric_time], \"DAY\") = \"2024-11-30\""
        }
    }
}

响应示例

{
    "data": {
        "PoMpVMKjYnCXWrht": {
            "dimensionValue": null,
            "currentValue": 10.0,
            "comparisonValue": 10.0,
            "growth": 0.0,
            "growthRate": 0.0,
            "overallContributionRate": 0.0,
            "relativeContributionRate": 0.0
        },
        "sMkWfXTOQGqPIhMr": {
            "dimensionValue": null,
            "currentValue": 11.0,
            "comparisonValue": 11.0,
            "growth": 0.0,
            "growthRate": 0.0,
            "overallContributionRate": 1.0,
            "relativeContributionRate": 1.0
        },
        "VjhkQrQJRqZaAAdw": {
            "dimensionValue": null,
            "currentValue": 1.0,
            "comparisonValue": 1.0,
            "growth": 0.0,
            "growthRate": 0.0,
            "overallContributionRate": 0.0,
            "relativeContributionRate": 0.0
        }
    },
    "success": true,
    "code": "200",
    "errorMsg": null,
    "detailErrorMsg": null,
    "traceId": "2184fcda742048f7bb0d82c963e09a7d.188.17369069011400081"
}