I was wondering if Flux for InfluxDB v2.0 (or even TICKscript for Kapacitor) could be used for real-time processing of data for multiple measurements.
As an example, let’s say I have the following 2 data sets (measurements):
Measurement #1: cpu
Measurement #2: gpu
I want to use Flux to query and retrieve all the points (all those 4 lines) from the cpu measurement, then iterate through each of those points one at a time (row by row), checking if there are any points in the gpu measurement that have a matching temperature. If the gpu.temperature matches cpu.temperature, output that point to a new measurement named after the matching temperature value.
> Is this possible using a Flux task?
The first point in the cpu measurement has cpu.temperature = 50. Can we store that 50 value (cpu.temperature value), then send a query to the gpu measurement to return all rows that have gpu.measurement = 50 to a new measurement also named after the value 50?
The next two points in the cpu measurement do not have any matching temperatures with the gpu measurements, so nothing else would be stored.
For the fourth point in the cpu measurement, cpu.temperature = 80 = gpu.temperature (the last point), so it should output that last point to a measurement named 80.
New Measurement #1: 50
New Measurement #2: 80
Another question I have is, let’s say I had the exact same situation and data as above, but now I have an extra field key/value:
Measurement #1 (modified): cpu
> Is there a way I can extract the value from the field key “measurement_to_query” and store it in a variable for use in a query?
This way, if I had multiple gpu measurements (gpu1,gpu2,gpu3), I could specify which measurement to find matching temperatures from.
I am new to using InfluxDB 2 and Flux is not like typical programming languages so I am not sure what I am able to and unable to do. Thanks!