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. Minimum: 32 Maximum: 32 |
workspace_id |
Yes |
String |
Workspace ID. Minimum: 36 Maximum: 36 |
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. Minimum: 1 Maximum: 255 |
cache |
No |
Boolean |
Indicates whether to enable the cache. The default value is true. The value false indicates that the cache is disabled. Default: true |
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. Minimum: 100 Maximum: 100000 |
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. Minimum: 10 Maximum: 64 Array Length: 1 - 50 |
workspace_ids |
No |
Array of strings |
Workspace list. This API is mandatory when the metric supports obtaining data of multiple workspaces. Minimum: 10 Maximum: 64 Array Length: 0 - 50 |
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. Array Length: 0 - 50 |
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. Array Length: 0 - 100 |
field_ids |
No |
Array of strings |
Metric card ID list Minimum: 32 Maximum: 64 Array Length: 0 - 50 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
[items] |
Array of ShowMetricResultResponseBody objects |
Request successful. |
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. Array Length: 0 - 64 |
log_msg |
String |
Result log information Minimum: 0 Maximum: 1024 |
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. Minimum: 0 Maximum: 128 Enumeration values:
|
Parameter |
Type |
Description |
---|---|---|
labels |
Array of strings |
Title of the metric query result table Minimum: 0 Maximum: 999 Array Length: 0 - 999 |
datarows |
Array<Array<Object>> |
Metric query result table. Array Length: 0 - 999 |
effective_column |
String |
Effective columns. If this parameter exists, the specified column is used as the metric data result. |
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot