Skip to content

Create



POST /api/v1/dashboards/create

Overview

Create an empty dashboard, or create a dashboard based on a dashboard template. Rules

The name field in the parameters will override the title in templateInfo.

Body Request Parameters

Parameter Name Type Required Description
name string Y Dashboard name
Allow empty: False
Max length: 128
desc string Description
Example: description1
Allow empty: False
Allow empty string: True
Max length: 2048
recoverIdentifier boolean Whether to overwrite duplicate identifier id/name related objects. false - only return duplicate groups, true - delete related objects in duplicate groups and continue creation.
Allow empty: False
identifier string Identifier id -- Added identifier id on 2024.12.25
Example: xxxx
Allow empty: False
Allow empty string: True
Max length: 128
extend json Extra data for the dashboard, default is {}
Example: {}
Allow empty: False
mapping array Field mapping information for view variables, default is []
Example: [{'class': 'host_processes', 'field': 'create_time', 'mapping': 'username', 'datasource': 'object'}]
Allow empty: False
tagNames array Associated tag list
Allow empty: False
templateInfo json Dashboard template data
Example: {}
Allow empty: False
Allow empty string: False
specifyDashboardUUID string Specify the UUID for the new dashboard, must start with dsbd_custom_ followed by 32 lowercase alphanumeric characters.
Example: dsbd_custom_xxxx32
Allow empty: False
Allow empty string: False
$matchRegExp: ^dsbd_custom_[a-z0-9]{32}$
isPublic int Whether to display publicly, 1 for public, 0 for non-public, -1 for custom.
Example: 1
Allow empty: False
openPermissionSet boolean 2024-11-27 iteration, this field is deprecated and no longer effective. Subsequently, use isPublic = -1 to indicate enabling custom permission configuration.
Allow empty: False
permissionSet array Operation permission configuration for custom when isPublic is -1, configurable (role (except owner), member uuid, team uuid).
Example: ['wsAdmin', 'acnt_xxxx', 'group_yyyy']
Allow empty: False
readPermissionSet array Read permission configuration for custom when isPublic is -1, configurable (role (except owner), member uuid, team uuid).
Example: ['wsAdmin', 'acnt_xxxx', 'group_yyyy']
Allow empty: False

Parameter Supplementary Description

1. Interface Behavior

The interface first checks for conflicts with the name and identifier ID of the dashboard to be created. Conflict results are returned in the following three categories:

  • name_and_identifier: Both name and identifier ID are duplicate.
  • identifier: Only the identifier ID is duplicate.
  • name: Only the name is duplicate.

When recoverIdentifier=false or not provided: - Does not create the dashboard. - Directly returns repeatInfo.

When recoverIdentifier=true: - Deletes the related dashboards in the duplicate groups mentioned above that are matched. - Then continues to create the new dashboard.


2. Response Examples

2.1 Creation Successful

{
  "uuid": "dsbd_xxxx32",
  "name": "CPU Monitoring View"
}

2.2 Duplicates exist, returns duplicate groups.

{
  "repeatInfo": {
    "name_and_identifier": [
      {
        "name": "System Overview",
        "identifier": "system_overview",
        "importName": "System Overview",
        "importIdentifier": "system_overview",
        "existName": "System Overview",
        "existIdentifier": "system_overview",
        "conflictUUIDs": ["dsbd_xxxx01"]
      }
    ],
    "identifier": [],
    "name": []
  }
}

3. Parameter Description

Parameter Description:

The basic structure of the template consists of: view structure (including chart structure, view variable structure, chart group structure).

Main Structure Description of templateInfo

