-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging #42
Comments
Hi @519859716 Thank you for sugestions. |
Hi @519859716 again! I found some time and worked over this during the weekend 😉 Done 1 and 2 from issue. I added parsing logs from elastalert and using dedicaded logger for them. So now instead:
will be:
Some logs example:
After level (INFO, ERROR etc.) there is logger type: elastalert-server or elastalert. Please try new version: btw. you can replace Point 4 is about that. I will add possibility to configure it. I don't close this issue becasue 3 and 4 remain to be done. |
I think you should check what the log looks like when an exception occurs as shown below. Below is an example of an error that occurred in elastalert 0.2.4 root@Lab-ELK:/etc/elastalert# python3.8 -m elastalert.elastalert --verbose --rule sshtele.yaml
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/etc/elastalert/elastalert/elastalert.py", line 30, in <module>
from .alerts import DebugAlerter
File "/etc/elastalert/elastalert/alerts.py", line 26, in <module>
from jira.client import JIRA
File "/usr/local/lib/python3.8/dist-packages/jira/__init__.py", line 10, in <module>
from jira.client import Comment # noqa: E402
File "/usr/local/lib/python3.8/dist-packages/jira/client.py", line 225
validate=False, get_server_info=True, async=False, logging=True, max_retries=3, proxies=None,
^
SyntaxError: invalid syntax |
I tried setting the value of slack_timeout to a string instead of a number [CORP\sano@a-ngft53r34ong elastalert2-server]$ docker run -d -p 3030:3030 -p 3333:3333 \
> -v `pwd`/config/elastalert.yaml:/opt/elastalert/config.yaml \
> -v `pwd`/config/elastalert-test.yaml:/opt/elastalert/config-test.yaml \
> -v `pwd`/config/config.json:/opt/elastalert-server/config/config.json \
> -v `pwd`/rules:/opt/elastalert/rules \
> -v `pwd`/rule_templates:/opt/elastalert/rule_templates \
> --net="host" \
> --name elastalert2-server karql/elastalert2-server:latest
WARNING: Published ports are discarded when using host network mode
af4e306b5095972305ef36420d43392e9cd9af61fdc661f68caedacf100df11b
[CORP\sano@a-ngft53r34ong elastalert2-server]$ docker logs -f elastalert2-server
> elastalert2-server@5.0.0-next.2 start /opt/elastalert-server
> sh ./scripts/start.sh
04:05:57.244Z INFO elastalert-server: Config: No config.dev.json file was found in /opt/elastalert-server/config/config.dev.json.
04:05:57.246Z INFO elastalert-server: Config: A config file was found in /opt/elastalert-server/config/config.json. Using that config.
04:05:57.246Z INFO elastalert-server: Config: Found config file.
04:05:57.262Z INFO elastalert-server: ProcessService: Starting ElastAlert
04:05:57.262Z INFO elastalert-server: ProcessService: Creating index
04:05:58.365Z INFO elastalert: create_index: Reading Elastic 6 index mappings: Reading index mapping 'es_mappings/6/silence.json' Reading index mapping 'es_mappings/6/elastalert_status.json' Reading index mapping 'es_mappings/6/elastalert.json' Reading index mapping 'es_mappings/6/past_elastalert.json' Reading index mapping 'es_mappings/6/elastalert_error.json' Index elastalert_status already exists. Skipping index creation.
04:05:58.365Z INFO elastalert-server: ProcessService: Index create exited with code 0
04:05:58.365Z INFO elastalert-server: ProcessService: Starting elastalert with arguments [none]
04:05:58.373Z INFO elastalert-server: ProcessService: Started Elastalert (PID: 40)
04:05:58.375Z INFO elastalert-server: Server: Server started
04:05:58.376Z INFO elastalert-server: Server: Server listening on port 3030
04:05:58.378Z INFO elastalert-server: Server: Websocket listening on port 3333
04:06:01.062Z WARN elastalert-server:
ProcessService: No matches while process elastalert log: Traceback (most recent call last):
File "/opt/elastalert/elastalert/loaders.py", line 277, in load_options
04:06:01.064Z WARN elastalert-server:
ProcessService: No matches while process elastalert log: self.rule_schema.validate(rule)
File "/usr/lib/python3.9/site-packages/jsonschema-4.3.3-py3.9.egg/jsonschema/validators.py", line 251, in validate
raise error
jsonschema.exceptions.ValidationError: '10' is not of type 'integer'
Failed validating 'type' in schema['properties']['slack_timeout']:
{'type': 'integer'}
On instance['slack_timeout']:
'10'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/elastalert/elastalert/loaders.py", line 162, in load
rule = self.load_configuration(rule_file, conf, args)
File "/opt/elastalert/elastalert/loaders.py", line 224, in load_configuration
self.load_options(rule, conf, filename, args)
File "/opt/elastalert/elastalert/loaders.py", line 279, in load_options
raise EAException("Invalid Rule file: %s\n%s" % (filename, e))
elastalert.util.EAException: Invalid Rule file: rules/a.yaml
'10' is not of type 'integer'
Failed validating 'type' in schema['properties']['slack_timeout']:
{'type': 'integer'}
On instance['slack_timeout']:
'10'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/elastalert/elastalert/elastalert.py", line 2166, in <module>
sys.exit(main(sys.argv[1:]))
File "/opt/elastalert/elastalert/elastalert.py", line 2155, in main
client = ElastAlerter(args)
File "/opt/elastalert/elastalert/elastalert.py", line 128, in __init__
self.rules = self.rules_loader.load(self.conf, self.args)
File "/opt/elastalert/elastalert/loaders.py", line 170, in load
raise EAException('Error loading file %s: %s' % (rule_file, e))
elastalert.util.EAException: Error loading file rules/a.yaml: Invalid Rule file: rules/a.yaml
'10' is not of type 'integer'
Failed validating 'type' in schema['properties']['slack_timeout']:
{'type': 'integer'}
On instance['slack_timeout']:
'10'
04:06:01.242Z ERROR elastalert-server: ProcessService: ElastAlert exited with code 1
04:06:01.242Z INFO elastalert-server: Server: Stopping server
04:06:01.242Z INFO elastalert-server: ProcessService: ElastAlert is not running
04:06:01.243Z INFO elastalert-server: Server: Server stopped. Bye!
[CORP\sano@a-ngft53r34ong elastalert2-server]$ |
The text was updated successfully, but these errors were encountered: