influxdata / influxdata/kapacitor
Batch task groupBy time and template variable
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
I would like to be able to group by time and a user defined set of tags in template batch tasks.
The goal is to be able to do something like this:
```
var intervall = 5m
var tags = [*]
batch
|query('SELECT MEAN(value) AS avg, MEAN(value_sq) AS avg_sq FROM "test"."autogen"."requests"')
.period(intervall)
.every(intervall)
.align()
.groupBy(time(intervall), tags)
| ...
```
Currently, Kapacitor complains about the `groupBy` in this form. I also tried adding multiple `groupBy`s, which did not help. The last `groupBy` seems to win over previous ones:
```
batch
|query('SELECT MEAN(value) AS avg, MEAN(value_sq) AS avg_sq FROM "test"."autogen"."requests"')
.period(intervall)
.every(intervall)
.align()
.groupBy(time(intervall))
.groupBy(tags)
```
Is there any workaround to achieve the desired behaviour?
Contributor guide
Research direction
Start by tracing how batch task groupBy expressions are parsed and how template variables are resolved. Compare the current handling of time(intervall), user-defined tags, and repeated groupBy calls; done means a batch task can combine the time and tag grouping shown in the issue, with tests covering the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100