All Products
Search
Document Center

Quick start

Last Updated: Sep 04, 2020

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®.

Note: You can also send native HTTP requests to TSDB for InfluxDB®. For more information, see curl command examples in Use the HTTP API to write data and Use the HTTP API to query data.

Data reads and writes

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.

A measurement is similar in concept to an SQL table. In the SQL table, the timestamp is the primary index, tag and 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:

  1. <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®:

  1. cpu,host=serverA,region=us_west value=0.64
  2. payment,device=mobile,product=Notepad,method=credit billed=33,licenses=3i 1434067467100293230
  3. stock,symbol=AAPL bid=127.46,ask=127.48
  4. 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.

  1. > INSERT cpu,host=serverA,region=us_west value=0.64
  2. >

The preceding example writes the specified point to TSDB for InfluxDB®. In the point, the measurement is cpu, the tags are host and region, and the value is 0.64.

Execute the following statement to query the point that is written to TSDB for InfluxDB®:

  1. > SELECT "host", "region", "value" FROM "cpu"
  2. > name: cpu
  3. ------------
  4. time host region value
  5. 2015-10-21T19:28:07.580664347Z serverA us_west 0.64
  6. >

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.

  1. > INSERT temperature,machine=unit42,type=assembly external=25,internal=37
  2. >

If you want to query all fields and tags, use an asterisk (*) operator in a query statement.

  1. > SELECT * FROM "temperature"
  2. name: temperature
  3. -----------------
  4. time external internal machine type
  5. 2015-10-21T19:28:08.385013942Z 25 37 unit42 assembly
  6. >

Note: If you do not specify LIMIT clauses and use asterisk (*) operators to query data from large databases, performance issues may occur. You can use the Ctrl+C keyboard 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:

  1. > SELECT * FROM /.*/ LIMIT 1
  2. --
  3. > SELECT * FROM "cpu_load_short"
  4. --
  5. > 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®.