Name and ID string template is blank

kapacitor
#1

I’m trying to send alerts to Alerta but I’m getting an error that ‘resource’ and ‘event’ are required fields. I’m using YAMLs for my event handler and task templates.

**My alerta handler:**
id: main-alerta
topic: main
kind: alerta 
options:
  token: 'F_pTpZc0zhMz4C46fmpdv2sRPKQGUBHGXXXXXXXX'
  token-prefix: 'Key'
  resource: '{{ .Name }}'
  event: '{{ .ID }}'
  group: '{{ .Group }}'
  origin: 'kapacitor'

**My task template:**
    template-id: main-mean
    vars:    
      measurement:
        type: string
        value: cpu
      where_filter:
        type: lambda
        value: "\"cpu\" == 'cpu-total'"
      groups:
        type: list
        value:
          - type: string
            value: "host"
      field :
        type: string
        value: usage_idle
      warn :
        type: lambda
        value: "\"mean\" < 30.0"
      crit :
        type: lambda
        value: "\"mean\" < 10.0"
      window :
        type: duration
        value: 1m

**My tick script:**
    dbrp "telegraf"."autogen"

    var measurement string
    var where_filter = lambda: TRUE
    var groups = [*]
    var field string
    var warn lambda
    var crit lambda
    var window = 10s
    
    stream
        |from()
            .measurement(measurement)
            .where(where_filter)
            .groupBy(groups)
        |window()
            .period(window)
            .every(window)
        |mean(field)
        |alert()
             .id('kapacitor/{{ .Name }}/{{ .Group }}')
             .warn(warn)
             .crit(crit)
             .topic('main')

When the alert is triggered, I see in the logs that Alert id is “kapacitor//” so it seems that I couldn’t get the .Name and the .Group substitution.

Please advise.
Thanks

#2

I figured it out. Since I was using Helm Charts to deploy the Kapacitor files, it was substituting the templates with empty string. Solution is to escape the double curly braces in the Kapacitor string templates.