influxdata / influxdata/kapacitor

Kapacitor Template Tasks - Passing trought JSON groupBy(time(10m))

Open
#1,779 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

Hello,

I'm trying to implement a Kapacitor Template Task to evaluate a simple condition on a "mean" value.
My Template task is configured as follow:

```
// Set Variable
var query string
var period duration
var every duration
var id string
var groupby list
var info lambda
var warn lambda
var crit lambda

batch
|query(query)
.period(period)
.every(every)
.groupBy(groupby)
|alert()
.id(id)
.info(info)
.warn(warn)
.crit(crit)
.message(' {{ .ID }} is {{ .Level }} - Context:{{ index .Tags "host_context" }} - Hostname {{ index .Tags "hostname" }} - Processor Time Usage > treshold ')
.log('/tmp/alert.log')
```

I've some doubts when i need to specify the "GroupBy" parameter inside the JSON file

```
{
"query": { "type": "string", "value": " select mean(\"value\") as \"value\" from \"zabbix\".\"autogen\".\"linux.processor-time\" where metric_type='custom-used'" },
"period": {"type": "duration", "value": "1h"},
"every": {"type": "duration", "value": "1m"},
"id": {"type": "string", "value": "zabbix/processor-time"},
"groupby": {"type": "list", "value": [{"type":"string", "value":"hostname"}, {"type":"?", "value": "???"} ]},
"info": {"type": "lambda", "value": "\"value\" < 20"},
"warn": {"type": "lambda", "value": "\"value\" < 60"},
"crit": {"type": "lambda", "value": "\"value\" < 90"}
}
```

My Question is: How can i configure the GroupBy parameter on JSON config file in order to pass whatever tag_key i want and also a time function? ( ex. time(10m) )

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or entry point is named in the issue. Start by locating the template-task JSON configuration handling and the groupBy parameter parsing, then verify how tag keys and time-based grouping are represented. Done means a documented or tested configuration that supports the requested tag key and time(10m) grouping.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.