Add an OpenAPI data source

更新时间:
复制 MD 格式

OpenAPI is an Alibaba Cloud service for calling cloud product APIs to perform control and query tasks. In DataV, you can add an OpenAPI data source to retrieve and display data from other cloud products.

Prerequisites

An OpenAPI data source is ready to be added.

Limits

This feature is available only in DataV Enterprise Edition and later versions.

Add an OpenAPI data source

  1. Access the DataV console.

  2. On the Workbench page, click Data Preparation > Data Source in the navigation pane on the left. On the Data Source page, click New Data Source.

  3. From the Type drop-down list, select OpenAPI.

  4. Enter the OpenAPI information.

    image

    Parameter

    Description

    Custom Data Source Name

    The display name for the data source. You can use any name.

    EndPoint

    The service endpoint for the OpenAPI. Obtain this from the API documentation of the cloud product. For example, the endpoint for ECS is ecs.aliyuncs.com, and the service endpoint for Cloud Monitor in the China (Hangzhou) region is metrics.cn-hangzhou.aliyuncs.com.

    APIVersion

    The API version of the cloud product. Obtain this from the API documentation. For example, the API version for Cloud Monitor is 2017-03-01.

    AppKey

    The AccessKey ID of the account used to call the OpenAPI.

    AppSecret

    The AccessKey secret of the account used to call the OpenAPI.

    Request Style

    Select RPC or ROA.

  5. After you enter the information, click OK to add the data source.

    The new data source is automatically added to the data source list.

Use an OpenAPI data source

  1. Access the DataV console.

  2. On the Workbench page, hover over the data dashboard you want to edit and click Edit.

    Important

    If you haven't created a data dashboard on your Workbench page, please see Create a PC Dashboard Using a Template for guidance on creating one.

  3. On the canvas editing page, select a widget from the canvas.

    If your canvas lacks widgets, please add them first. For more information, see Widget Canvas Operations.

  4. In the widget configuration panel on the right, select Data Source.

    image

  5. Set Data Source Type to OpenAPI.

  6. From the Select Existing Data Source drop-down list, select the OpenAPI data source that you configured.

  7. From the Request Method drop-down list, select a request method. You can select GET or POST. For more information about these methods, see Common request methods.

  8. Enter the API Operation Name.

    The name of the API operation to call, which corresponds to the Action parameter. Obtain this from the API list of the cloud product. For example, the value for Cloud Monitor is DescribeMetricList.

  9. (Optional) Enter the Response Path.

    Specify a path to extract a specific part of the OpenAPI response.

    For example, if the OpenAPI response is:

    {
        "data": [
            {
                "x": 1,
                "y": 2
            },
            {
                "x": 2,
                "y": 4
            }
        ]
    }

    If you enter data in the Response Path field, the following data is returned:

    [
        {
            "x": 1,
            "y": 2
        },
        {
            "x": 2,
            "y": 4
        }
    ]
    Note

    You can also perform this transformation by using a filter. You can leave this field empty.

  10. In the editor, enter the query parameters.

    • The query parameters are the request parameters of the API operation. Enter them in JSON object format.

    • For parameter names, see the request parameter descriptions in the API documentation of the cloud product.

    • Enter the callback ID as a value in the JSON object.

    For example, the following code shows the query parameters for the DescribeMetricList API operation of Cloud Monitor.

    {
      "MetricName": "cpu_idle",
      "Namespace": "acs_ecs_dashboard",
      "Dimensions": [
        {
          "instanceId": "i-j6c0kyh2qh7fi0r4k351"
        }
      ],
      "StartTime": "2021-01-27 14:00:00",
      "EndTime": "2021-01-27 15:00:00",
      "Period": "60"
    }
  11. Select Object to Array to automatically convert the returned object to an array.

    For example:

    // Raw data
    {
      "name": "..."
    }
     => 
    // Transformed data
    [{
      "name": "..."
    }]
    Note

    This option is not frequently used. We recommend that you use a filter to transform the data format.

  12. Click View Data Response to view the data response.

What to do next

To use the data source in your widgets, see Configure a widget data source.

FAQ

For more information, see FAQ about data source configuration and usage.