Parameter Name type Required Description
title string Required View title name
summary string Summary information of the template
identifier string Template identifier id -- Added identifier id on 2024.12.25
dashboardType string Deprecated, defaults to CUSTOM
dashboardExtend json Extra data information for the view
dashboardMapping array[json] List of field mapping configurations for view variables
iconSet json Dashboard icon information
iconSet.url json Medium icon link address for the dashboard
iconSet.icon json Small icon link address for the dashboard
icon string Small icon file name for the dashboard
thumbnail string Medium icon file name for the dashboard
main json Dashboard content structure
main.type string Template type, this is a system field and can be ignored.
main.vars array[json] List of view variable configurations
main.vars[#] json View variable configuration structure
main.groups array[string] List of chart group names
main.charts array[json] List of chart configurations for the view
main.charts[#] json Chart configuration structure

Main Structure Description of dashboardMapping[#]

Parameter Name type Required Description

Main Structure Description of main.charts[#]

Parameter Name type Required Description
name string Required Chart name
type string Required Chart type
pos json Chart position structure
pos.i string
pos.h string Height
pos.w string Width
pos.x string X-axis coordinate
pos.y string Y-axis coordinate
group json[string] Group information
group.name string Group name, can be null if no group.
queries array[json] Required List of chart query statement structures

**Structure of Time Series Chart main.charts[#].type=sequence Its main structure parameters are as follows: **

Parameter Name type Required Description
name string Required Chart name
type string Required Chart type
pos string Required Chart type
queries array[json] Required List of chart query statement structures

Main Structure Description of main.vars[#]

Parameter Name type Required Description

Request Example

curl 'https://openapi.truewatch.com/api/v1/dashboards/create' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw '{"name": "x5T8APwi", "templateInfo": {"dashboardBindSet": [], "dashboardExtend": {}, "dashboardMapping": [], "dashboardOwnerType": "node", "dashboardType": "CUSTOM", "iconSet": {}, "main": {"charts": [{"extend": {"settings": {"chartType": "bar", "colors": [{"color": "#3ab8ff", "key": "count(trace_id){\"status\": \"ok\"}"}, {"color": "#f97575", "key": "count(trace_id){\"status\": \"error\"}"}], "openStack": true, "options": {"yAxis": {"axisLabel": {"color": "#666"}, "axisLine": {"show": true}, "axisTick": {"show": false}, "splitLine": {"show": false}, "splitNumber": 1}}, "xAxisShowType": "time"}}, "group": {"name": null}, "name": "Request Count", "pos": null, "queries": [{"checked": true, "datasource": "dataflux", "qtype": "dql", "query": {"density": "lower", "filter": [{"logic": "and", "name": "service", "op": "=", "value": "front-api"}], "groupBy": " by `status`", "groupByTime": "auto", "q": "T::re(`.*`):(count(`trace_id`)){ `service` = 'front-api' } [::auto] by `status`"}, "unit": "", "uuid": "6aed3c00-7a99-11ec-8689-536665ee3a48"}], "type": "sequence"}], "groups": [], "type": "template", "vars": []}, "summary": "", "tagInfo": [], "tags": [], "thumbnail": "", "title": "lwc-Tracing Resource"}}' \
--compressed

Response

{
    "code": 200,
    "content": {
        "chartGroupPos": [],
        "chartPos": [
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 0,
                    "w": 8,
                    "x": 0,
                    "y": 0
                }
            },
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 1,
                    "w": 8,
                    "x": 0,
                    "y": 9
                }
            },
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 2,
                    "w": 8,
                    "x": 8,
                    "y": 0
                }
            },
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 3,
                    "w": 8,
                    "x": 16,
                    "y": 0
                }
            },
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 4,
                    "w": 8,
                    "x": 8,
                    "y": 9
                }
            },
            {
                "chartUUID": "chrt_xxxx32",
                "pos": {
                    "h": 9,
                    "i": 5,
                    "w": 8,
                    "x": 16,
                    "y": 9
                }
            }
        ],
        "createAt": 1641953280.0015242,
        "createdWay": "manual",
        "creator": "acnt_xxxx32",
        "dashboardBindSet": [],
        "deleteAt": -1,
        "extend": {},
        "iconSet": {
            "icon": "http://testing-static-res.cloudcare.cn/dataflux-template/dashboard/cpu/icon.svg",
            "url": "http://testing-static-res.cloudcare.cn/dataflux-template/dashboard/cpu/cpu.png"
        },
        "id": null,
        "mapping": [],
        "name": "CPU Monitoring View-lwctest",
        "ownerType": "node",
        "status": 0,
        "tag_info": [
            {
                "id": "tag_xxxx32",
                "name": "Test"
            }
        ],
        "type": "CUSTOM",
        "updateAt": 1641953280.0015464,
        "updator": "acnt_xxxx32",
        "uuid": "dsbd_xxxx32",
        "workspaceUUID": "wksp_xxxx32"
    },
    "errorCode": "",
    "message": "",
    "success": true,
    "traceId": "TRACE-97C1194E-40E6-43A3-B6DF-6637D96BECDB"
}