将动态生成的AdaptiveCard列表中的项目符号格式化为Teams。

huangapple go评论119阅读模式
英文:

Format bullet points in dynamically produced AdaptiveCard list to Teams

问题

以下是您提供的文本的翻译:

我有一个“Watcher”操作,用来向“Teams”频道发送消息。

为了创建一个嵌套的项目符号列表,我在我的AdaptiveCard主体中添加了以下TextBlock:

"body": [
    {
        "type": "TextBlock",
        "text": "发现了以下[事件]({{ 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:!())) 最后 {{ 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"
    }
]

我期望的输出是:

在过去的1小时内发现了以下匹配错误响应的事件:

> - /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)

但实际输出是:

> - /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)

如何解决这个问题?

英文:

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?

答案1

得分: 0

我在错误的地方有一个\\r-,我需要在\\r-周围进行一些空格/制表符的更改。最后得到了以下结果:

在以下位置找到了[事件]({{ 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:!())) 中找到了匹配的错误响应在最后 {{ 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"

英文:

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"

huangapple
  • 本文由 发表于 2023年3月7日 20:28:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定