Yelp / elastalert

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

slack alerter uses "slack_webhook_url" and not "slack[slack_webhook_url]" #787

Open Thermi opened 7 years ago

Thermi commented 7 years ago

The slack alerter currently gets the webhook URL in the first layer of the document, instead of from the slack section. This should be changed, as the other alerters get all the other options from their own section. The documentation implies that that should already be the case, but it isn't.

Documentation: https://elastalert.readthedocs.io/en/latest/ruletypes.html#slack

Code:

    def __init__(self, rule):
        super(SlackAlerter, self).__init__(rule)
        **self.slack_webhook_url = self.rule['slack_webhook_url']**
        if isinstance(self.slack_webhook_url, basestring):
            self.slack_webhook_url = [self.slack_webhook_url]
        **self.slack_proxy = self.rule.get('slack_proxy', None)**
[...]

I think self.slack_webhook_url = self.rule['slack_webhook_url'] should be self.slack_webhook_url = self.rule.get('slack_webhook_url').

Thermi commented 7 years ago

Okay, that first part of the issue description was crap. I discovered that actually all alerters get their settings directly from the list of settings in the config.yml file. I got it intuitively wrong. I assumed that the settings were in specific dictionaries below the list. Why was that decision made? And can we have better documentation of that, please? I searched the site elastalert.readthedocs.org, but did not find any part about the configuration file syntax yet. Having a working example would be nice. :/