After you purchase TSDB for InfluxDB®, you can get started to use its features and benefits. This topic introduces the
influx command-line interface (CLI). The CLI is a lightweight tool that you can use to interact with databases. For more information about how to download and use the CLI, see Command-line interface. By default, the CLI sends requests to the HTTP API endpoints of TSDB for InfluxDB® by using port
3242. This enables direct communication between the CLI and TSDB for InfluxDB®.
After you create a TSDB for InfluxDB® instance in the Alibaba Cloud console, you can read data from or write data to TSDB for InfluxDB®.
You can get started with database storage. TSDB for InfluxDB® stores data based on series. Each series contains a measurement, for example, cpu_load or temperature. Each series has zero or more points, and each point is a measurement value. A point consists of a timestamp, a metric, at least one field key-value pair, and zero or more tag key-value pairs. The timestamp is indicated by
time. The metric is indicated by
measurement, such as cpu_load. The field key-value pair is indicated by
field, such as value=0.64 and temperature=21.2. The tag key-value pair stores metadata and is indicated by
tag, such as host=server01, region=EMEA, and dc=Frankfurt.
measurement is similar in concept to an SQL table. In the SQL table, the timestamp is the primary index,
field are two columns. Indexes are created for the
tag values, but no indexes are created for the
field values. Unlike SQL tables, TSDB for InfluxDB® can store millions of measurements and does not store null values. TSDB for InfluxDB® is schemaless. Therefore, you do not need to pre-define schemas.
Clients write data to TSDB for InfluxDB® by using a line protocol. The line protocol uses the following format:
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]
The following examples show the valid format that you can use to write data points to TSDB for InfluxDB®:
payment,device=mobile,product=Notepad,method=credit billed=33,licenses=3i 1434067467100293230
temperature,machine=unit42,type=assembly external=25,internal=37 1434067467000000000
Note: For more information about the line protocol, see Line protocol reference .
If you use the CLI to write a point to TSDB for InfluxDB®, enter
INSERT and then enter the information about the point.
> INSERT cpu,host=serverA,region=us_west value=0.64
The preceding example writes the specified point to TSDB for InfluxDB®. In the point, the measurement is
cpu, the tags are
region, and the
Execute the following statement to query the point that is written to TSDB for InfluxDB®:
> SELECT "host", "region", "value" FROM "cpu"
> name: cpu
time host region value
2015-10-21T19:28:07.580664347Z serverA us_west 0.64
Note: In the preceding example, the point does not contain a timestamp. TSDB for InfluxDB® assigns the local current time as the timestamp to the point when you query the point. Therefore, if you query a point that does not a timestamp, the returned timestamp for the point is different from the actual timestamp.
The following example writes the point that includes one measurement and two fields. The data type of the point is different from that in the preceding example.
> INSERT temperature,machine=unit42,type=assembly external=25,internal=37
If you want to query all fields and tags, use an asterisk (
*) operator in a query statement.
> SELECT * FROM "temperature"
time external internal machine type
2015-10-21T19:28:08.385013942Z 25 37 unit42 assembly
Note: If you do not specify
LIMITclauses and use asterisk (
*) operators to query data from large databases, performance issues may occur. You can use the
Ctrl+Ckeyboard shortcut to terminate long-running queries.
This topic does not provide the details about certain features of TSDB for InfluxDB®, such as support for Go regular expressions. The examples of Go regular expressions are provided as follows:
> SELECT * FROM /.*/ LIMIT 1
> SELECT * FROM "cpu_load_short"
> SELECT * FROM "cpu_load_short" WHERE "value" > 0.9
This quick start guide explains the steps you must take to get started with TSDB for InfluxDB®. Now you can write data to TSDB for InfluxDB® and query data from TSDB for InfluxDB®. For more information about how to write data to TSDB for InfluxDB® and query data from TSDB for InfluxDB®, see Use the HTTP API to write data and Use the HTTP API to query data . For more information about the concepts of TSDB for InfluxDB®, see Key concepts.
InfluxDB® is a trademark registered by InfluxData, which is not affiliated with, and does not endorse, TSDB for InfluxDB®.