Skip to content

A repository for the sixth session in "DevOps, Software Evolution and Software Maintenance" at IT University of Copenhagen

Notifications You must be signed in to change notification settings

itu-devops/itu-minitwit-monitoring

Repository files navigation

This is the basic ITU_MiniTwit application (Python 3 and SQLite) with added support for monitoring with Prometheus and Grafana as a Dashboard.

The application is Dockerized. To build the application and a client which simulates users clicking around the front page you have to:

  • Build the application:
$ docker build -f docker/minitwit/Dockerfile -t <youruser>/minitwitserver .
  • Build the test client:
$ docker build -f docker/minitwit_client/Dockerfile -t <youruser>/minitwitclient .
  • Start the application:
$ docker compose up

Alternatively, you can build and run the application in one step:

$ docker compose up --build

To stop the application again run:

$ docker compose down -v

After starting the entire application, you can reach:

Starting Grafana and Instantiating a Dashboard

Navigate your browser to http://localhost:3000 and login with the default credentials admin/admin. Remember later to change the password for your projects!

Now, do the following:

  • Click Add your first data source

  • Select the Prometheus data source
  • Set the Name to a name that you deem suitable
  • Under Connection set the Url to http://prometheus:9090
  • Finally, scroll down to the bottom and press Save & test
  • If there's a Successfully queried the Prometheus API. message, click on building a dashboard

Now, click Add visualization, select the Prometheus data source you just added

The default visualization type is a Time series. Change it to a Stat.

In the Metrics browser, find minitwit_http_responses_total and click Run queries

Click on Apply

This is a good point to save the dashboard using the diskette icon :)

Play a bit around with more visualizations. Try make a Time series that display the query rate(minitwit_http_responses_total[$__rate_interval])

Test what happens if you visit the minitwit server at http://localhost:5000/public and perform some actions.

Installing plugins

In case you need another panel type for example a clock and in case you are running Grafana via Docker follow the steps below.

$ docker exec -it itu-minitwit-monitoring-grafana-1 /bin/bash
root@9c17c8757ffb:/# grafana cli plugins install briangann-gauge-panel
✔ Downloaded and extracted briangann-gauge-panel v2.0.1 zip successfully to /var/lib/grafana/plugins/briangann-gauge-panel

Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.

root@9c17c8757ffb:/# exit
exit
$ docker restart itu-minitwit-monitoring_grafana_1
itu-minitwit-monitoring_grafana_1

´


This minitwit.py application was adapted to be monitored with Prometheus with the help of this blog post.


Credits

  • 2024: Leonora updated the scenario to a modern Prometheus and Grafana setup. Thanks a lot!

About

A repository for the sixth session in "DevOps, Software Evolution and Software Maintenance" at IT University of Copenhagen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published