V2/Concepts/Intro to Tag

From Senfi Docs
Jump to: navigation, search

Tag

A tag is an attribute of the sample. It is usually used as a way to identify where is the metrics are taken from (eg. device ID). It is also useful for labelling the data being sent, in order to perform operations on the data later, eg. filtering.

Example

Say you have a smart weighing scale at home. One possible way to represent the time series data for the device is as follows:

Measurement
Smart Weighing Scale
Measurement code
iot_weighingscale_v1
Data
tm_source weight_kg
xxxxxxxxxxxxx 70.1
xxxxxxxxxxxxx 70.4
xxxxxxxxxxxxx 69.4

tm_source represents when the reading was taken. In this case, weight_kg is the metric, and is sent everytime a weight is taken.

This is well and good, but what if there is another person who's using the weighing scale? One way to distinguish them apart is by adding an additional field, or tag, called person:

tm_source person weight_kg
xxxxxxxxxxxxx Sam 70.1
xxxxxxxxxxxxx Susan 55.2
xxxxxxxxxxxxx Sam 70.4

Much better. But what if there are multiple weighing scales in the house? We can tell them apart by adding another tag:

tm_source room person weight_kg
xxxxxxxxxxxxx bathroom Sam 70.1
xxxxxxxxxxxxx kitchen Susan 55.2
xxxxxxxxxxxxx kitchen Sam 70.4

So we end up with a measurement that has 2 tags (room, person) and 1 metric (weight_kg).

A more complete example can be as follows:

tm_source site_id room person weight_kg bodyfat battery_level
xxxxxxxxxxxxx 1547 bathroom Sam 70.1 19.1 99
xxxxxxxxxxxxx 1547 kitchen Susan 55.2 15.3 54
xxxxxxxxxxxxx 1547 kitchen Sam 70.4 19.2 49

This example is admittedly contrived, but it serves as an example of how data can be modelled in Senfi.

What's Next