forked from jertel/elastalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jertel#149 from archfz/envyaml
jertel#110: Replace yaml loader with one that supports env value substitutions.
- Loading branch information
Showing
12 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
import yaml | ||
|
||
|
||
def read_yaml(path): | ||
with open(path) as f: | ||
yamlContent = os.path.expandvars(f.read()) | ||
return yaml.load(yamlContent, Loader=yaml.FullLoader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import mock | ||
import datetime | ||
|
||
from elastalert.config import load_conf | ||
|
||
|
||
def test_config_loads(): | ||
os.environ['ELASTIC_PASS'] = 'password_from_env' | ||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
test_args = mock.Mock() | ||
test_args.config = dir_path + '/example.config.yaml' | ||
test_args.rule = None | ||
test_args.debug = False | ||
test_args.es_debug_trace = None | ||
|
||
conf = load_conf(test_args) | ||
|
||
assert conf['rules_folder'] == '/opt/elastalert/rules' | ||
assert conf['run_every'] == datetime.timedelta(seconds=10) | ||
assert conf['buffer_time'] == datetime.timedelta(minutes=15) | ||
|
||
assert conf['es_host'] == 'elasticsearch' | ||
assert conf['es_port'] == 9200 | ||
|
||
assert conf['es_username'] == 'elastic' | ||
assert conf['es_password'] == 'password_from_env' | ||
|
||
assert conf['writeback_index'] == 'elastalert_status' | ||
assert conf['writeback_alias'] == 'elastalert_alerts' | ||
|
||
assert conf['alert_time_limit'] == datetime.timedelta(days=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules_folder: /opt/elastalert/rules | ||
|
||
run_every: | ||
seconds: 10 | ||
|
||
buffer_time: | ||
minutes: 15 | ||
|
||
es_host: elasticsearch | ||
es_port: 9200 | ||
|
||
es_username: elastic | ||
es_password: $ELASTIC_PASS | ||
|
||
writeback_index: elastalert_status | ||
writeback_alias: elastalert_alerts | ||
|
||
alert_time_limit: | ||
days: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters