sensu-plugins / sensu-plugins-slack

Sensu Slack chat handlers
http://sensu-plugins.io
MIT License
30 stars 54 forks source link

Correction in payload_template example in readme #91

Open colmobrien84 opened 5 years ago

colmobrien84 commented 5 years ago

We had some issues with our implementation of the slack handler with the payload_template option configured. Our template looked like this, very similar to the example in the README : { "attachments": [ { "fallback": "<%= @event["check"]["output"] %>", "color": "<%= color %>", "title": "<%= @event["check"]["name"] %> (<%= @event["client"]["name"] %>)", "text": "<%= @event["check"]["output"].gsub('"', '\\"') %>" } ] }

What we found was that with the above template we were losing messages containing escaped double quotes in the output. Eg. from the CheckPostgresAlive in sensu-plugins-postgres: "output":"CheckPostgres CRITICAL: Error message: FATAL: database \"mon-test\" does not exist\n"

We were able to correct this(i.e. slack alerts now being recieved and displaying as expected) by changing the gsub to read : gsub('"', '\"') ^^^ note one less backslash.

Can you update the readme if I have correctly interpreted this.