Search code examples
kibanaelkelastalert

How to use html in elastalert?


I am working with ELK stack and have setup elastalert to monitor kibana-logs. I have created a simple elastalert rule and i am trying to use html inside my rules file but it's not rendering the html in the alert.

This is what my rules file look like :-

es_host: localhost
es_port: 9200
name: New Test Rule
type: frequency
index: logstash-*
num_events: 1
realert:
  minutes: 3
timeframe:
    hours: 4
filter:
- query:
    query_string:
      query: "no"
alert_text_type: alert_text_only
alert_text: "<h5>Test!!!</h5>"
alert:
- command
command: ["/home/ubuntu/elastalert/script.sh"]

If someone knows how to parse html in an alert. I sure can use some assistance. Thank you in advance.


Solution

  • In your configuration, you simply need to specify the email_format setting:

    email_format: html
    

    email_format: If set to html, the email’s MIME type will be set to HTML, and HTML content should correctly render. If you use this, you need to put your own HTML into alert_text and use alert_text_type: alert_text_only.