Writing data in an OpenTSDB database
In this section, we will see the data schema of an OpenTSDB database. You will also learn how to write data.
Data schema
The data schema of OpenTSDB is based on the following elements:
- metric: This is a name that is used to identify TSD, for example,
lab.freezer.sensor
,server.cpu.user
, orasset.location
. - timestamp: As its name implies, this is a timestamp in seconds or milliseconds.
- value: This is a numeric value that represents some variable and it’s stored associated with a timestamp. It can be an integer or a floating-point value.
- tags: These are a key-value pair. All the data points must have at least one tag assigned.
Let’s see how metrics and tags work together.
Imagine that you have a fleet of trucks and you want to store data on location, speed, and fuel consumption. Then, you can create the truck.location
, truck.speed
, and truck.fuel
metrics.
But, how do you identify each of the trucks...