All Products
Document Center

TSQL development

Last Updated: May 25, 2020

TSQL Development is a web-based data query tool that is provided by Time Series Database (TSDB). This topic describes how to use TSQL to query data and implement visual data analysis. The TSQL Development page in the TSDB console consists of three key sections.

Auxiliary input section

The auxiliary input section provides the following fields: Metrics, Time Range, Agg Window, and Columns. You can specify the fields based on your business requirements. Each change you have made to the field settings is reflected in the SELECT statement in the code editor section. The code editor section is located below the preceding fields. The fields are described as follows:

  • Metrics: After you select a metric, the table name is automatically added to the FROM clause.

  • Time Range: After you specify a time range, the query condition for the time is automatically added to the WHERE clause.

  • Agg Window: After you select a time window, the GROUP BY clause is automatically added. Groups are determined based on the time window, such as tumble (timestamp, INTERVAL ‘1’ MINUTE).

  • Columns: After you select a metric, the check boxes for the relevant columns are automatically displayed. You can select the columns based on your business needs, and the selected columns are automatically added to the SELECT clause. If a GROUP BY clause exists, these columns are also automatically added to the GROUP BY clause. If you clear the check boxes for one or more columns, the columns are removed from TSQL statements.

TSQL code editor section

The TSQL code editor section provides the following features: TSQL keyword highlighting, real-time syntax check, and auto-completion. These features provide a quick method for you to write TSQL statements and eliminate syntax errors. If a TSQL statement has a syntax error, a red mark appears at the beginning of the corresponding line. To view the syntax error details, you can move the pointer over the line. A syntax error message is also displayed at the bottom of the TSQL code editor section.

Query result display section

After you click Execute in the TSQL code editor section, the corresponding SQL statement is executed. You can view the result in the display section. In the result display section, you can also download the result to a JSON or comma-separated values (CSV) file.Web 4

The exported JSON-formatted data is described as follows:

  1. [
  2. {
  3. "hostname": "host_1",
  4. "rack": "74",
  5. "service_environment": "production",
  6. "os": "Ubuntu16.10",
  7. "serial": "933-676-168",
  8. "service": "17",
  9. "datacenter": "ap-southeast-1a",
  10. "arch": "x64",
  11. "service_version": "0",
  12. "team": "CHI",
  13. "region": "ap-southeast-1",
  14. "timestamp": "2019-03-01 00:00:00.000",
  15. "value": "0.0"
  16. },
  17. {
  18. "hostname": "host_1",
  19. "rack": "74",
  20. "service_environment": "production",
  21. "os": "Ubuntu16.10",
  22. "serial": "933-676-168",
  23. "service": "17",
  24. "datacenter": "ap-southeast-1a",
  25. "arch": "x64",
  26. "service_version": "0",
  27. "team": "CHI",
  28. "region": "ap-southeast-1",
  29. "timestamp": "2019-03-01 00:00:10.000",
  30. "value": "100.0"
  31. }
  32. ...
  33. ]