Updated on 2024-12-10 GMT+08:00

OpenTSDB Development Plan

This topic describes the application development in a typical scenario, helping you quickly learn and master the OpenTSDB development process and know key functions.

Scenario Description

Assume that a user develops an application to record and query the weather information of a city. Table 1, Table 2, and Table 3 describe the recorded data.

Table 1 Raw data

City

District

Time

Temperature

Humidity

Shenzhen

Longgang

2017/7/1 00:00:00

28

54

Shenzhen

Longgang

2017/7/1 01:00:00

27

53

Shenzhen

Longgang

2017/7/1 02:00:00

27

52

Shenzhen

Longgang

2017/7/1 03:00:00

27

51

Shenzhen

Longgang

2017/7/1 04:00:00

27

50

Shenzhen

Longgang

2017/7/1 05:00:00

27

49

Shenzhen

Longgang

2017/7/1 06:00:00

27

48

Shenzhen

Longgang

2017/7/1 07:00:00

27

46

Shenzhen

Longgang

2017/7/1 08:00:00

29

46

Shenzhen

Longgang

2017/7/1 09:00:00

30

48

Shenzhen

Longgang

2017/7/1 10:00:00

32

48

Shenzhen

Longgang

2017/7/1 11:00:00

32

49

Shenzhen

Longgang

2017/7/1 12:00:00

33

49

Shenzhen

Longgang

2017/7/1 13:00:00

33

50

Shenzhen

Longgang

2017/7/1 14:00:00

32

50

Shenzhen

Longgang

2017/7/1 15:00:00

32

50

Shenzhen

Longgang

2017/7/1 16:00:00

31

51

Shenzhen

Longgang

2017/7/1 17:00:00

30

51

Shenzhen

Longgang

2017/7/1 18:00:00

30

51

Shenzhen

Longgang

2017/7/1 19:00:00

29

51

Shenzhen

Longgang

2017/7/1 20:00:00

29

52

Shenzhen

Longgang

2017/7/1 21:00:00

29

53

Shenzhen

Longgang

2017/7/1 22:00:00

28

54

Shenzhen

Longgang

2017/7/1 23:00:00

28

54

In this scenario, the temperature and humidity data of the Longgang district, Shenzhen, is recorded at 00:00 on July 1, 2017. OpenTSDB uses two groups of data points for modeling.

Table 2 Metric data point 1

Metric

City

District

Unix timestamp

Value

city.temp

Shenzhen

Longgang

1498838400

28

city.temp

Shenzhen

Longgang

1498842000

27

city.temp

Shenzhen

Longgang

1498845600

27

city.temp

Shenzhen

Longgang

1498849200

27

city.temp

Shenzhen

Longgang

1498852800

27

city.temp

Shenzhen

Longgang

1498856400

27

city.temp

Shenzhen

Longgang

1498860000

27

city.temp

Shenzhen

Longgang

1498863600

27

city.temp

Shenzhen

Longgang

1498867200

29

city.temp

Shenzhen

Longgang

1498870800

30

city.temp

Shenzhen

Longgang

1498874400

32

city.temp

Shenzhen

Longgang

1498878000

32

city.temp

Shenzhen

Longgang

1498881600

33

city.temp

Shenzhen

Longgang

1498885200

33

city.temp

Shenzhen

Longgang

1498888800

32

city.temp

Shenzhen

Longgang

1498892400

32

city.temp

Shenzhen

Longgang

1498896000

31

city.temp

Shenzhen

Longgang

1498899600

30

city.temp

Shenzhen

Longgang

1498903200

30

city.temp

Shenzhen

Longgang

1498906800

29

city.temp

Shenzhen

Longgang

1498910400

29

city.temp

Shenzhen

Longgang

1498914000

29

city.temp

Shenzhen

Longgang

1498917600

28

city.temp

Shenzhen

Longgang

1498921200

28

Table 3 Metric data point 2

Metric

City

District

Unix timestamp

Value

city.hum

Shenzhen

Longgang

1498838400

54

city.hum

Shenzhen

Longgang

1498842000

53

city.hum

Shenzhen

Longgang

1498845600

52

city.hum

Shenzhen

Longgang

1498849200

51

city.hum

Shenzhen

Longgang

1498852800

50

city.hum

Shenzhen

Longgang

1498856400

49

city.hum

Shenzhen

Longgang

1498860000

48

city.hum

Shenzhen

Longgang

1498863600

46

city.hum

Shenzhen

Longgang

1498867200

46

city.hum

Shenzhen

Longgang

1498870800

48

city.hum

Shenzhen

Longgang

1498874400

48

city.hum

Shenzhen

Longgang

1498878000

49

city.hum

Shenzhen

Longgang

1498881600

49

city.hum

Shenzhen

Longgang

1498885200

50

city.hum

Shenzhen

Longgang

1498888800

50

city.hum

Shenzhen

Longgang

1498892400

50

city.hum

Shenzhen

Longgang

1498896000

51

city.hum

Shenzhen

Longgang

1498899600

51

city.hum

Shenzhen

Longgang

1498903200

51

city.hum

Shenzhen

Longgang

1498906800

51

city.hum

Shenzhen

Longgang

1498910400

52

city.hum

Shenzhen

Longgang

1498914000

53

city.hum

Shenzhen

Longgang

1498917600

54

city.hum

Shenzhen

Longgang

1498921200

54

Each group of metric data points has two tags:

  • Tags: City and District
  • Tag values: ShenZhen and Longgang

You can perform the following operations on data:

  • Obtain the daily monitored data and write data points of the two groups to the database through the put API of OpenTSDB.
  • Use the query API of OpenTSDB to query and analyze the existing data.

Function Description

Determine functions to be developed based on the preceding scenario. Table 4 describes functions to be developed.

Table 4 Functions to be developed in OpenTSDB

No.

Step

Code Implementation

1

Build a data model based on the typical scenario description.

For details, see Configuring OpenTSDB Parameters.

2

Write metric data.

For details, see Writing Data into OpenTSDB.

3

Query data based on metrics.

For details, see Querying OpenTSDB Data.

4

Delete data in a specified range.

For details, see Deleting OpenTSDB Data.