New line in mustache template for destination

#1

hey,

Can anyone help me out on how to give newline delimiter using mustache template in the destination block?

Eg:

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

  • Trigger: {{ctx.trigger.name}}
  • Severity: {{ctx.trigger.severity}}
  • Period start: {{ctx.periodStart}}
  • Period end: {{ctx.periodEnd}}

Unhealthy Nodes:
{{#ctx.results.0.aggregations.hosts.buckets}}Hostname -> {{key}} containers -> {{#dockers.buckets}}{{key}}, {{/dockers.buckets}}{{/ctx.results.0.aggregations.hosts.buckets}}

current output:

Monitor Health check alerts - non kube just entered alert status. Please investigate the issue.

  • Trigger: TEST TRIGGER
  • Severity: 1
  • Period start: 2019-04-18T12:35:53Z
  • Period end: 2019-04-18T12:36:53Z

Unhealthy Nodes:
Hostname -> hostname1 containers -> container name1, Hostname -> hostname2 containers -> container name2,

Desired output:

Monitor Health check alerts - non kube just entered alert status. Please investigate the issue.

  • Trigger: TEST TRIGGER
  • Severity: 1
  • Period start: 2019-04-18T12:35:53Z
  • Period end: 2019-04-18T12:36:53Z

Unhealthy Nodes:
Hostname -> hostname1 containers -> container name1,
Hostname -> hostname2 containers -> container name2,

Thanks,
Nishant

#2

Hi Nishant,

Can you try formatting this part from:

to

{{#ctx.results.0.aggregations.hosts.buckets}}
Hostname -> {{key}} containers -> {{#dockers.buckets}}{{key}}, {{/dockers.buckets}}{{/ctx.results.0.aggregations.hosts.buckets}}

#3

Hello.
This is a HTML document. So you can use <.br>(without dot) to split lines.
In your case
{{#ctx.results.0.aggregations.hosts.buckets}}Hostname -> {{key}} containers -> {{#dockers.buckets}}{{key}}, {{/dockers.buckets}}<.br>{{/ctx.results.0.aggregations.hosts.buckets}}
Remove dot before br.

1 Like