def alert(self, matches):
    body = self.create_alert_body(matches)
    body = self.format_body(body)
    headers = {'content-type': 'application/json'}
    proxies = ({'https': self.slack_proxy} if self.slack_proxy else None)
    payload = {'username': self.slack_username_override, 'parse': self.slack_parse_override, 'text': self.slack_text_string, 'attachments': [{'color': self.slack_msg_color, 'title': self.create_title(matches), 'text': body, 'mrkdwn_in': ['text', 'pretext'], 'fields': []}]}
    if (self.slack_alert_fields != ''):
        payload['attachments'][0]['fields'] = self.populate_fields(matches)
    if (self.slack_icon_url_override != ''):
        payload['icon_url'] = self.slack_icon_url_override
    else:
        payload['icon_emoji'] = self.slack_emoji_override
    if (self.slack_title != ''):
        payload['attachments'][0]['title'] = self.slack_title
    if (self.slack_title_link != ''):
        payload['attachments'][0]['title_link'] = self.slack_title_link
    if self.slack_attach_kibana_discover_url:
        kibana_discover_url = lookup_es_key(matches[0], 'kibana_discover_url')
        if kibana_discover_url:
            payload['attachments'].append({'color': self.slack_kibana_discover_color, 'title': self.slack_kibana_discover_title, 'title_link': kibana_discover_url})
    for url in self.slack_webhook_url:
        for channel_override in self.slack_channel_override:
            try:
                if self.slack_ca_certs:
                    verify = self.slack_ca_certs
                else:
                    verify = (not self.slack_ignore_ssl_errors)
                if self.slack_ignore_ssl_errors:
                    requests.packages.urllib3.disable_warnings()
                payload['channel'] = channel_override
                response = requests.post(url, data=json.dumps(payload, cls=DateTimeEncoder), headers=headers, verify=verify, proxies=proxies, timeout=self.slack_timeout)
                warnings.resetwarnings()
                response.raise_for_status()
            except RequestException as e:
                raise EAException(('Error posting to slack: %s' % e))
    log.info(("Alert '%s' sent to Slack" % self.rule['name']))
def alert(self, matches):
    body = self.create_alert_body(matches)
    body = self.format_body(body)
    headers = {'content-type': 'application/json'}
    proxies = ({'https': self.slack_proxy} if self.slack_proxy else None)
    payload = {'username': self.slack_username_override, 'parse': self.slack_parse_override, 'text': self.slack_text_string, 'attachments': [{'color': self.slack_msg_color, 'title': self.create_title(matches), 'text': body, 'mrkdwn_in': ['text', 'pretext'], 'fields': []}]}
    if (self.slack_alert_fields != ):
        payload['attachments'][0]['fields'] = self.populate_fields(matches)
    if (self.slack_icon_url_override != ):
        payload['icon_url'] = self.slack_icon_url_override
    else:
        payload['icon_emoji'] = self.slack_emoji_override
    if (self.slack_title != ):
        payload['attachments'][0]['title'] = self.slack_title
    if (self.slack_title_link != ):
        payload['attachments'][0]['title_link'] = self.slack_title_link
    if self.slack_attach_kibana_discover_url:
        kibana_discover_url = lookup_es_key(matches[0], 'kibana_discover_url')
        if kibana_discover_url:
            payload['attachments'].append({'color': self.slack_kibana_discover_color, 'title': self.slack_kibana_discover_title, 'title_link': kibana_discover_url})
    for url in self.slack_webhook_url:
        for channel_override in self.slack_channel_override:
            try:
                if self.slack_ca_certs:
                    verify = self.slack_ca_certs
                else:
                    verify = (not self.slack_ignore_ssl_errors)
                if self.slack_ignore_ssl_errors:
                    requests.packages.urllib3.disable_warnings()
                payload['channel'] = channel_override
                response = requests.post(url, data=json.dumps(payload, cls=DateTimeEncoder), headers=headers, verify=verify, proxies=proxies, timeout=self.slack_timeout)
                warnings.resetwarnings()
                response.raise_for_status()
            except RequestException as e:
                raise EAException(('Error posting to slack: %s' % e))
    log.info(("Alert '%s' sent to Slack" % self.rule['name']))