Yelp / elastalert

Easy & Flexible Alerting With ElasticSearch
https://elastalert.readthedocs.org
Apache License 2.0
7.99k stars 1.73k forks source link

Fix UnicodeEncodeError in PagerDutyAlerter #3182

Open katkasian opened 3 years ago

katkasian commented 3 years ago

PagerDutyAlerter class appears to lack handling of non-Latin languages in alert subject / text. Specifically, with Japanese characters HTTP requests fail with the below error:

"UnicodeEncodeError: codec can't encode characters in position 106-125: Body (<redacted>) is not valid Latin-1. Use body.encode(\u0027utf-8\u0027) if you want to send it encoded in UTF-8." ] }'

Tested that specifying encoding as utf-8 on line 1419 of alerts.py resolves the issue.

data=json.dumps(payload, cls=DateTimeEncoder, ensure_ascii=False).encode("utf-8")