influxdata / influxdata/kapacitor
combining groupBy in tickscript
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi,
I have a script like following
```
batch
|query('SELECT sum("value") FROM "app"."autogen"."measurement" WHERE ' +
'product = \'' + product + '\'')
.every(1m)
.offset(5m)
.period(1m)
.groupBy('event_type')
.align()
.fill('none')
|alert()
.warn(lambda: 0 < 1)
.message(message + ' {{.Group}}')
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.log('/var/lib/kapacitor/logs/alerts.log')
```
It calls `alert` node for every unique `event_type` as given in documentation. But I want to combine it somehow. for me `event_type` has types like 404, 400, 401, total_request etc (these are variable) and i want to find percentage of 404, 400, 401 and then say
`if percentage(404) > x and percentage(400) < y and percentage(401) > 0` then push something to influxdb different measure. (percentage(x) = sum(x)/total_requests*100)
And in order to do this i need to have access to all those `sum('value')` of all event_types in the same node at same time so that can use it in my usecase. One way i found was to get all data without groupBy and then find different sums on kapacitor side. but it ends up retrieving 100k+ values which is waste.
So what would be other way of doing it ?
Thanks !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the query(...).groupBy('event_type').alert() chain shown in the issue and review the Kapacitor documentation for grouping and aggregation behavior. Determine whether a supported approach can combine event_type groups without retrieving raw values; done would be a validated solution or a clearly documented limitation.
Written by the indexing model from the issue text.
Assessment
- Domain
- stream-processing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100