- Prepare the Environment
- Structure the Application
- Application Configuration
- Views and Web Forms
- Error Management
- Healthcheck and Monitoring
One of the major parts in the application lifecycle is the monitoring. It is providing information how your application is performing, helping you easily to identify and resolve issues. Based on the application monitoring you could gather usage statistics, trigger actions, etc.
What should be monitored?
You have to consider monitoring both the web server and the Flask application.
Web Server Monitoring
- CPU utilization
- Memory usage
- Network traffic
- Disk capacity and usage
- Runtime performance
- Runtime errors and warnings
- Persistence data querying
There lots of monitoring tools that can be used with your Flask Application.
Zabbix is an enterprise open source monitoring solution for networks and applications. It is designed to monitor and track the status of various network services, servers, and other network hardware.
The ELK stack combines Elasticsearch, Logstash and Kibana.
Elasticsearch is a distributed, open source search and analytics engine, designed for horizontal scalability, reliability, and easy management. It combines the speed of search with the power of analytics via a sophisticated, developer-friendly query language covering structured, unstructured, and time-series data.
Logstash is a flexible, open source data collection, enrichment, and transportation pipeline. With connectors to common infrastructure for easy integration, Logstash is designed to efficiently process a growing list of log, event, and unstructured data sources for distribution into a variety of outputs, including Elasticsearch.
Kibana is an open source data visualization platform that allows you to interact with your data through stunning, powerful graphics. From histograms to geomaps, Kibana brings your data to life with visuals that can be combined into custom dashboards that help you share insights from your data far and wide.
Healhcheck is a Flask application that allows developers to implement their own monitoring checks for their applications – persistence storage state, environment information, etc. I have added simple check.py module, which demonstrates how to include Healthcheck in your application. Have a look how to implement custom check functions.
In the next blog post I will describe how to implement internationalization and localization support in your Flask application.
The complete demo application, described in this blog post, can be found here.