Using environment variables for rules.
Hi. I am trying to implement alerting on elasticsearch using ElastAlert for some of our customers. Right now we have around 6-7 rules configured. I want to know that is it possible that we can use some environment variables or file which can directly make the changes to all the rule files (rule.yaml files) instead of going to each rule file and changing the fields there because changing each rule file every time may result in an accidental error. Can anyone help ?? Thanks in advance.
@prateek1709 what changes your would like to do in rule.yaml ..Can you share some example•
I can provide an example of what would be useful for us. We run ElastAlert rules in multiple environments (i.e. Stage and Prod). We run ElastAlert inside docker. I'd like to be able to set the current environment in an environment variable and then be able to use it in the rules yaml file to set slack_webhook_url and/or alert_subject_args so we can distinguish messages coming from different environments
This can be accomplished in a couple lines in Bash:
$ cat test.yaml
name: $NAME
something: $FOO
$ export NAME="test rule"
$ export FOO="bar"
$ cat test.yaml | envsubst > test2.yaml
$ cat test2.yaml
name: test rule
something: bar
Just run this against all of your rule files before you start elastalert
This is perfect. Thanks!