influxdata / influxdata/kapacitor
Group by parameters with json configuration file
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hello everyone, i'm trying to group by time and other fields, using a json file, but i can't make it work.
If you do something like this:
```
var now = batch
|query(getdata)
.period(timeframe)
.cron(frequency)
.groupBy('host',time(1m))
.offset(3m)
|shift(3m)
```
it works. But I need to put it in a json file, and apply the groupBy node by parameter... I'm not getting any error. It just does not group data...
This is the template:
```
var getdata string
var timeframe duration
var frequency string
var group list
var warncondition = lambda: FALSE
var warnreset = lambda: FALSE
var now = batch
|query(getdata)
.period(timeframe)
.cron(frequency)
.groupBy(group)
.offset(3m)
|shift(3m)
now
|alert()
.warn(warncondition)
.warnReset(warnreset)
.slack()
```
And my json:
```
{
"getdata": {"type": "string", "value": "SELECT sum(\"Total_request\") AS \"data\" FROM \"global\""},
"timeframe": {"type" : "duration", "value" : "5m"},
"frequency": {"type" : "string", "value" : "* * * * *"},
"group": {"type" : "list", "value" : [{"type":"string", "value":"host"}]},
"warncondition": {"type" : "lambda", "value" : "\"data\" < 1000000"},
"warnreset": {"type" : "lambda", "value" : "\"data\" > 1000000"},
}
```
If I group only by host, it works. But when i try adding time(1m) it doesn't group by anything.
I already tried:
`{"type":"string", "value":"time(1m)"}
`
and
`{"type":"time", "value":"1m"}`
But nothing seems to work.
Can you help me? Thank you!
Contributor guide
Research direction
The reported entry points are the TICKscript `.groupBy(group)` call and the JSON `group` parameter, with `time(1m)` as the failing case. Start by reproducing the configuration behavior and trace how that parameter is interpreted; done means grouping by both host and one-minute time windows works from the JSON configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100