Show match info in the alerts

Versions and technical info:

  • OpenSearch: v 2.11.0
  • Browser: Firefox
  • Webhook: Teams

Describe the issue:
Hi everyone,

I’m trying to create some alerts when there are some new documents in an index, I finally could create the alerts, but I’m struggling with the alert message.

My monitors are Per document monitor type and the monitor defining method is Visual editor, I added some querys (all of them find a match in a field called eventName), and for the message in the trigger I’ve got this, which is not working properly:

ALERTS:
{{#ctx.alerts.0}}
  - id:  {{id}}
  - finding_ids: {{finding_ids}}
  - related_doc_ids: {{related_doc_ids}}
  - name: {{name}}
{{/ctx.alerts.0}}
-----------------
RESULTS:
{{#ctx.results.0.hits.hits}}
  - eventName: {{_source.eventName}}
{{/ctx.results.0.hits.hits}}
-----------------
ERROR: {{ctx.error}}

All I want is to see is the query that is activating the monitor, because I’ve got more than one. I mean, I want to see in the message if the eventName that triggered the alert was X or Y.

Thanks in advance.

Here is the solution: Unable to access Documents Fields (Per Document Monitor Alerts) - #2 by HarryPottar

I’ve to use {{#sample_documents}} and {{/sample_documents} to access to the info from the document.