Convertig a task to a template in Kapacitor

Hi we are trying to convert a batch task to a template. As a task this batch works flawless. When we converted it to a template we were able to submit the template, create a task just filling some variables BUT in the moment we issue “enable” we received an error complaining there is no function called “every” in our batch.

So, this is weird because when this batch were defined directly in a task it had not problem at all.
So, I am here trying to figure it out what is happening.

Thanks in advance.

Hi @mbribeiro welcome to our community ,

do you see something weird when you do a show task ?

Best regards

Hi, here is the output:

kapacitor show visa_aprovadas_marcelo

ID: visa_aprovadas_marcelo
Error:
Template: cartoes_aprovadas
Type: batch
Status: disabled
Executing: false
Created: 24 Jun 19 10:01 -03
Modified: 24 Jun 19 10:01 -03
LastEnabled: 01 Jan 01 00:00 UTC
Databases Retention Policies: [“cartoes”.“raw”]
TICKscript:
dbrp “cartoes”.“raw”

var card_brand string

var approved_resp_code string

var offset duration

var period duration

var repeat_every duration

var group_by_time duration

var alert_message string

var period_of_time lambda

var period_of_time_reset lambda

batch
|query(‘SELECT sum(“qtd”) AS “aprovadas” FROM “cartoes”.“raw”.“transacoes” WHERE “cartao”=card_brand AND “respcode”=approved_resp_code’)
.offset(offset)
.align()
.period(period)
.every(repeat_every)
.fill(0)
.groupBy(‘cartao’, time(group_by_time))
|eval(lambda: hour(“time”) * 100 + minute(“time”))
.as(‘hour’)
.keep()
|alert()
.id(’{{ index .Tags “cartao” }}/Aprovadas’)
.crit(lambda: period_of_time)
.critReset(lambda: period_of_time_reset)
.message(alert_message)

// .topic(‘monitoramento-cartoes’)

Vars:
Name Type Value
alert_message string {{ index .Tags “cartao” }} - Nenhuma transacao aprovada no(s) ultimo(s) {{ every }} minuto(s)
approved_resp_code string Aprovado
card_brand string VISA
group_by_time duration 1m0s
offset duration 1m0s
period duration 1m0s
period_of_time lambda “aprovadas” == 0 AND (“hour”>= 700 AND “hour” <= 2300)
period_of_time_reset lambda “aprovadas” >= 5 AND (“hour”>= 700 AND “hour” <= 2300)
repeat_every duration 1m0s
DOT:
digraph visa_aprovadas_marcelo {
query1 -> eval2;
eval2 -> alert3;
}
strong text

If I try to enable this test I get:

kapacitor enable visa_aprovadas_marcelo

enabling task visa_aprovadas_marcelo: template: message:1: function “every” not defined