Skip to content

Commit

Permalink
Fixed path error for create index runner and Kibana parameter source. (
Browse files Browse the repository at this point in the history
  • Loading branch information
cdahlqvist authored Sep 12, 2018
1 parent 7c88cdb commit aa3f097
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion eventdata/parameter_sources/elasticlogs_kibana_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def __init__(self, track, params, **kwargs):
if params['query_string'] in gs.global_config.keys():
self._query_string_list = gs.global_config[params['query_string']]
else:
self._query_string_list = json.loads(open(os.path.expandvars(params['query_string']), 'rt', encoding="utf-8").read())
cwd = os.path.dirname(__file__)
self._query_string_list = json.loads(open(os.path.join(cwd, "..", params['query_string']), 'rt', encoding="utf-8").read())
gs.global_config[params['query_string']] = self._query_string_list
else:
self._query_string_list = params['query_string']
Expand Down
13 changes: 7 additions & 6 deletions eventdata/runners/createindex_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ def createindex(es, params):
"""
if 'index_template_body' in params:
if 'index_template_name' in params:
template_name = params['index_template_name']
template_name = params['index_template_name']
else:
template_name = 'elasticlogs'
template_name = 'elasticlogs'

if 'mappings' in params['index_template_body'] and isinstance(params['index_template_body']['mappings'], str):
if params['index_template_body']['mappings'] in gs.global_config.keys():
mapping = gs.global_config[params['index_template_body']['mappings']]
else:
mapping_path = os.path.expandvars(params['index_template_body']['mappings'])
cwd = os.path.dirname(__file__)
mapping_path = os.path.join(cwd, "..", params['index_template_body']['mappings'])
logger.info("[createindex] Use mapping file: %s", mapping_path)
mapping = json.loads(open(mapping_path, 'rt', encoding="utf-8").read())
gs.global_config[params['index_template_body']['mappings']] = mapping
Expand All @@ -41,8 +42,8 @@ def createindex(es, params):
es.indices.put_template(name=template_name, body=params['index_template_body'])

if 'alias' in params:
b = { 'aliases': {} }
b['aliases'][params['alias']] = {}
b = { 'aliases': {} }
b['aliases'][params['alias']] = {}
else:
b = { 'aliases': { 'elasticlogs_write': {} } }

Expand All @@ -57,4 +58,4 @@ def createindex(es, params):
es.indices.create(index=index_name, body=b, ignore=400)

return 1, "ops"

0 comments on commit aa3f097

Please sign in to comment.