I have a set of sensor data in KairosDB. To query the data, the start time and end time is necessary.
Now, my question is how to know the start time and end time of this whole database?
And further, how to know the start time and end time of each metric?
Having basically the same issue wrapping my head around this.
As far as i can tell there is no direct option for this.
As a costly workaround (costly in terms of CPU time spent for this.) it is possible to query the data like
{
"metrics": [
{
"tags": {
"aggr": [
"yourDataPointTags_1"
]
},
"name": "yourMetric_1",
"aggregators": [
{
"name": "first",
"align_sampling": true,
"sampling": {
"value": "1",
"unit": "months"
}
},
{
"name": "last",
"align_sampling": true,
"sampling": {
"value": "1",
"unit": "months"
}
}
]
}
],
"cache_time": 0,
"start_relative": {
"value": "5",
"unit": "years"
}
}
With a query like this you get the first and last datapoint for each month.
So in the result the first entries timestamp is the first datapoint for your sensor data and the last one is the last existing datapoint.
But be aware that this is only a query for the last 5 years. And for kairosDB it is a huge one, because for queries like this all the datapoints are processed.
So basically you are responsible to store the information [begin, end] for each metric.