Continuous Queries - different math operations and specifying topic instead of measurement

The typical CQ I’m familiar with looks like this:

BEGIN
SELECT mean(“value”) AS value
INTO “new_RP”.“new_measurement”
FROM “old_RP”.“old_measurement”
group by time(1m), topic
FILL(previous)
END

I’d like to ask how to do two things:

  1. What are all the options for math downsampling? Can I use mean, max, min, and what else? Can I specify if the value is different from previous value by X amount? So for temperature, I don’t want average, I want to capture if the values are changed from the previous value by a certain amount.

  2. What if I don’t want all topics within that measurement, only specific topics?

Thanks!

Hello @jason2,
I think if you’re looking to perform more sophisticated downsampling tasks, I might recommend that you use Flux and 2.x instead.

  1. With 1.x and CQ you’re limited to:
    InfluxQL functions | InfluxDB OSS 1.8 Documentation
    But with Flux you can use so many more:
    Flux standard library | Flux 0.x Documentation

You can do things like:

  • manipulate timestamps
  • math across measurements
  • work with geotemporal data
  • push and pull data form other data sources
  • and more.
  1. What do you mean by topics? Do you mean tags? If so you can use the Where by. clause with influxql if you still want to perform CQs.

Please let me know if this helps or if I can supply any additional information.

1 Like