Integration With Superset
Apache Superset is a modern enterprise level business intelligence (BI) web application primarily used for data exploration and visualization. It is supported by the Apache Software Foundation and is an open source project with an active community and rich ecosystem. Apache Superset provides an intuitive user interface that makes creating, sharing, and visualizing data simple, while supporting multiple data sources and rich visualization options.
Through the Python connector of TDengine, Superset can support TDengine data sources and provide functions such as data presentation and analysis.
Prerequisites
Prepare the following environment:
- TDengine 3.2.3.0 and above version is installed and running normally (both Enterprise and Community versions are available).
- taosAdapter is running normally, refer to taosAdapter.
- Apache Superset version 2.1.0 or above is already installed, refre to Apache Superset.
- The Python connector taospy version 2.7.18 or higher is installed, Install reference link.
- The Python connector (WebSocket) taos-ws-py version 0.3.9 or higher is installed, Install reference link.
Configure Data Source
-
Enter the new database connection page, "Superset" -> "Setting" -> "Database Connections" -> "+DATABASE".
-
Select the last item "Other" from the drop-down list of "SUPPORTED DATABASES".
-
Enter a connection name in "DISPLAY NAME", you can enter any name.
-
Fill in the database connection string.
Fill in the "SQLAlchemy URI" in the following format, and make sure the information is correct.taosws://user:password@host:port
Parameter Parameter Description user Username for logging into TDengine database password Password for logging into TDengine database host Name of the host where the TDengine database is located port The port that provides WebSocket services, default is 6041 Example:
The TDengine database installed on this machine provides WebSocket service port 6041, using the default username and password, "SQLALCHEMY URI" is:
taosws://root:taosdata@localhost:6041
-
Test the connection.
Click "TEST CONNECTION" to check if the connection is successful. After the test passes, click the "CONNECT" button to save the configuration.
Data Analysis
Data preparation
There is no difference in the use of TDengine data source compared to other data sources. Here is a brief introduction to basic data queries:
- Click the "+" button in the upper right corner of the Superset interface, select "SQL query", and enter the query interface.
- Select the previously created "TDengine" data source from the "Database" dropdown list in the upper left corner.
- Select the name of the database to be operated on from the drop-down list of "SCHEMA" (system libraries are not displayed).
- "SEE TABLE SCHEMA" select the name of the super table or regular table to be operated on (sub tables are not displayed).
- Subsequently, the schema information of the selected table will be displayed in the following area.
- In the "SQL" editor area, any SQL statement that conforms to TDengine syntax can be entered for execution.
Smart Meter Example
We chose two popular templates from the "Superset Chart" template to showcase their effects, using smart meter data as an example:
-
"Aggregate" Type, which displays the maximum voltage value collected per minute during the specified time period in Group 4.
-
"RAW RECORDS" Type, which displays the collected values of current and voltage during the specified time period in Group 4.