Skip to content

Review required 7bbf77ca

API Description

Queries a metric tree attribution analysis report.

API Request URL

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

For how to obtain anymetrics_host:anymetrics_port, see Calling APIs

Request Parameters

Common Request Parameters (HEADERS)

Parameter Type Required Description
tenant-id String Yes Tenant ID, used to identify the tenant that contains the metric query content
auth-type String Yes Authentication method. Supports UIDTOKENACCOUNTAPIKEY
auth-value String Yes Authentication value corresponding to auth-type

How to Obtain Common Parameters

You can obtain tenant-id in Aloudata CAN by choosing Metric Applications in the top navigation and API Integration in the left menu. Fill in auth-value according to the selected auth-type.

Request Parameters

Map Type Required Description
attributionRange Map Yes Attribution range. For details, see attributionRange parameter description.
metricTree Map Yes metricTree defines the hierarchy and calculation logic between metrics. Each node represents a metric and contains its calculation expression and referenced metric ID. For details, see metricTree parameter description.
metrics Map Yes The metrics section defines details for each metric, including its unique identifier and code.
filters List No Filters

attributionRange ParameterDescription

Parameter Type Required Description
granularity String Yes Time granularity: DAY, WEEK, MONTH, QUARTER, YEAR
currentFilter String Yes Current time:

<br>"currentFilter": {<br> "type": "EXPR",<br> "expr": "DateTrunc([metric_time], \"DAY\")=\"2024-12-25\""<br> }<br>
comparisonType String Yes Comparison type: CUSTOM, DOD, YOY, MOM, QOQ, WOW
endDateTime String No When comparison type is CUSTOM, specify startDateTime and endDateTime.
startDateTime String No

metricTree (Metric Tree)

Description: metricTree defines the hierarchy and calculation logic between metrics. Each node represents a metric and contains its calculation expression and referenced metric ID.

Node Information

Fill in the following information for each node:

Parameter Path Type Required Example Value Description
metricTree.{nodeName} Object Yes { "expr": "[SubMetric1]+[SubMetric2]", "refId": "METRIC_001" } Name of each node, such as RootNode; contains the calculation expression and referenced metric ID.
metricTree.{nodeName}.expr String No "[MetricA]+[MetricB]" Calculation expression of the metric. If empty, the node is not split into additional metrics.
metricTree.{nodeName}.refId String Yes "METRIC_001" Referenced metric ID used to associate the node with a specific metric in metrics.
Example Node Values
nodeName expr refId Description
RootNode "[MetricA]+[MetricB]" METRIC_001 Defines the root node by adding the two child metrics MetricA and MetricB.
MetricA "" METRIC_002 No further split; directly references a specific metric.
MetricB "" METRIC_003 No further split; directly references a specific metric.

metrics (Metric Definitions)

Description:The metrics section defines details for each metric, including its unique identifier and code.

Metric Information

Fill in the following information for each metric:

Parameter Path Type Required Example Value Description
metrics.{MetricID} Object Yes { "id": "METRIC_002", "code": "Sales" } Unique identifier and code of each metric.
metrics.{MetricID}.id String Yes "METRIC_002" Unique ID of the metric.
metrics.{MetricID}.code String Yes "Sales" Metric code or name used to uniquely identify the metric.
Example Metric Values
MetricID code Description
METRIC_001 TotalSales Calculated total sales.
METRIC_002 Sales Specific sales metric.
METRIC_003 Returns Return metric.

Complete Template

{
    "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'"
        }
    }
}

ResponseParameter

Parameter Type Required Max Length Description Example Value
code String Yes 32 API response code 200
errorMsg String Yes 512 Error message null
success boolean Yes Whether the request succeeded true
traceId String Yes 128 traceId fdde343f9ff2dcd70.292.16857691758642861
data List Yes Returned result. For parameter details, see 4.1 data.
detailErrorMsg String Yes 512 Error details null

data

Parameter Subparameter Type Required Description Example Value
{Metric id} currentValue Double Yes Current value 123
comparisonValue Double Yes Comparison value 100
growth Double Yes Growth value -23
growthRate Double Yes Growth rate 0.23
contributionRate Double Yes Contribution rate 0.23

Request Example

{
    "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\""
        }
    }
}

Response Example

{
    "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"
}