-
Notifications
You must be signed in to change notification settings - Fork 302
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 #1193 from Goggin/feat-fields-query
Add fields option to rules to allow for runtime fields and others
- Loading branch information
Showing
7 changed files
with
39 additions
and
3 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
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 |
---|---|---|
|
@@ -45,7 +45,8 @@ | |
'use_count_query': True, | ||
'email': '[email protected]', | ||
'aggregation': {'hours': 2}, | ||
'include': ['comparekey', '@timestamp']} | ||
'include': ['comparekey', '@timestamp'], | ||
'fields': ['test_runtime_field']} | ||
|
||
test_args = mock.Mock() | ||
test_args.config = 'test_config' | ||
|
@@ -275,6 +276,8 @@ def test_load_rules(): | |
assert isinstance(rules['rules'][0]['alert'][0], elastalert.alerts.Alerter) | ||
assert isinstance(rules['rules'][0]['timeframe'], datetime.timedelta) | ||
assert isinstance(rules['run_every'], datetime.timedelta) | ||
assert isinstance(rules['rules'][0]['fields'], list) | ||
assert 'test_runtime_field' in rules['rules'][0]['fields'] | ||
for included_key in ['comparekey', 'testkey', '@timestamp']: | ||
assert included_key in rules['rules'][0]['include'] | ||
|
||
|
@@ -363,7 +366,10 @@ def test_load_disabled_rules(): | |
|
||
|
||
def test_raises_on_missing_config(): | ||
optional_keys = ('aggregation', 'use_count_query', 'query_key', 'compare_key', 'filter', 'include', 'es_host', 'es_port', 'name') | ||
optional_keys = ( | ||
'aggregation', 'use_count_query', 'query_key', 'compare_key', 'filter', 'include', 'es_host', 'es_port', | ||
'name', 'fields' | ||
) | ||
test_rule_copy = copy.deepcopy(test_rule) | ||
for key in list(test_rule_copy.keys()): | ||
test_rule_copy = copy.deepcopy(test_rule) | ||
|