PyCon.de: Observing your applications with Sentry and Prometheus - Patrick Mühlbauer

Tags: pycon, python

(One of my summaries of a talk at the 2017 PyCon.de conference).

Monitoring your applications is important. You can fix problems before they happen. You can quickly pin-point them if they occur anyway. And you should get a good feel for the application through metrics.

There are three ‘pillars of observability’:

  • Logging. Records of individual events that happened.

  • Metrics. Numbers describing a particular process or activity. CPU load, for instance.

  • Tracing. Capture the lifetime of requests as they flow through the various components of a distributed system. (He won’t talk about this).

Error logging

Logging in on a server and searching through logfiles is not much fun. Much better: sentry.

  • It sends notifications for events (mail, slack, etc).

  • It sends them only once. This is important.

  • It aggregates events (statistics, regressions).

  • There are lots of clients for multiple languages (python, javascript, etc.) and platforms (django, flask, angular).

  • It is open source. There is also a software-as-a-service.

He showed the user interface for an error. You see the line in your python code where the error occurred. Traceback. Statistics about browser types, server names, and so on. How often the error occurred already. When it occurred.

It is easy to integrate. He showed it for flask, django and pure python.

Metrics

The tool they use is prometheus. A time series database for system and application metrics. Metrics are things like cpu load and memory consumption.

There are different metric types: counters, gauges, histograms, summaries.

Prometheus normally works by pulling data. There are advantages and disadvantages. There is a push gateway, but they don’t use it.

There’s a python client (prometheus_client). You start its webserver so that prometheus can talk to it. In your code, you can configure the things you want to measure (like “request duration”) and then use them as decorators to decorate your actual functions.

If you want to know more about prometheus, look at https://hynek.me/talks/prometheus/

https://abload.de/img/screenshot2017-10-04aa4pc6.png

Photo explanation: some 1:87 scale figures on my model railway (under construction).

 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):