elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

create_index config attribute ignored if config.yaml is present

Open Salaander opened this issue 7 years ago • 2 comments

I will create a pull request to fix this issue, if there is a config attribute passed to the create_index.py but there is a config.yaml in the folder, the config argument is ignored and the config.yaml is used.

The problem is located here:

if os.path.isfile(args.config):
   filename = args.config
elif os.path.isfile('config.yaml'):
   filename = 'config.yaml'
else:
   filename = ''

should be:

if os.path.isfile(args.config):
   filename = args.config
else:
   filename = ''

Since the default value for the config variable is already config.yaml is nothing else is specified.

Would somebody confirm this is not intended?

Salaander avatar Jan 28 '19 10:01 Salaander

The actual code is the other way round:

    if os.path.isfile('config.yaml'):
        filename = 'config.yaml'
    elif os.path.isfile(args.config):
        filename = args.config
    else:
        filename = ''

Which only encourages the needs for this to be updated since the --config option doesn't currently let you override the config file that is used.

pdscopes avatar Jan 29 '19 14:01 pdscopes

Ohh yeah, that was already a version that I fixed, but later I realized that I can just delete one of the clauses and I got mixed up. I will submit the PR than. Thanks for the confirmation.

Salaander avatar Jan 29 '19 14:01 Salaander