Creating, Copying, or Batch Creating Graphs on a Dashboard
Function
This API is used to create, copy, or batch create graphs on a dashboard.
Constraints
This API is not supported in the following regions: CN East-Qingdao, LA-Mexico City1, TR-Istanbul, AP-Jakarta, ME-Riyadh, and AP-Manila.
URI
POST /v2/{project_id}/dashboards/{dashboard_id}/widgets
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID. It is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID. Constraints N/A Range 1 to 64 characters Default Value N/A |
|
dashboard_id |
Yes |
String |
Definition Dashboard ID. Constraints N/A Range The value starts with db and is followed by 22 characters of letters, digits, or a combination of both. The total length is 24 characters. Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
Content-Type |
No |
String |
Definition MIME type of the request body. Constraints: None Value range: The value can contain 1 to 64 characters. Default value: The default type is application/json; charset=UTF-8. |
|
X-Auth-Token |
No |
String |
Definition User token. Constraints: None Value range: The value can contain 1 to 16,384 characters. Default value: None |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
[items] |
No |
Array of BaseWidgetInfo objects |
Definition Graph information. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
group_id |
No |
String |
Definition Graph group ID. Constraints N/A Range The value must start with dg and is followed by 22 characters of letters, digits, or a combination of both. The total length is 24 characters. Default Value N/A |
|
metrics |
Yes |
Array of WidgetMetric objects |
Definition Metric list. Constraints Up to 200 metrics may be included, with at least one required. |
|
title |
Yes |
String |
Definition Graph name. Constraints N/A Range The value can include 1 to 128 characters. It can contain digits, letters, and the following special characters: "≤<>&/%_:;'?+,~()º[.- Default Value N/A |
|
threshold |
No |
Double |
Definition Threshold of metrics on the graph. Constraints N/A Range 0 to 1.7976931348623157e+308 Default Value N/A |
|
threshold_enabled |
Yes |
Boolean |
Definition Whether to display the threshold. Constraints N/A Range
Default Value N/A |
|
view |
Yes |
String |
Definition Graph type. Constraints N/A Range
Default Value N/A |
|
metric_display_mode |
Yes |
String |
Definition Metric display type. Constraints N/A Range
Default Value N/A |
|
properties |
No |
properties object |
Definition Additional information. Constraints N/A |
|
location |
Yes |
location object |
Definition Graph coordinates. Constraints N/A |
|
unit |
No |
String |
Definition Unit. Constraints N/A Range 0 to 32 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
namespace |
Yes |
String |
Definition Namespace of a service. For details about the namespace of each service, see Namespaces. Constraints N/A Range The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). The value must contain 3 to 32 characters. Default Value N/A |
|
dimensions |
Yes |
DimensionInfo object |
Description Dimension list. Constraints N/A |
|
metric_name |
Yes |
String |
Definition Multiple metric names. Constraints N/A Range The value can contain 1 to 1,080 characters. Multiple metric names are separated by commas (,). Default Value N/A |
|
alias |
No |
Array of strings |
Definition Metric aliases of the graph. Constraints This parameter can be transferred only when the resource type is set to Specified resources. |
|
extra_info |
No |
ExtraInfo object |
Definition Metric information. Constraints N/A |
|
last_week_compare_enable |
No |
Boolean |
Definition Whether to display comparison data (same period last week). Constraints N/A Range
Default Value N/A |
|
yesterday_compare_enable |
No |
Boolean |
Definition Whether to display comparison data (same period yesterday). Constraints N/A Range
Default Value N/A |
|
metric_dimension |
No |
String |
Definition Dimension name. For details about the dimensions supported by each service, see Service Dimension Names. The value must start with a letter and can only contain digits, letters, underscores (_), and hyphens (-). Multiple dimensions are separated by commas (,). Each dimension allows 32 characters. The value can contain 1 to 131 characters. A maximum of four dimensions are supported. Example: instance_id for single-dimension scenarios; instance_id,disk for multi-dimension scenarios. Constraints N/A Range 1 to 131 characters Default Value N/A |
|
top_num |
No |
Integer |
Definition Number of displayed data records. Constraints N/A Range 1 to 200 Default Value N/A |
|
unit |
No |
String |
Definition Unit. Constraints N/A Range 0 to 32 characters Default Value N/A |
|
order |
No |
String |
Definition Sorting field. Constraints N/A Range
Default Value N/A |
|
topn_metric_name |
No |
String |
Definition Metric name of a resource. The name must start with a letter and contain only digits, letters, and underscores. The length ranges from 1 to 64 characters. For example, cpu_util of an ECS indicates the CPU usage of the ECS. mongo001_command_ps in DDS indicates the command execution frequency. For details about the metric name of each service, see Service Metric Names. Constraints N/A Range 1 to 96 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
Description Dimension name. Constraints N/A Range Multiple dimensions are separated using commas (,). For details about the dimensions supported by each cloud service, see Services Interconnected with Cloud Eye. The value must start with a letter. Each dimension allows 1 to 32 characters and can only contain letters, digits, underscores (_), and hyphens (-). Multiple dimensions are separated using commas (,). The value can contain 1 to 131 characters. A maximum of four dimensions are supported. Example: instance_id for single-dimension scenarios; instance_id,disk for multi-dimension scenarios. Default Value N/A |
|
filter_type |
Yes |
String |
Description Resource type. Constraints N/A Range
Default Value N/A |
|
values |
No |
Array of strings |
Description Dimension value list. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
origin_metric_name |
Yes |
String |
Definition Metric name. Constraints N/A Range 1 to 4,096 characters Default Value N/A |
|
metric_prefix |
No |
String |
Definition Metric name prefix. Constraints N/A Range 1 to 4,096 characters Default Value N/A |
|
metric_type |
No |
String |
Definition Metric type. Constraints N/A Range 1 to 32 characters Default Value N/A |
|
custom_proc_name |
No |
String |
Definition Custom process name. Constraints N/A Range 1 to 250 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
filter |
No |
String |
Definition Aggregation type. Constraints This parameter is not available for line charts. Range The value can only be TopN. Default Value N/A |
|
topN |
No |
Integer |
Definition Top N values. In a line chart, this parameter indicates the number of time series data records that are randomly displayed. Constraints N/A Range 1 to 2147483647 Default Value 100 |
|
order |
No |
String |
Definition Sorting field. Constraints This parameter is not available for line charts. Range
Default Value N/A |
|
description |
No |
String |
Definition Description of the graph. Constraints N/A Range [0,200] Default Value N/A |
|
last_week_compare_enable |
No |
Boolean |
Definition Whether to display comparison data (same period last week). Constraints N/A Range
Default Value N/A |
|
yesterday_compare_enable |
No |
Boolean |
Definition Whether to display comparison data (same period yesterday). Constraints N/A Range
Default Value N/A |
|
legend_location |
No |
String |
Definition Legend location. Constraints This parameter is not available for tables. Range
Default Value N/A |
|
legend_values |
No |
Array of strings |
Definition List of statistical values to be displayed in the legend for the current time series. Constraints This parameter is not available for tables. For horizontal bar charts and vertical bar charts, only last can be selected for this parameter. |
|
thresholds |
No |
Array of ThresholdInfo objects |
Definition Threshold line configured for the graph. Constraints N/A |
|
is_all_compare_enable |
No |
Boolean |
Definition Whether to enable PoP comparison. Constraints N/A Range
Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
threshold |
Yes |
Number |
Definition Threshold of the threshold line configured for the graph. Constraints N/A Range The value ranges from 0 to 2147483647. Default Value N/A |
|
threshold_color |
Yes |
String |
Definition Color of the threshold line for the graph. Constraints N/A Range
Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
top |
Yes |
Integer |
Definition Grids between the graph and the top of the dashboard. Constraints N/A Range The value ranges from 0 to 2147483647. Default Value N/A |
|
left |
Yes |
Integer |
Definition Grids between the graph and the left side of the dashboard. Constraints N/A Range 0 to 9 Default Value N/A |
|
width |
Yes |
Integer |
Definition Graph width. Constraints N/A Range 3 to 12 Default Value N/A |
|
height |
Yes |
Integer |
Definition Graph height. Constraints N/A Range 3 to 2147483647 Default Value N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
widget_ids |
Array of strings |
Definition Response body for creating graphs in batches. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Status codes customized by each cloud service when a request error occurs. |
|
error_msg |
String |
Request error message. |
|
request_id |
String |
Request ID. |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Status codes customized by each cloud service when a request error occurs. |
|
error_msg |
String |
Request error message. |
|
request_id |
String |
Request ID. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Status codes customized by each cloud service when a request error occurs. |
|
error_msg |
String |
Request error message. |
|
request_id |
String |
Request ID. |
Example Requests
[ {
"metrics" : [ {
"namespace" : "SYS.ECS",
"dimensions" : {
"name" : "instance_id",
"filter_type" : "specific_instances",
"values" : [ "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ]
},
"metric_name" : "cpu_util",
"alias" : [ "cpuutilalias" ],
"extra_info" : {
"origin_metric_name" : "cpu_util",
"metric_prefix" : "cpu",
"metric_type" : "type",
"custom_proc_name" : "app.sh"
}
} ],
"view" : "bar",
"metric_display_mode" : "single",
"threshold" : 0.7,
"threshold_enabled" : true,
"title" : "widget_title",
"properties" : {
"filter" : "topN",
"topN" : 100,
"order" : "desc"
},
"location" : {
"left" : 0,
"top" : 0,
"width" : 4,
"height" : 3
},
"unit" : "%"
} ]
Example Responses
Status code: 200
OK
{
"widget_ids" : [ "wgx234567890123456789012" ]
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
OK |
|
400 |
The server failed to process the request. |
|
401 |
Token authentication is required. |
|
500 |
Failed to complete the request because of an internal server error. |
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.