kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

.email() recipient built using variable substitution not working

Open Seiei00 opened this issue 4 years ago • 4 comments

Hello,

I'm building my email recipient by getting a specific tag value and concatenating it in a string but it is not sending an alert.

var email_target = '{{ index .Tags "Product" }}@example.com'

var email_target = '{{ index .Tags "Product" }}' + '@example.com'

Both are not working, but if initialize the variable directly I was able to receive the alert.

var email_target = '[email protected]'

Here is what the alert node looks like:

data |alert() .warn(lambda: "state_duration" >= warn_duration AND "value" != running_threshold) .stateChangesOnly() .message(message) .id(idVar) .idTag(idTag) .levelTag(levelTag) .messageField(messageField) .durationField(durationField) .details(details) .email() .to(email_target)

Is this not supported yet? I'm not seeing any errors as well when this TICK script is deployed.

Seiei00 avatar Sep 08 '20 01:09 Seiei00

This isn't supported yet, sorry.

docmerlin avatar Sep 08 '20 18:09 docmerlin

The same problem exists for the telegram handler, for example. In my case chat id depends on some field but the property method telegram.chatId() can only have a hardcoded parameter. This is a global issue of the tick script syntax - method parameters cannot be really considered like in normal programming languages. This limits tick scripts and encourages to massively use countless copies of tasks just because a difference in a single line.

Please, consider improving the tick syntax. For example it could be implemented keeping backward compatibility using a global templating function which is called by the interpreter before passing a parameter to a method. ... .telegram() .chatId(template('{{ index .Fields "chat_id"}}'))

where 'template()' is a global function which 'preprocesses' its parameter and return a string.

leonty avatar Jul 21 '21 12:07 leonty

Good afternoon all,

Any update on this issue?

I am trying the same !

thiagocorredor avatar Nov 12 '21 16:11 thiagocorredor

This isn't supported yet, sorry.

No ETA about this?

thiagocorredor avatar Nov 12 '21 16:11 thiagocorredor