Already have an account? Sign In
This guide has been setup and tested using both the Python 2.7 (64-bit) and Python 3.6 (64-bit) environments. Code samples included can be used inside a basic Python script, or web framework such as Django or Flask. To send logs to logstash through Python you will need the python-logstash-async (version 1.4.1) Python plugin.
Execute the following command using pip:
pip install python-logstash-async
Python’s logging module is used by most third-party libraries and allows you to integrate your log messages with application-specific logs.
The five standard levels of logs aggregated by the Python module include; CRITICAL, ERROR, WARNING, INFO, DEBUG.
- Critical logs let you know that the application is shutting down and can’t recover without a reboot.
- Error logs capture unexpected bugs that can be handled without a reboot, for example, a 503 or 404 error.
- Warnings can show that resources are running low or that suspicious web requests have been identified. Warning logs can be monitored to protect the security of your applications.
- Info is log data that is sent to your ELK Stack that has captured information on your application’s behaviour metrics.
The creation of a single Python script can produce thousands of logs which only increase once migrated to a production environment. Each logging level adds complexity to being able to efficiently report on the development process, as well as increasing the risk of breaking points across the module.
Using the Logit.io platform allows you to centralise all five types of Python logs for the streamlining of monitoring, troubleshooting and debugging in the cloud. Our onboarding has your ELK Stacks ready for analysis of Python logging events in minutes by using our highly available hosted Logstash pipeline for collecting log files.
Using Logit.io you can view all of the five log types for easy analysis with our out of the box Kibana dashboards. Set alerts on errors, warnings and mission-critical Python issues from one centralised dashboard. Logit.io integrates with Opsgenie, Slack, Webhooks and PagerDuty to send notification messages to your Dev teams.
If you need any further assistance with migrating your Python application logs to Logstash we're here to help you get started. Just get in contact with our support team by visiting our dedicated Help Centre or via live chat & we'll be happy to assist.