Regular expressions in functions

I’m using InfluxDB 1.8 and was pleased to find regular expressions to work in derivative() calls. So now I can keep both counters and gauges in the same measurement (and use them together in queries).
I can do derivative(/counter_.* / ) just fine, but how do I for example get the mean() of the rest? I was thinking of this for a continuous query. Do I have to rename my other metrics so I can mean(/gauge_.*/) ?


Hello @rvdheij,
Can you please describe what you mean by mean() of the rest? What’s the rest?
Thank you :slight_smile:

Hi @Anaisdg
Some of my metrics are counter-type (like usage data) and some are gauges (like current memory usage). When I want to aggregate the 1-min samples into hourly or daily values, I think I need to compute the derivate over the counters and the mean or average of the other metrics. I rather not code the individual metrics.

What I was looking for is the complement or negate of the field selection by regular expression. It does not seem to exist in golang regex.

But it looks like I would run into another issue when this would have worked, since InfluxDB thinks I am mixing aggregate and non-aggregate. For example like this:

select derivative(/^cal.*/),/^sys.*/ from zvm_sytusr

Since derivative() produces output for each measurement, it’s not really an aggregate and I’m not even sure it’s right to complain… I will go and try to use two separate queries and make sure to name the fields such that I can select them by regex to avoid the issues.