Skip to content

Dora Exporter

David edited this page Aug 8, 2024 · 10 revisions

Overview

This section covers steps taken in congiguring DORA metrics for this repository.

Introduction to DORA Metrics

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:

  1. Deployment Frequency: Measures how often your team successfully deploys code to production.
  2. Lead Time for Changes: The time it takes for a commit to reach production, indicating development speed.
  3. Change Failure Rate: The percentage of deployments that result in failures in production.
  4. Mean Time to Recovery (MTTR): The average time it takes to recover from a failed deployment.

Configuring the DORA Metrics Exporter

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.

1. Environment Setup

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
2. Prometheus Metrics Configuration

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'])
3. Data Fetching and Calculation

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.
4. Integration with Prometheus

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']
5. Running the Exporter

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.

Example Screenshots and Configuration Snippets

Example Grafana Dashboard for DORA Metrics

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. Deployment Frequency

  • Panel 2: Lead Time for Changes: Line graph displaying the average lead time across different branches. Lead Time for Changes

  • Panel 3: MTTR: Gauge or bar chart showing MTTR values to quickly identify recovery performance. MTTR

  • Panel 4: Change Failure Rate: Pie chart or bar graph showing the percentage of failed deployments. Change Failure Rate

This screenshot shows the DORA metrics as they appear on the Grafana dashboard after being scraped from the exporter.

2. GitHub Workflow Runs: GitHub Workflow

This screenshot highlights the workflow runs in your GitHub repository that the exporter monitors to calculate deployment-related metrics.

Conclusion

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.