Prettify Watcher JSON Response

What is the best way to pretty JSON response from Elasticsearch Watch ?

Currently doing webhook to MS Teams,

body": "{ title: 'Server Metrics Alert', text: '{{#toJson}}ctx.payload.hits{{/toJson}}' }",

Everything works, however (as expected) ctx.payload.hits is NOT pretty.

What is the easiest way to prettify that ctx.payload.hits ?

Use a transform in your action to get the data into a proper format first.

The format is fine, just want to prettify the json text.

Do you see anything in transform that can be used to prettify JSON text?

I don't see a way to do this right now, but soon you will be able to use Json.dump() with a prettyfying option in Painless.

See https://github.com/elastic/elasticsearch/pull/63278

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