microsoft-teamsadaptive-cardstext-formattingadaptive-designelasticsearch-watcher

Format bullet points in dynamically produced AdaptiveCard list to Teams


I have a Watcher action to message a Teams channel.

To create a nested bullet list I added the following TextBlock to my AdaptiveCard body:

"body":[
    {
        "type": "TextBlock",
        "text": "Found the following [events]({{ url }}:{{ port }}/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:{{ watcher_config.start_range }},to:{{ watcher_config.end_range }}))&_a=(columns:!(request),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'{{ watcher_index }}',key:query,negate:!f,type:custom,value:'%7B%22bool%22:%7B%22must%22:%5B%7B%22range%22:%7B%22@timestamp%22:%7B%22gte%22:%22{{ watcher_config.start_range }}%22,%22lt%22:%22{{ watcher_config.end_range }}%22%7D%7D%7D,%7B%22bool%22:%7B%22{{ watcher_config.regex_match }}%22:%5B%7B%22regexp%22:%7B%22request%22:%22{{ watcher_config.regex }}%22%7D%7D%5D%7D%7D,%7B%22bool%22:%7B%22must%22:%5B%7B%22range%22:%7B%22response%22:%7B%22gte%22:{{ watcher_config.start_response_status }},%22lt%22:{{ watcher_config.end_response_status }}%7D%7D%7D%5D%7D%7D%5D%7D%7D'),query:(bool:(must:!((range:('@timestamp':(gte:{{ watcher_config.start_range }},lt:{{ watcher_config.end_range }}))),(bool:({{watcher_config.regex_match  }}:!((regexp:(request:'{{ watcher_config.regex }}'))))),(bool:(must:!((range:(response:(gte:{{ watcher_config.start_response_status }},lt:{{ watcher_config.end_response_status }}))))))))))),index:'{{ watcher_index }}',interval:auto,query:(language:kuery,query:''),sort:!())) matching error responses in the last {{ watcher_config.interval }}: \\r - {{ '{{' }}#ctx.payload.aggregations.group_by_kong_route.buckets{{ '}}' }} {{ '{{' }}key{{ '}}' }} ({{ '{{' }}doc_count{{ '}}' }}) {{ '{{' }}#group_by_response_code.buckets{{ '}}' }} \\r    - {{ '{{' }}key{{ '}}' }} ({{ '{{' }}doc_count{{ '}}' }}) \\r {{ '{{' }}/group_by_response_code.buckets{{ '}}' }} \\r{{ '{{' }}/ctx.payload.aggregations.group_by_kong_route.buckets{{ '}}' }} \\r"
    }
]

I expected:

Found the following events matching error responses in the last 1h:

  • /myapp/api/basic (330)
    • 429 (221)
    • 404 (109)
  • /myapp/bike (323)
    • 429 (214)
    • 404 (109)
  • /myapp/rest/build (147)
    • 429 (81)
    • 404 (64)
    • 403 (2)
  • /myapp/bike/532669 (122)
    • 429 (90)
    • 404 (32)
  • /myapp/bike/make (84)
    • 429 (84)

Instead I get this:

  • /myapp/api/basic (330)
    • 429 (221)
    • 404 (109)

/myapp/bike (323)

-429 (214)

-404 (109)

/myapp/rest/build (147)

-429 (81)

-404 (64)

-403 (2)

/myapp/bike/532669 (122)

-429 (90)

-404 (32)

/myapp/bike/make (84)

-429 (84)

How do I resolve this?


Solution

  • I had one \\r- in the wrong place and I had to make some space/tab changes around the \\r's and -'s. This is what I ended up with:

    Found the following [events]({{ url }}:{{ port }}/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:{{ watcher_config.start_range }},to:{{ watcher_config.end_range }}))&_a=(columns:!(request),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'{{ watcher_index }}',key:query,negate:!f,type:custom,value:'%7B%22bool%22:%7B%22must%22:%5B%7B%22range%22:%7B%22@timestamp%22:%7B%22gte%22:%22{{ watcher_config.start_range }}%22,%22lt%22:%22{{ watcher_config.end_range }}%22%7D%7D%7D,%7B%22bool%22:%7B%22{{ watcher_config.regex_match }}%22:%5B%7B%22regexp%22:%7B%22request%22:%22{{ watcher_config.regex }}%22%7D%7D%5D%7D%7D,%7B%22bool%22:%7B%22must%22:%5B%7B%22range%22:%7B%22response%22:%7B%22gte%22:{{ watcher_config.start_response_status }},%22lt%22:{{ watcher_config.end_response_status }}%7D%7D%7D%5D%7D%7D%5D%7D%7D'),query:(bool:(must:!((range:('@timestamp':(gte:{{ watcher_config.start_range }},lt:{{ watcher_config.end_range }}))),(bool:({{watcher_config.regex_match }}:!((regexp:(request:'{{ watcher_config.regex }}'))))),(bool:(must:!((range:(response:(gte:{{ watcher_config.start_response_status }},lt:{{ watcher_config.end_response_status }}))))))))))),index:'{{ watcher_index }}',interval:auto,query:(language:kuery,query:''),sort:!())) matching error responses in the last {{ watcher_config.interval }}:{{ '{{' }}#ctx.payload.aggregations.group_by_kong_route.buckets{{ '}}' }}\r- {{ '{{' }}key{{ '}}' }} ({{ '{{' }}doc_count{{ '}}' }}) {{ '{{' }}#group_by_response_code.buckets{{ '}}' }}\r - {{ '{{' }}key{{ '}}' }} ({{ '{{' }}doc_count{{ '}}' }}) \r {{ '{{' }}/group_by_response_code.buckets{{ '}}' }}\r{{ '{{' }}/ctx.payload.aggregations.group_by_kong_route.buckets{{ '}}' }}\r"