Batch Querying Metrics
Function
This API is used to batch query metrics.
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 ISO 8601, 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 |
Whether to enable the cache. The default value is true. false: 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 the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
metric_ids |
Yes |
Array of strings |
The ID list of the metrics 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 parameter is mandatory when the data from multiple workspaces can be obtained for metrics. |
params |
No |
Array of Map<String,String> objects |
The parameter list for the metric to be queried. Each element in the list is a <String, String> key-value pair. 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 |
Interactive parameter query. If the metric supports interactive parameters, enter a parameter list, which contains <String, String> key-value pairs. 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 |
Results of batch querying metrics. |
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 alert 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 succeeded.
[ { "metric_id" : "1f0f5e29-5a92-17a5-2c16-5f37c6dc109c", "result" : { "labels" : [ "label1" ], "datarows" : [ [ { } ] ], "effective_column" : "0:1" }, "status" : "SUCCESS" } ]
Status Codes
Status Code |
Description |
---|---|
200 |
Request succeeded. |
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot