Developer guide

Updated at: 2024-12-04 08:11

This topic describes how to develop applications that use Lindorm Time Series Database (LindormTSDB) to store data.

Procedure

In general, you can perform the following steps to develop an application that uses LindormTSDB.

1. Select an SDK

Lindorm allows you to use a variety of SQL-based methods to develop applications that need to access LindormTSDB.

  • If you use Java to develop applications, you can use LindormTSDB SDK for Java or the JDBC driver for Lindorm. For more information, see Java Native SDK and Java JDBC Driver.

    We recommend that you use LindormTSDB SDK for Java to develop your applications. LindormTSDB SDK for Java allows your applications to access LindormTSDB in an efficient and easy-to-use method and provides various features such as underlying connection management, batch data writing, and error retry mechanism. In addition, the encoding in data transmission is optimized in LindormTSDB SDK for Java for higher data writing efficiency.

  • If you use other programming languages to develop applications, you can use the HTTP-based SQL API of LindormTSDB and the InfluxDB line protocol. For more information, see Use the HTTP-based SQL API of LindormTSDB and Write data by using the InfluxDB line protocol.

    We recommend that you use the InfluxDB line protocol to write data to LindormTSDB and use the HTTP-based SQL API of LindormTSDB to query data.

2. Create data models

Before you create a time series data and table, you must create data models based on your business to determine the tag, time, and value columns in the table. Then, you must determine the primary key of the time series table based on data characteristics and distribute data into different shards. For more information, see Data models.

LindormTSDB provides three types of schema constraint policies: strong constraint, weak constraint, and no constraint. You can select a policy based on your requirements. For more information, see Constraints on the schemas of time series models.

3. Write data to LindormTSDB

You can use multiple methods to write data to Lindorm, such as LindormTSDB SDK for Java, the InfluxDB line protocol, or standard SQL statements. LindormTSDB provides three types of schema constraint policies: strong constraint, weak constraint, and no constraint. If you use LindormTSDB SDK for Java, the InfluxDB line protocol, or API operations that are compatible to Time Series Database (TSDB) to write data to LindormTSDB, you can set the schema constraint policy to weak constraint. In this case, LindormTSDB automatically creates tables in schemaless scenarios. Select a method to write data based on your requirements.

4. Query data in LindormTSDB

LindormTSDB allows you to access time series data by using standard SQL statements. In addition, LindormTSDB optimizes the SQL syntax for time series data and supports features that are specific to time series data, such as data downsampling, data aggregation, and latest value queries.

5. Perform continuous queries

Continuous queries are applicable to big data scenarios. You can create a continuous query to pre-aggregate data that is newly written. This way, the amount of data that is queried in real time is reduced and the query latency is decreased.

6. Perform pre-downsampling

Pre-downsampling is applicable to query data within a long time range. Data is downsampled based on the specified rules when it is written to LindormTSDB. When the downsampled data is queried, the amount of data that is queried is reduced to decrease query latency.

Procedure for the development of applications that use OpenTSDB or TSDB to store data

LindormTSDB is compatible with the API operations of OpenTSDB and TSDB. You can perform the following steps to migrate the database engine used by your application from OpenTSDB or TSDB to LindormTSDB:

  1. Adapt the application for LindormTSDB

    1. Change the endpoint of OpenTSDB or TSDB to the endpoint of LindormTSDB in the application code. For more information about how to obtain the endpoint of LindormTSDB, see Obtain the endpoint.

    2. Modify the application based on the capabilities of LindormTSDB.

      • Applications developed based on HTTP-based API operations: The HTTP-based API operations provided by LindormTSDB are basically compatible with the API operations provided by TSDB. For more information, see HTTP API overview.

      • Java applications developed by using SDKs for TSDB: LindormTSDB is compatible with 90% of the capabilities provided by TSDB. You can directly use your application to access LindormTSDB without modification.

      • Applications that use multi-value models to write data: By default, data is written to the database named default in LindormTSDB. The default schema constraint policy in LindormTSDB is no constraint, which indicates that time series tables are not automatically created in LindormTSDB. To use SQL statements to query data in LindormTSDB, you can manually create time series tables or set the schema constraint policy to weak constraint. LindormTSDB provides SQL-based features that are specific to time series data and optimizes the performance of SQL queries for time series data. We recommend that you use SQL statements to query data in LindormTSDB.

      • Applications that use OpenTSDB or single-value models to write data: The default schema constraint policy in LindormTSDB is no constraint, which indicates that time series tables cannot be automatically created in LindormTSDB. Therefore, these applications cannot use SQL statements to query data in LindormTSDB.

    3. Connect the application to LindormTSDB to perform debugging and testing and then release the application after the application passes all tests.

  2. Migrate application data

    Data in TSDB can be fully migrated to LindormTSDB. For more information, see Migrate all data from TSDB to LindormTSDB.

Procedure for the development of applications that use Prometheus

LindormTSDB supports the remote write and remote read interfaces for remote storage and supports the native PromQL syntaxes for queries. For more information, see Use Prometheus to connect to and use LindormTSDB.

Procedure for the development of applications that use InfluxDB

You can use the InfluxDB line protocol to write data to LindormTSDB. For more information, see Line protocol reference.

  • On this page (1, O)
  • Procedure
  • 1. Select an SDK
  • 2. Create data models
  • 3. Write data to LindormTSDB
  • 4. Query data in LindormTSDB
  • 5. Perform continuous queries
  • 6. Perform pre-downsampling
  • Procedure for the development of applications that use OpenTSDB or TSDB to store data
  • Procedure for the development of applications that use Prometheus
  • Procedure for the development of applications that use InfluxDB
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare