elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

alert_text adds additional new line at the end

Open volym3ad opened this issue 9 years ago • 3 comments

When alerting rule to HipChat room, new line is pasted at the end. github-question How to get rid of it? Is this caused by the link at the end of statement?

P.S. alert_text: "{0}: At least {1} events occurred for host {2} link"

volym3ad avatar Jul 11 '17 09:07 volym3ad

seems this is caused due to _ensure_new_line method in alerts.py
https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py#L49
but I don't understand why it is needed to call it here - https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py#L134
In this case if alert_text_only message consists of one row - it adds empty new line after body message.

volym3ad avatar Jul 11 '17 13:07 volym3ad

This is one of those things that makes sense for some alerters but not for others. I'd probably like to see the newline kept in the generic alert text generator, but have each alerter strip it off if necessary. Hipchat, Slack, Pagerduty, others, seem like good candidates. I'm willing to take a PR on this, otherwise it's not very high priority.

Qmando avatar Jul 11 '17 17:07 Qmando

@Qmando

I also observe multiple new lines at the end of my email output. I'm using summary_table_fields for alert_text: output . Are there any options to ignore these new lines in my email output?

alert_text_type: alert_text_only
alert_text: |

summary_table_fields:


    - field 1
    - field 2

sathishdsgithub avatar Jul 21 '17 09:07 sathishdsgithub