influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

[0.9.0] Downsampling and tags

Open robinroestenburg opened this issue 11 years ago • 4 comments

Hi,

I have been playing around with the 0.9.0 version today and I have a question about continuous queries and tags.

Say, I have some data points in measurement X with tag 'foo' and value 'bar' and I have some data points in measurement X with tag 'foo' and value 'baz'. If I downsample using a GROUP BY on time only I loose the tags, right?

The only way to preserve that information AFAIK is to create a continuous query like this:

CREATE CONTINUOUS QUERY x_per_10m ON mydb BEGIN
  SELECT count(value) INTO x_10m FROM x GROUP BY time(10m), foo
END

So, every tag I want to preserve needs to be added into the GROUP BY clause.

This makes it difficult to create a downsampling query over multiple measurements that use different tags, because:

  • all tags in use by all measurements need to be specified,
  • new tags are not automatically added (regenerate the continuous query).

Any thoughts on how to make this easier?

robinroestenburg avatar Jun 19 '15 14:06 robinroestenburg

give a try like this; CREATE CONTINUOUS QUERY x_per_10m ON mydb BEGIN SELECT count(value) INTO x_10m FROM x GROUP BY time(10m), * END

eminden avatar Jun 19 '15 14:06 eminden

Works great, thanks @eminden!

robinroestenburg avatar Jun 19 '15 15:06 robinroestenburg

you can add a tag in the origin table,and group by the tag in the continue query shell

chijey avatar May 17 '19 07:05 chijey

@eminden Your solution works great. I was applying downsampling, but it took an aggregate across all tags. If I filtered on, say, hostname = 10.x.x.x, it would return no data, but if I filtered on no tag at all, it worked fine. Thanks for this great solution - always love an easy fix.

pieter2501 avatar Mar 22 '23 15:03 pieter2501