Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is proper rule syntax to generate two different alert types? #1135

Closed
branchnetconsulting opened this issue May 31, 2017 · 3 comments
Closed

Comments

@branchnetconsulting
Copy link

I can successfully use this in a rule to send an email:

alert:
- "email"
email:
- "my@email-addr.com"

or this to send a Slack message:

alert:
- "slack"
slack:
slack_webhook_url: "my-slack-webhook"

but how do I specify that I want a rule to do both? Appending the second example above to the first one seems to result in the first one being discarded and only the last one taking affect. I presume I can only have one "alert:" line and then multiple alert types specified thereafter, but my every attempt at this results in rule parsing failures. For example, this fails

alert:
- "email"
email:
- "my@email-addr.com"
- "slack"
slack:
slack_webhook_url: "my-slack-webhook"

with an error "yaml.parser.ParserError: while parsing a block mapping in...expected , but found '-'

Please enlighten me about proper syntax for specifying multiple alert types for my above example.

Thanks!

@pblasquez
Copy link
Contributor

Hi,

You must enumerate your alert methods all within the alert block, like so:

alert:
- "email"
- "slack"

Then you only need your email list:

email:
- "my@email-addr.com"
- "another@email-addr.com"

and your slack options (no need for slack: by itself):

slack_webhook_url: "my-slack-webhook"
slack_username_override: "Elastalert"

@branchnetconsulting
Copy link
Author

Thanks, that worked like a charm!

@musabdogan
Copy link

musabdogan commented Mar 25, 2022

Thanks a lot

One more example:

alert:
- "slack"
- "command"

slack:
slack_webhook_url: "https://hooks.slack.com/services/***/***/***"

command:
command: ["/usr/bin/sh", "/root/musab/elastalert_run.sh"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants