Yelp / elastalert

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

Got an error AttributeError: 'StompConnection11' object has no attribute 'start' with alert type stomp #2731

Open kvskjava opened 4 years ago

kvskjava commented 4 years ago

Hi Team,

I've created a sample rule with alert type as stomp in order to store the alert details into Apache ActiveMQ server.

Initially it showed error to include stomp related properties even though those are all optional(elastalert.util.EAException: Error initiating alert ['stomp']: Missing required option(s): stomp_login, stomp_password, stomp_hostport, stomp_hostname), so I added the required properties in my rule yaml as shown below:

alert:

Now it's showing error as

ERROR:root:Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/elastalert/elastalert.py", line 1440, in alert return self.send_alert(matches, rule, alert_time=alert_time, retried=retried) File "/usr/local/lib/python3.6/site-packages/elastalert/elastalert.py", line 1529, in send_alert alert.alert(matches) File "/usr/local/lib/python3.6/site-packages/elastalert/alerts.py", line 378, in alert conn.start() AttributeError: 'StompConnection11' object has no attribute 'start'

Am I doing anything wrong or missing anything? Kindly help me on it. Any help would be highly appreciated.

nsano-rururu commented 4 years ago

@kvskjava

It looks like the code doesn't work with the current stomp.py. It works if you delete "conn.start()".

https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py#L374

before

        conn.start()
        conn.connect(self.stomp_login, self.stomp_password)
        # Ensures that the CONNECTED frame is received otherwise, the disconnect call will fail.
        time.sleep(1)
        conn.send(self.stomp_destination, json.dumps(fullmessage))
        conn.disconnect()

after

delete 「 conn.start()」

        conn.connect(self.stomp_login, self.stomp_password)
        # Ensures that the CONNECTED frame is received otherwise, the disconnect call will fail.
        time.sleep(1)
        conn.send(self.stomp_destination, json.dumps(fullmessage))
        conn.disconnect()

キャプチャ