tencent cloud

Database Management
Last updated: 2025-04-30 16:33:26
Database Management
Last updated: 2025-04-30 16:33:26
TencentDB for CTSDB 3.0 is compatible with the InfluxDB OSS V1.7 by default. This chapter will explain the compatibility of CTSDB 3.0 with the InfluxDB OSS V1.7 for creating a database, downloading data, and writing data to the database.

Database Management

A brand-new purchased instance of CTSDB 3.0 has no database, and a database needs to be created manually. Refer to the table below for the semantics of related commands for creating and deleting the database. Among them, ✅ indicates compatibility with InfluxDB, and ❌ indicates incompatibility. For more information, see Sample data.
Command
Function
Compatibility
Semantics
CREATE DATABASE
Create a new database.
Currently, CREATE DATABASE only supports configuring the following parameters, and other parameters are not supported yet. The semantic format is as follows:
CREATE DATABASE <database_name> [WITH [DURATION <duration>[default unlimited]>]]
database_name: Refers to the database name.
DURATION: Refers to the Time To Live (TTL), in which the unit is day, the value adopts non-zero integer, and the parameter is optional. If TTL is not enabled, this parameter is not configured. If TTL is enabled, the data in the database will be automatically deleted after reaching the expiration time. Configure with caution! For example, DURATION 180d means that the data in the database will be automatically deleted after reaching 180 days.
Create a database named test_tsdb1, and the data of the database will be retained permanently: CREATE DATABASE test_tsdb1.
Create a database named test_tsdb2, enable TTL for this database, and set the data retention period to 30 days: CREATE DATABASE test_tsdb2 WITH DURATION 30d.
DROP DATABASE
Delete a database.
The execution semantics are as follows:
DROP DATABASE <database_name>

DROP SERIES
Delete time series data from the database.
-

DROP MEASUREMENT
Delete measurements.
The execution semantics:
DROP MEASUREMENT <measurement_name>
DROP SHARD
Delete data shards.
-
DELETE

Delete data points. One or more data points can be deleted based on time range and query condition.
The execution semantics:
DELETE FROM <measurement_name> WHERE [<tag_key>='<tag_value>'] | [<time interval>]
The following is an example of deleting all data points with timestamps within a certain time range in the measurement type named cpu_load to demonstrate its execution method.
DELETE FROM cpu_load WHERE time >= '2023-05-20T00:00:00Z' AND time < '2023-05-21T00:00:00Z'
CREATE RETENTION POLICY
Create a command for a data retention policy.
-
ALTER RETENTION POLICY
Modify retention policy.
-
DROP RETENTION POLICY
Delete retention policy.
-

Writing Protocol

InfluxDB Line Protocol is a data format used by the InfluxDB database to write data in text form to the InfluxDB database. This protocol uses a comma-separated values (CSV) format, including timestamps, measurement identifiers, tags, and fields. You can use this protocol to write data to an InfluxDB database and retrieve and query data from it.
Protocol
Protocol Description
Compatibility
Format
InfluxDB Line Protocol 
InfluxDB Line Protocol is a text-based data format used to write data points to the InfluxDB database. Each data point is represented by a separate line containing the timestamp, the measurement name, and the values of the tag set and field set.
Each data point is represented by a separate line containing the timestamp, the measurement name, and the values of the tag set and field set.
<measurement>[,<tag_key>=<tag_value>[,<tag_key>=<tag_value>]] <field_key>=<field_value>[,<field_key>=<field_value>] [<timestamp>]
For more information, see the official website InfluxDB line protocol reference.
Prometheus
Prometheus is an open-source monitoring system and time series database for collecting, storing, and querying various types of metric data.
InfluxDB provides an HTTP API endpoint compatible with Prometheus, allowing Prometheus to write its data to InfluxDB.
Enable Prometheus remote read-write API with InfluxDB:
1. Create a target database
1. In an InfluxDB instance, create a database for storage of the data sent from Prometheus by Database Management or referring to Managing Databases.
1. In the following instance, prometheus_test is an example for the database name to CREATE DATABASE "prometheus_test".
2. Add the URL value to the following settings in the Prometheus configuration file:
username, password: the access account and password of the instance respectively.
influxdb_ip: the instance's private IP address.
db: the database name, such as prometheus_test.
remote_write:
- url: "http://influxdb_ip:8086/api/v1/prom/write?db=prometheus_test&u=username&p=password"

remote_read:
- url: "http://influxdb_ip:8086/api/v1/prom/read?db=prometheus_test&u=username&p=password"
For details on how to configure files and parse Prometheus indicators, see Prometheus endpoints support in InfluxDB.

Downloading and Writing the Data

To download and write time series data that complies with the InfluxDB Line Protocol, see Using Database Instances. For more information, see Download and write the data to InfluxDB.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback