-
Notifications
You must be signed in to change notification settings - Fork 58
Dora Exporter
This section covers steps taken in configuring DORA metrics for this repository.
DORA (DevOps Research and Assessment) metrics are essential indicators used to measure software delivery performance. These metrics provide valuable insights into the efficiency, reliability, and speed of your DevOps processes. The four key DORA metrics are:
- Deployment Frequency: Measures how often your team successfully deploys code to server from a branch.
- Lead Time for Changes: The time it takes for a commit to reach the server, indicating deploypment speed.
- Change Failure Rate: The percentage of deployments that result in failures in the server.
- Mean Time to Recovery (MTTR): The average time it takes to recover from a failed deployment.
This DORA metrics exporter is a Python-based script that collects these metrics from this GitHub repository and exposes them to Prometheus for monitoring. Below is a brief overview of how the exporter was configured and integrated into your environment.
The exporter uses environment variables to configure the GitHub repository details:
-
GITHUB_OWNER
: The owner of the GitHub repository. -
GITHUB_REPO
: The name of the repository. -
GITHUB_TOKEN
: A GitHub personal access token with permissions to access the repository.
These variables are stored in a .env
file and loaded using the dotenv
library:
GITHUB_OWNER=your-username
GITHUB_REPO=your-repo
GITHUB_TOKEN=your-github-token
The exporter defines several Prometheus Gauge
metrics to capture and expose the DORA metrics:
-
Deployment Frequency:
github_deployments_total
-
Change Failure Rate:
github_change_failure_rate
-
Lead Time for Changes:
github_deployments_lead_time
-
MTTR:
github_deployments_mttr
Each metric is labeled with the branch (dev
, staging
, prod
) and the repository name for granularity.
DEPLOYMENT_GAUGE = Gauge('github_deployments_total', 'Total number of GitHub deployments', ['branch', 'repo', 'status'])
LEAD_TIME_GAUGE = Gauge('github_deployments_lead_time', 'Lead time for changes in seconds', ['branch', 'repo'])
MTTR_GAUGE = Gauge('github_deployments_mttr', 'Mean Time to Recovery (MTTR) in seconds', ['branch', 'repo'])
CHANGE_FAILURE_RATE = Gauge('github_change_failure_rate','Percentage of failed GitHub deployments relative to the total number of deployments',['branch','repo'])
The exporter interacts with the GitHub API to fetch commit data and workflow runs:
- Commits: Retrieved in chunks to handle large datasets.
-
Workflow Runs: Filtered by status (
completed
) and event (push
).
It then calculates the metrics as follows:
- Deployment Frequency: Counts the total successful and failed deployments for each branch.
- Lead Time for Changes: Measures the time between a commit and its successful deployment.
- MTTR: Calculates the time taken to recover from a failed deployment.
The exporter runs an HTTP server that exposes the metrics on a specified port (default is 5555
). Prometheus can scrape these metrics by adding the exporter to your prometheus.yml
configuration:
scrape_configs:
- job_name: 'dora_metrics'
static_configs:
- targets: ['localhost:5555']
To run the exporter, use the following command:
python dora_exporter.py
This will start the HTTP server and begin collecting and exposing metrics to Prometheus.
Below is an example layout for a Grafana dashboard monitoring DORA metrics:
-
Panel 1: Deployment Frequency: Bar chart showing the number of deployments per branch over time.
-
Panel 2: Lead Time for Changes: Bar chart displaying the average lead time across different branches.
-
Panel 3: Mean Time to Recovery (MTTR): Bar chart showing MTTR values to quickly identify recovery performance.
-
Panel 4: Change Failure Rate: Bar chart showing the percentage of failed deployments.
These screenshots show the DORA metrics as they appear on the Grafana dashboard after being scraped from the exporter.
By integrating the DORA metrics exporter with Prometheus and visualizing these stats on grafana, you gain valuable insights into your software delivery performance. This setup allows you to continuously monitor and improve your DevOps processes, ultimately leading to more reliable and efficient software delivery.
You can view the full python exporter script here.
Made with ❤️ by Olat-nji | Ujusophy | tulbadex | Darkk-kami | Otie16 courtesy of @HNG-Internship