elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Unable to add content in email body with summary_table_fields

Open sathishdsgithub opened this issue 9 years ago • 4 comments

@Qmando

I'm using the below conditions to alert the email output in summary table field format. In the email output body, I would like to add some content. I tried to add the content next to the alert_text: | but it's not working. Are there any options to add some content in the email body with summary_field?

summary

alert_text_type: alert_text_only

alert_text: |

summary_table_fields:


    - srx-source-address

    - srx-destination-address

    - srx-destination-port

Expected Email body output

capture

sathishdsgithub avatar Aug 06 '17 12:08 sathishdsgithub

alert_text: |

Do you have actual text? You're adding an empty string.

Qmando avatar Aug 07 '17 17:08 Qmando

@Qmando I'm trying to add the test next to alert_text: | as shown below. But it is not working as expected. The text is getting appended at the bottom of the email. Attached Screenshot for reference.

Just an FYI I'm using type: cardinality

alert_text_type: alert_text_only

alert_text: |

   This is a test email

summary_table_fields:


    - srx-source-address

    - srx-destination-address

    - srx-destination-port

capture1

sathishdsgithub avatar Aug 08 '17 07:08 sathishdsgithub

Here's the function where this text is generated: https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py#L239 You could move self.get_aggregation_summary_text(matches) to the end of the function to make the alert_text appear first, though, it will still contain duplicates.

Qmando avatar Aug 08 '17 20:08 Qmando

@Qmando

Thanks for the update. I see that for the summary_table_fields it prints the code line 257 from alerts.py. I would like to know is there any options to put the content of the alert_subject: to the email body?

I have uploaded the screenshot for reference.

 255             # Include a count aggregation so that we can see at a glance how many of each aggregation_key were encountered
 256             summary_table_fields_with_count = summary_table_fields + ['count']
 257             text += "Aggregation resulted in the following data for summary_table_fields ==>{0}:\n\n".format(
 258                 summary_table_fields_with_count
 259             )

email-body

sathishdsgithub avatar Aug 11 '17 16:08 sathishdsgithub