Querying Metrics in Batches
Function
This API is used to query metrics in batches.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/workspaces/{workspace_id}/sa/metrics/hits
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Project ID. |
|
workspace_id |
Yes |
String |
Workspace ID. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
timespan |
No |
String |
The time range for querying metrics. The format is ISO8601, for example, 2007-03-01T13:00:00Z/2008-05-11T15:30:00Z, 2007-03-01T13:00:00Z/P1Y2M10DT2H30M, or P1Y2M10DT2H30M/2008-05-11T15:30:00Z. |
|
cache |
No |
Boolean |
Indicates whether to enable the cache. The default value is true. The value false indicates that the cache is disabled. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
metric_ids |
Yes |
Array of strings |
Specifies the metric ID list to be queried. For details about how to obtain the existing metrics, see the related information in the appendix. |
|
workspace_ids |
No |
Array of strings |
Workspace list. This API is mandatory when the metric supports obtaining data of multiple workspaces. |
|
params |
No |
Array of Map<String,String> objects |
Indicates the parameter list of the metric to be queried. Each element in the list is in K-V format of <String, String>. The number of elements must be the same as that of the metric_ids list. For details, see the appendix. |
|
interactive_params |
No |
Array of Map<String,String> objects |
For query the interactive parameters, if the metric supports interactive parameters, enter a parameter list in the K-V format of <String, String>. For details, see the appendix. |
|
field_ids |
No |
Array of strings |
Metric card ID list |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
[items] |
Array of ShowMetricResultResponseBody objects |
|
Parameter |
Type |
Description |
|---|---|---|
|
metric_id |
String |
Metric ID |
|
result |
result object |
Metric query result. |
|
metric_format |
Array of MetricFormat objects |
Metric format. The value is fixed based on different metrics. |
|
log_msg |
String |
Result log information |
|
status |
String |
Query result status. The options are as follows: SUCCESS: The query is successful. FAILED: The query fails. FALLBACK: The default value is used. |
Example Requests
Query the alarm severity distribution from June 25 to the current time through the metric API.
https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/sa/metrics/hits
{
"metric_ids" : [ "1f0f5e29-5a92-17a5-2c16-5f37c6dc109c" ],
"params" : [ {
"start_date" : "2024-06-25T00:00:00.000+08:00"
} ]
}
Example Responses
Status code: 200
Request successful.
[ {
"metric_id" : "1f0f5e29-5a92-17a5-2c16-5f37c6dc109c",
"result" : {
"labels" : [ "label1" ],
"datarows" : [ [ { } ] ],
"effective_column" : "0:1"
},
"status" : "SUCCESS"
} ]
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Request successful. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.