0
votes

Assume a DB with the following data records:

2018-04-12T00:00:00Z value=1000 [series=distance]
2018-04-12T00:00:00Z value=10   [series=signal_quality]
2018-04-12T00:01:00Z value=1100 [series=distance]
2018-04-12T00:01:00Z value=0    [series=signal_quality]

There is one field called value. Square brackets denote the tags (further tags omitted). As you can see, the data is captured in different data records instead of using multiple fields on the same record.

Given the above structure, how can I query the time series of distances, filtered by signal quality? The goal is to only get distance data points back when the signal quality is above a fixed threshold (e.g. 5).

1
This can hardly be done as InfluxDB doesn't have joins. It might be possible with kapacitor, but that's another story. It would be much easier to add signal_quality_value field to distance series.Yuri Lachin

1 Answers

2
votes

"Given the above structure", there's no way to do it in plain InfluxDB.

Please keep in mind - Influx is NONE of a relational DB, it's different, despite query language looks familiar.

Again, given that structure - you can proceed with Kapacitor, as it was already mentioned.

But I strongly suggest you to rethink the structure, if it is possible, if you're able to control the way the metrics are collected.

If that is not an option - here's the way: spin a simple job in Kapacitor that will just join the two points into one basing on time (check this out for how), and then drop it into new measurement.

The data point would look like this, then:

DistanceQualityTogether,tag1=if,tag2=you,tag2=need,tag4=em distance=1000,signal_quality=10 2018-04-12T00:00:00Z

The rest is oblivious with such a measurement.

But again, if you can configure your metrics to be sent like this - better do it.