-
Notifications
You must be signed in to change notification settings - Fork 58
Dora Exporter
This section covers steps taken in congiguring 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 production.
- Lead Time for Changes: The time it takes for a commit to reach production, indicating development speed.
- Change Failure Rate: The percentage of deployments that result in failures in production.
- Mean Time to Recovery (MTTR): The average time it takes to recover from a failed deployment.
The DORA metrics exporter is a Python-based script that collects these metrics from your 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
-
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'])
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: Line graph displaying the average lead time across different branches.
-
Panel 3: MTTR: Gauge or bar chart showing MTTR values to quickly identify recovery performance.
-
Panel 4: Change Failure Rate: Pie chart or bar graph showing the percentage of failed deployments.
This screenshot shows the DORA metrics as they appear on the Grafana dashboard after being scraped from the exporter.
2. GitHub Workflow Runs:
This screenshot highlights the workflow runs in your GitHub repository that the exporter monitors to calculate deployment-related metrics.
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.
For more detailed instructions and troubleshooting, refer to the official documentation.
Made with ❤️ by Olat-nji | Ujusophy | tulbadex | Darkk-kami | Otie16 courtesy of @HNG-Internship