Skip to content

Display Data through Alibaba Cloud DataV

This document mainly introduces how to query data via DataKit and display the data in DataV within this system.

The content of this article is for the overall appearance of the documentation, some screenshots may contain fictional elements

The examples in this article will only produce expected results if components such as DataKit, DataWay, etc., from Guance are correctly configured/running and the network is functioning properly

Always use the latest version of DataFlux Func for operations

1. Background

For Guance users, it is possible to query time series data from Guance using DataKit via DataFlux Func and display the data in DataV.

DataFlux Func, as a platform for managing and running Python scripts, can provide more flexible and powerful data processing capabilities.

This article assumes that the user has already correctly connected DataKit in DataFlux Func. For information on how to connect DataKit in DataFlux Func, please refer to:

2. Writing a Data Query Function

Enter the editor, create a script, and input the following example script:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import arrow

@DFF.API('DataKit Demo')
def datakit_demo():
    # Get the DataKit operation object
    datakit = DFF.CONN('datakit')

    # Use DQL to query data
    dql = 'M::datakit:(AVG(num_goroutines) AS value) [7d::1d] LIMIT 10'
    status_code, dql_res = datakit.query(dql, dict_output=True)

    # Convert to the format required by DataV line charts
    data = []
    series = dql_res['series'][0]
    for point in series:
        data.append({
            'x': arrow.get(point['time']).format('YYYY-MM-DD'),
            'y': point['value'],
            's': 1,
        })

    print('OK')

    return data

3. Publish the Script

After modifying the script, it will be saved as a draft and needs to be published to go live formally.

Functions decorated with @DFF.API(...) can be configured in the "Manage / Sync API (Old Version: Authorized Link)" section to allow external systems access.

5. Configure Connectors in DataV

In the list of "Sync APIs (Old Version: Authorized Links)" that have been created, you can find the previously created Sync API (Old Version: Authorized Link).

Open the "API Call Example" to obtain various ways to call this Sync API (Old Version: Authorized Link).

Select an appropriate calling method and configure it in DataV.

6. View Dashboards in DataV

At this point, the data from the Guance workspace has been successfully displayed on DataV.