Yelp / elastalert

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

Render HTML in elastalert? #3156

Closed paarth1995 closed 3 years ago

paarth1995 commented 3 years ago

I am trying to parse simple HTML in my elastalert and also i am using the command attribute to run an external script which sends an alert to pushover but i am not getting the html in my alert. Here is the rule that is setup :-

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"]

This is what my script.sh looks like :-

#!/bin/bash

if [ "$4" != "" ] &&  [ "$5" != "" ]
then TEXT="\"\`$1\` | \`Timestamp:$3\` | \`Host: $4\` | \`Container:$5\` | $2\""
elif [ "$4" != "" ] && [ "$5" = "" ]
then TEXT="\"\`$1\` | \`Timestamp:$3\` | \`Host: $4\` | $2\""
else TEXT="\"\`$1\` $2\""
fi

echo $1
echo $2

curl -k -s -F "token=mytoken" \
      -F "user=usertoken" \
      -F "title=Elast Alert" \
      -F "priority=1" \
      -F "message=${TEXT}" https://api.pushover.net/1/messages.json