Continuous Integration (CI) is a vital part of the software development process that helps teams detect and solve issues early in the development cycle. Drone is a popular open-source CI/CD tool that automates building, testing, and deploying applications. In this article, we will explore how to monitor and visualise Drone CI metrics using Prometheus and Grafana.
To get started, you'll need Drone Server. If setup and installation are yet to be done, you can refer to my blogtorial.
About Prometheus and Grafana
Prometheus is a popular open-source monitoring system that collects and stores metrics from various sources. It is designed to be highly scalable and has a powerful query language for data analysis. Grafana is a data visualisation tool that helps visualise and analyse metrics stored in Prometheus. It provides a rich set of visualisation options, such as graphs, dashboards, and alerts.
Setting up Prometheus & Grafana
Using Docker, we will set up Prometheus and Grafana. For that, we'll use the following docker-compose
file.
Create a docker-compose.yml
file
touch docker-compose.yml
Copy the contents below into the created file.
Create a prometheus.yml
file
touch prometheus.yml
We'll create a Prometheus configuration file, which will be used by the Prometheus container to scrape data from the targets we specify. The configuration file contains the target to scrape, the scrape interval, and other settings.
Copy the contents below into the prometheus.yml
file
127.0.0.1:8080
. If the server is hosted at any other URL/PORT, please change the URL in the Prometheus config accordingly.Create a Grafana drone-dashboard.json
file
touch drone-dashboard.json
Copy the following contents into the drone-dashboard.json
file.
This JSON data defines a dashboard with a single panel that shows the build status over time. The data source for the panel is set to Prometheus, and the drone_build_status
metric is used to generate the graph. The legend format is set to show the build number, and the graph is displayed as a line chart with the fill option enabled.
Accessing Prometheus and Grafana
Finally, we can start Prometheus and Grafana by running the command below. This will start Prometheus and Grafana with their respective configurations.
docker compose up -d
You can now access Prometheus at localhost:9090
and Grafana at localhost:3000
.
Frequently Asked Questions
Why use Prometheus and Grafana for monitoring Drone CI/CD build metrics?
Prometheus and Grafana are well-suited for monitoring Drone CI/CD build metrics for several reasons:
- Prometheus provides a highly scalable and flexible way to collect and store time-series data, making it easy to monitor a large number of builds in real time.
- Grafana provides a wide range of visualisation tools, making it easy to create custom dashboards that display the specific metrics you are interested in.
- Together, Prometheus and Grafana provide a powerful and highly customisable monitoring solution that can be tailored to your organisation's specific needs.
What metrics can be monitored using Prometheus and Grafana in Drone CI/CD?
Drone CI/CD provides a variety of metrics that can be monitored using Prometheus and Grafana, including:
- Build status: Whether a build is successful, failed, or still running
- Build duration: How long each build takes to complete
- Build triggers: What triggers each build, such as a commit or a pull request
- Build steps: How many steps each build has, and how long each step takes to complete
- Build artefacts: What artefacts are generated by each build, and how large they are
In this article,
we explored how to monitor and visualise Drone CI metrics using Prometheus and Grafana. Together, they provide a powerful toolset for monitoring and analysing Drone CI metrics.
Subscribe and comment below if you have any queries! I try to regularly update my articles to ensure legibility.