elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

elastalert-create-index problem

Open cayirburak opened this issue 7 years ago • 4 comments

Hey , When I enter elastalert-create-index command and after some questions I am getting this error. Please help me.

bitnami@debian:~/elasticsearch-7.0.1$ sudo elastalert-create-index
/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Enter Elasticsearch host: 192.168.73.131
Enter Elasticsearch port: 9200
Use SSL? t/f: f
Enter optional basic-auth username (or leave blank):
Enter optional basic-auth password (or leave blank):
Enter optional Elasticsearch URL prefix (prepends a string to the URL of every request):
New index name? (Default elastalert_status)
New alias name? (Default elastalert_alerts)
Name of existing index to copy? (Default None)
Elastic Version: 7.0.0
Reading Elastic 6 index mappings:
Reading index mapping 'es_mappings/6/silence.json'
Traceback (most recent call last):
  File "/usr/local/bin/elastalert-create-index", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/elastalert/create_index.py", line 265, in main
    create_index_mappings(es_client=es, ea_index=index, recreate=args.recreate, old_ea_index=old_index)
  File "/usr/local/lib/python2.7/dist-packages/elastalert/create_index.py", line 27, in create_index_mappings
    es_index_mappings = read_es_index_mappings() if is_atleastsix(esversion) else read_es_index_mappings(5)
  File "/usr/local/lib/python2.7/dist-packages/elastalert/create_index.py", line 120, in read_es_index_mappings
    'silence': read_es_index_mapping('silence', es_version),
  File "/usr/local/lib/python2.7/dist-packages/elastalert/create_index.py", line 134, in read_es_index_mapping
    return json.load(f)
  File "/usr/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

cayirburak avatar May 12 '19 12:05 cayirburak

I got the same issue, running on ubuntu 18.04 ELK stack 7.0 and elastalert>=0.2.0b

# elastalert-test-rule /etc/elastalert/rule.yml 
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Traceback (most recent call last):
  File "/usr/local/bin/elastalert-test-rule", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/elastalert/test_rule.py", line 441, in main
    test_instance.run_rule_test()
  File "/usr/local/lib/python2.7/dist-packages/elastalert/test_rule.py", line 408, in run_rule_test
    conf = load_conf(args, defaults, overwrites)
  File "/usr/local/lib/python2.7/dist-packages/elastalert/config.py", line 44, in load_conf
    conf = yaml_loader(filename)
  File "/usr/local/lib/python2.7/dist-packages/staticconf/loader.py", line 167, in yaml_loader
    with open(filename) as fh:
TypeError: coercing to Unicode: need string or buffer, NoneType found

lasse-kristensen avatar May 13 '19 10:05 lasse-kristensen

am also facing same error while testing example rules (frequency type) but this not related to elastalert , its more related to python3.

Python version 3.6 elastalert==0.2.1 elasticsearch==7.0.2

can someone please advise which version python3 should be used!!

Thanks in advance!. Screen Shot 2019-08-12 at 11 30 17 PM

prabhuverse avatar Aug 12 '19 18:08 prabhuverse

I got the same issue ???? @prabhur24 @lasse-kristensen These are not at all the same as the original poster. Different command, different error. This was just fixed in master https://github.com/Yelp/elastalert/commit/3affdd7ebf2b6d82c5cfcad0092df97dc27cd8b1

As for the original issue, I'm not sure exactly what the issue is. It's trying to read https://github.com/Yelp/elastalert/blob/master/elastalert/es_mappings/6/silence.json. Can you double check that it exists at /usr/local/lib/python2.7/dist-packages/elastalert/es_mappings/6/silence.json and looks the same as the linked file above?

Qmando avatar Aug 13 '19 17:08 Qmando

@lasse-kristensen | @cayirburak issue is due to --config missed.

updated query and example be like : elastalert-test-rule --config config.yaml example_rules/example_frequency.yaml

You can find more on : https://github.com/Yelp/elastalert/issues/2391

prabhuverse avatar Aug 13 '19 18:08 prabhuverse