Kibana Alerting Trigger Condition Evaluate a Value

Hi,

How do I store the value from the trigger condition so I can use it in the action section. For example
My trigger condition:

ctx.results[0].hits.total.value/100 > 0

Action Message:

Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.

  • Trigger: {{ctx.trigger.name}}
  • Severity: {{ctx.trigger.severity}}
  • Count: {{ctx.results.0.hits.total.value}}
  • Count Ratio: {{ctx.results.0.hits.total.value/100}}

Preview:
Monitor test just entered alert status. Please investigate the issue.

  • Trigger: test
  • Severity: 1
  • Count: 982
  • Count Ratio:

I would like to get the value of “ctx.results.0.hits.total.value/100” in the message.

[Welcome @sushmamagesh - I’ve moved your question to the Alerting category]

Hi @sushmamagesh,

Unfortunately, arithmetic operations cannot be done within the mustache template as far as I’m aware.

If you were dealing with the per-document fields, one workaround could have been to use script fields and perform the operation through that so you could have access to it in the ctx when defining the Action message. However, I don’t think hits.total.value is available there since it’s a value outside of the document.