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:
- ITU-MiniTwit at http://localhost:5000
- ITU-MiniTwit metrics for this node at http://localhost:5000/metrics
- The Prometheus web-client at http://localhost:9090
- Grafana at http://localhost:3000 (default login and password:
admin
)
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 theUrl
tohttp://prometheus:9090
- Finally, scroll down to the bottom and press
Save & test
- If there's a
Successfully queried the Prometheus API.
message, click onbuilding 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.
In case you need another panel type for example a clock and in case you are running Grafana via Docker follow the steps below.
- Navigate to https://grafana.com/plugins?type=panel
- Choose a panel of your liking, e.g., https://grafana.com/grafana/plugins/grafana-clock-panel/?tab=overview
- Copy the installation command, which has to be run on the Grafana server (machine)
$ 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.
- 2024: Leonora updated the scenario to a modern Prometheus and Grafana setup. Thanks a lot!