Loop throught context (ctx) data model result at action template in SLACK text field

How can loop over array result when integrate with slack using message template?

At kibana monitor to over an array example:

{{#ctx.results.0.hits.hits}} // Loop over hits
   {{_source.message}}
   {{_source.module_name}}
   {{_source.trace_id}}
{{/ctx.results.0.hits.hits}}

That's works, but how can I integrate it with slack message template but the loop at text field?

My attempt:

{
"text":"{{#ctx.results.0.hits.hits}} 
{{_source.message}} 
_service_: {{_source.service}}
_uri_: {{_source.uri}}
{{/ctx.results.0.hits.hits}}"
"channel": "#my-channel-to-alert",
"username": "Monitor Name",
"icon_emoji": ":exploding_head:"
}

I tried it but receive a bad request from action action send message test:

action_results: {,…}
MrJsQXoBG1Y5JW62_aE0: {id: "MrJsQXoBG1Y5JW62_aE0", name: "circuit-breaker-opened-action", output: {}, throttled: false,…}
error: "java.io.IOException: Failed: HttpResponseProxy{HTTP/1.1 400 Bad Request [date: Fri, 25 Jun 2021 16:24:24 GMT, server: Apache, strict-transport-security: max-age=31536000; includeSubDomains; preload, x-slack-backend: r, access-control-allow-origin: *, x-frame-options: SAMEORIGIN, vary: Accept-Encoding, referrer-policy: no-referrer, content-type: text/html, x-envoy-upstream-service-time: 17, x-backend: main_normal main_canary_with_overflow main_control_with_overflow, x-server: slack-www-hhvm-main-iad-17t3, x-via: envoy-www-iad-3oio, haproxy-edge-iad-e6hp, x-slack-shared-secret-outcome: shared-secret, via: envoy-www-iad-3oio, transfer-encoding: chunked] ResponseEntityProxy{[Content-Type: text/html,Chunked: true]}}"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.