connr
April 14, 2017, 1:28pm
1
Is there a way to have two different aggregates in a group by. Basically what I am looking to do is take the mean across a group by time statement and then sum up across the other tags. For an example.
Lets say I have a metric http.requests.count
that has a tag of host
. I want to take the mean across the group by time()
statement and then sum up the count for the hosts per time interval as well.
Basically something like
select sum("time_avg") from (select mean(count) as "time_avg" where time > now() - 12h group by time(1m), host) group by time(1m)
I realize that I can prob do it with a CQ, but was hoping there was a more adhoc way
connr
May 23, 2017, 2:20pm
2
Anyone have any ideas on how to achieve this. Based on a few of the links I found it doesn’t seem possible yet
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/influxdb/uXdYy9JA6_E/cZRzQo7FBAAJ
opened 10:48PM - 07 Mar 16 UTC
area/functions
kind/feature-request
1.x
This issue contains a list of related feature requests that are not on the near-… term roadmap. The feature requests in this issue are all new functions that have been requested. If you want to request a function not already listed please make a comment on this issue, and we will add it to the checklist.
#### Aggregations
- [x] moving averages function: https://github.com/influxdata/influxdb/issues/77
- [ ] histogram https://github.com/influxdata/influxdb/issues/3674
- [x] cumulative counts https://github.com/influxdata/influxdb/issues/813
- [ ] HDR histogram https://github.com/influxdata/influxdb/issues/739
- [ ] histogram with log-scaled buckets https://github.com/influxdata/influxdb/issues/984
- [ ] time weighted aggregations https://github.com/influxdata/influxdb/issues/7445
- [ ] logarithmic mean https://github.com/influxdata/influxdb/issues/2482
- [x] integrals https://github.com/influxdata/influxdb/issues/1400
- [ ] cumulative distribution function: https://github.com/influxdata/influxdb/issues/7261
#### Selectors
- [ ] faster, slightly less accurate percentages calculation https://github.com/influxdata/influxdb/issues/513
- [ ] lag variables https://github.com/influxdata/influxdb/issues/142
- [ ] lead variables https://github.com/influxdata/influxdb/issues/143
- [ ] upper bound, lower bound https://github.com/influxdata/influxdb/issues/659
- [ ] average "gauges" with awareness of time spent in state https://github.com/influxdata/influxdb/issues/1115
- [x] mode https://github.com/influxdata/influxdb/issues/1823
#### Transformations
- [x] trigonometric functions (sine, cosine, etc.) https://github.com/influxdata/influxdb/issues/659
- [ ] hyperloglog https://github.com/influxdata/influxdb/issues/717
- [x] dot-product https://github.com/influxdata/influxdb/issues/5095
#### Operators
- [x] difference https://github.com/influxdata/influxdb/issues/1825
- [x] elapsed time between events https://github.com/influxdata/influxdb/issues/1856
- [x] exponents and logarithms https://github.com/influxdata/influxdb/issues/659
- [x] ceiling and floor functions https://github.com/influxdata/influxdb/issues/3691
- [ ] trend operators: linear and least square https://github.com/influxdata/influxdb/issues/5358
- [x] DIFFERENCE of two fields https://github.com/influxdata/influxdb/issues/761
#### InfluxQL enhancements
- [x] general support for nested functions https://github.com/influxdata/influxdb/issues/834
- [x] percentile + derivative https://github.com/influxdata/influxdb/issues/5150
- [ ] percentage of values above/below given value (inverse PERCENTILE)
- [x] Top accepts nested functions https://github.com/influxdata/influxdb/issues/2467, https://github.com/influxdata/influxdb/issues/5345
- [x] CAST into different data types https://github.com/influxdata/influxdb/issues/2911
- [ ] `fill(previous)` without GROUP BY https://github.com/influxdata/influxdb/issues/3633
- [ ] User defined functions https://github.com/influxdata/influxdb/issues/6891
- [ ] Boolean type cast https://github.com/influxdata/influxdb/issues/7562
opened 08:59PM - 15 Aug 14 UTC
closed 10:36PM - 18 Mar 16 UTC
area/functions
kind/feature-request
We store our data in InfluxDB such that each individual metric is its own series… , and we insert a hostname value into each update so that we can build out dashboards for clustered services without falling back to regex'd series names, and we keep our series count down.
Some of our metrics are counters that we take a derivative of at search time. When viewing each host individually this works fine, but if I want to roll up those values easily across a set of hostnames that exist in the series, I can't do much other than:
`select derivative(value) from seriesName group by time(30s), hostname;`
and then see independent lines graphed for each hostname in tools like Grafana.
If I could instead query it as follows, aggregate graphs would be much easier and more universally applicable:
`select sum(derivative(value)) from seriesName group by time(30s);`
This seems to be a pretty limiting factor in the influx query language. Both graphite and opentsdb support two aggregations in one query
Which version of the server are you using? Subqueries were added in 1.2 and your query should be possible with that version if I’m understanding it correctly.
@connr Looks like that query is correct and does the described. Are you not getting the desired output.
connr
May 24, 2017, 2:21pm
5
Yeah I get an error when I try to run the query as shown above
select sum("time_avg") from (select mean(count) as "time_avg" from "http.requests.count" where time > now() - 12h group by time(1m), host) group by time(1m)
ERR: error parsing query: aggregate functions with GROUP BY time require a WHERE time clause
@connr Try adding the same WHERE time > now() - 12h
to the outer query. If that doesn’t work then could you please open an issue on InfluxDB ?