Materials for my talks/articles on Python monitoring
- Understanding metrics and monitoring with Python
- Exploring Security, Metrics, and Error-handling with gRPC in Python
- Your options for monitoring multi-process Python applications with Prometheus
- Monitoring Your Synchronous Python Web Applications Using Prometheus
- Monitoring Your Asynchronous Python Web Applications Using Prometheus
Playing with the demos
VM Setup on Windows 10 with Hyper-V
You will need to open a powershell session as Adminstrator and do the following from a clone of the git repository:
C:\> ~\work\github.com\amitsaha\python-monitoring-talk [master ≡]> vagrant up --provider=hyperv Bringing machine 'default' up with 'hyperv' provider... ==> default: Verifying Hyper-V is enabled... ==> default: Importing a Hyper-V instance default: Please choose a switch to attach to your Hyper-V instance. default: If none of these are appropriate, please open the Hyper-V manager default: to create a new virtual switch. default: default: 1) Default Switch default: 2) nat default: 3) minikube-virtualswitch default: default: What switch would you like to use? 1 default: Cloning virtual hard drive... default: Creating and registering the VM... default: Setting VM Integration Services default: Successfully imported a VM with name: ubuntu-18.04-amd64_1 ==> default: Starting the machine... ==> default: Waiting for the machine to report its IP address... default: Timeout: 120 seconds
Then, we will
ssh into the VM using:
C:\> ~\work\github.com\amitsaha\python-monitoring-talk [master ≡]> vagrant ssh
VM Setup on Windows/Linux/OS X - VirtualBox
$ vagrant up ... $ vagrant ssh
Now, that we are in the VM, the
/vagrant directory has a copy of the entire repository from where you
can play with the demos:
$ cd /vagrant $ ls demo1 LICENSE prometheus scripts statsd Vagrantfile demo2 opensource-com-article README.md slides statsd_prometheus
Each demo directory above has a README explaining the instructions of playing with the demo. In general, to access a network port running in the virtual machine, use the following address in your browser:
If it doesn't work, please file an issue with OS + VM details.
Rebuild an image:
$ sudo docker-compose -f docker-compose.yml build
If you see errors such as:
ERROR: for webapp Cannot create container for service webapp: Conflict. The container name "/webapp" is already in use by container "2e452aa1622b053fe33c6fe508ddce3f207e8a8c7446564f86e6f31c2d81466c". You have to remove (or rename) that container to be able to reuse that name.
You can do:
$ sudo docker rm webapp
Make 100 requests with a concurrency of 3:
$ ab -n 100 -c 3 http://localhost:5000/test/
The following resources are some of the ones that I found very useful:
- Prometheus metric types
- How does a prometheus gauge work?
- Why are prometheus histograms cumulative?
- Monitoring batch jobs in Python
- Promtheus monitoring at soundcloud
- Why are Prometheus histograms cumulative?