Skip to main content

Measuring CI/CD Performance with DORA Metrics

Measure deployment frequency, lead time, change failure rate, and MTTR from real pipeline data, then use DORA bands to improve delivery.

22 Terms

Overview and What You Will Learn

DORA metrics are four measurements of software delivery performance: Deployment Frequency, Lead Time for Changes, Change Failure Rate, and Mean Time to Restore (MTTR). Two measure speed and two measure stability, and the research behind them found that the best teams are strong on all four at once. They can be computed from data your pipeline and incident tracker already hold.

In this lab you will:

  • Define each metric precisely, including what counts as a failure.
  • Read the benchmark bands without treating them as a scorecard.
  • Compute Deployment Frequency and Lead Time with a script against the GitHub API.
  • Compute Change Failure Rate and MTTR from an incidents table.
  • Run the script on a schedule so regressions are visible.
  • Pick pipeline changes that move each metric.

Why This Matters in Production

Without numbers, "are we good at shipping?" gets answered with opinions. DORA gives a shared, comparable measure and shows where the time actually goes. A team at Swiggy or Zerodha that ships many times a day with few failed releases is not lucky. It is the result of small batches, fast automated tests, and fast rollback, all of which are pipeline design decisions.

The metrics also expose trade-offs. A team can raise Deployment Frequency by cutting corners, and Change Failure Rate will show the cost within weeks.

Common Mistake

Tracking Deployment Frequency alone and declaring success. Ten deploys a day with a high failure rate is shipping incidents faster. Always read the speed and stability metrics together.

Core Principles

Two speed metrics and two stability metrics balance each other.

flowchart LR subgraph Speed A[Deployment Frequency] B[Lead Time for Changes] end subgraph Stability C[Change Failure Rate] D[Time to Restore] end A --> E[Delivery performance] B --> E C --> E D --> E classDef speed fill:#326CE5,color:#FFFFFF classDef stab fill:#10B981,color:#FFFFFF classDef out fill:#8B5CF6,color:#FFFFFF class A,B speed class C,D stab class E out

Each metric has a precise definition.

  • Deployment Frequency: how often a team successfully deploys to production.
  • Lead Time for Changes: time from a commit to that change running in production.
  • Change Failure Rate: share of production deployments that cause an incident, rollback, or hotfix.
  • MTTR: average time to restore service after a failure. Recent DORA reports also call it failed deployment recovery time.

Benchmark bands move a little each year, so use them for direction. The commonly cited bands from recent reports:

Metric Elite Low
Deployment Frequency On demand, many per day Less than once per six months
Lead Time Less than one day One to six months
Change Failure Rate About 5 percent Much higher, 40 percent and up
MTTR Less than one hour More than one week

High and medium tiers sit between these. Older reports used slightly different cut-offs, for example elite lead time under one hour, so always note which report you compare against. Since 2024 DORA has also discussed rework rate alongside the four metrics.

Each metric maps to data you already have.

Metric Source data
Deployment Frequency Successful production deployment events
Lead Time Commit time and deploy success time
Change Failure Rate Incidents linked to a deployment
MTTR Incident start and resolution times

Link incidents to deployments automatically. Stamp the deployment ID into the running service, for example through an environment variable or a /version endpoint, so incident tooling records which deploy was live when the incident began. Manual tagging decays within weeks.

Tip

Treat the bands as a direction to move in. A team improving from Low to Medium on lead time has made a bigger real gain than an elite team shaving another ten minutes.

Detailed Step-by-Step Practical Lab

This lab measures a streaming-api repository over the last 30 days using the GitHub API and an incidents table.

Milestone 1 - Create a read-only token

Create a fine-grained token with read access to deployments and contents for the repository, and export it.

Bash
export GITHUB_TOKEN=github_pat_xxxxxxxx
export REPO=hotstar/streaming-api

This token can read deployment data only, so it is safe to use in a scheduled job.

Milestone 2 - Compute Deployment Frequency and Lead Time

Python
#!/usr/bin/env python3
"""dora_speed.py - Deployment Frequency and Lead Time from GitHub Deployments."""
import os
import sys
import statistics
from datetime import datetime, timedelta, timezone
import requests
API = "https://api.github.com"
TOKEN = os.environ["GITHUB_TOKEN"]
REPO = os.environ.get("REPO", "hotstar/streaming-api")
ENV = os.environ.get("DEPLOY_ENV", "production")
WINDOW_DAYS = int(os.environ.get("WINDOW_DAYS", "30"))
MAX_MEDIAN_LEAD_HOURS = float(os.environ.get("MAX_MEDIAN_LEAD_HOURS", "24"))
HEADERS = {
"Authorization": f"Bearer {TOKEN}",
"Accept": "application/vnd.github+json",
}
def get(url, **params):
response = requests.get(url, headers=HEADERS, params=params, timeout=30)
response.raise_for_status()
return response.json()
def parse(ts):
return datetime.fromisoformat(ts.replace("Z", "+00:00"))
since = datetime.now(timezone.utc) - timedelta(days=WINDOW_DAYS)
deployments, page = [], 1
while True:
batch = get(f"{API}/repos/{REPO}/deployments", environment=ENV, per_page=100, page=page)
if not batch:
break
deployments += [d for d in batch if parse(d["created_at"]) >= since]
if parse(batch[-1]["created_at"]) < since:
break
page += 1
# 2. Keep only deployments that reached a success status, and record when
lead_times = []
successful = 0
for d in deployments:
statuses = get(f"{API}/repos/{REPO}/deployments/{d['id']}/statuses", per_page=20)
success = [s for s in statuses if s["state"] == "success"]
if not success:
continue
successful += 1
deployed_at = parse(min(s["created_at"] for s in success))
commit = get(f"{API}/repos/{REPO}/commits/{d['sha']}")
committed_at = parse(commit["commit"]["committer"]["date"])
lead_times.append((deployed_at - committed_at).total_seconds() / 3600)
print(f"Successful {ENV} deploys in {WINDOW_DAYS} days: {successful}")
print(f"Deploys per day: {successful / WINDOW_DAYS:.2f}")
if lead_times:
median_lead = statistics.median(lead_times)
print(f"Median lead time: {median_lead:.2f} hours")
if median_lead > MAX_MEDIAN_LEAD_HOURS:
print(f"Median lead time above {MAX_MEDIAN_LEAD_HOURS} hours")
sys.exit(1)
Bash
python3 dora_speed.py

You now have a deploys-per-day figure and a median lead time. This uses the deployed commit, so it slightly understates lead time for a branch that held many commits. For a strict figure, use the first commit of each pull request.

Milestone 3 - Link incidents to deployments

Add a caused_by_deployment_id column filled at incident creation from the version stamp, and a started_at timestamp for when the failure began.

SQL
CREATE TABLE incidents (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
started_at TIMESTAMPTZ NOT NULL,
resolved_at TIMESTAMPTZ,
caused_by_deployment_id TEXT
);

Incidents now carry the link that Change Failure Rate needs.

Milestone 4 - Compute Change Failure Rate

SQL
SELECT
COUNT(DISTINCT i.caused_by_deployment_id) * 100.0
/ NULLIF(COUNT(DISTINCT d.id), 0) AS change_failure_rate_pct
FROM deployments d
LEFT JOIN incidents i ON i.caused_by_deployment_id = d.id::text
WHERE d.environment = 'production'
AND d.created_at > NOW() - INTERVAL '30 days';

Counting distinct deployments with incidents prevents one bad deploy from being counted twice.

Milestone 5 - Compute MTTR

SQL
SELECT
AVG(EXTRACT(EPOCH FROM (resolved_at - started_at)) / 60) AS mttr_mean_minutes,
PERCENTILE_CONT(0.5) WITHIN GROUP (
ORDER BY EXTRACT(EPOCH FROM (resolved_at - started_at)) / 60
) AS mttr_median_minutes
FROM incidents
WHERE started_at > NOW() - INTERVAL '30 days'
AND resolved_at IS NOT NULL
AND caused_by_deployment_id IS NOT NULL;

Measure from when the failure started, not when the ticket was opened. Report the median next to the mean, since one long data incident can pull the mean far up.

Milestone 6 - Run it on a schedule

YAML
name: DORA report
on:
schedule:
- cron: '30 3 * * 1' # Mondays 09:00 IST
workflow_dispatch:
jobs:
dora:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: read
steps:
- uses: actions/checkout@v4
- run: pip install requests
- name: Compute speed metrics
env:
GITHUB_TOKEN: ${{ secrets.DORA_READ_TOKEN }}
REPO: hotstar/streaming-api
MAX_MEDIAN_LEAD_HOURS: '24'
run: python3 dora_speed.py

A sustained lead-time regression now fails the weekly job and becomes visible in a notification instead of a retro months later.

Milestone 7 - Choose the right improvement for each metric

  • Deployment Frequency: smaller pull requests, deploy on merge, remove approval gates on lower environments.
  • Lead Time: review SLAs, faster test suites, fewer stacked approvals.
  • Change Failure Rate: higher coverage on incident-prone paths, staging that matches production, canary releases.
  • MTTR: better alerts, one-step rollback, rehearsed runbooks.
Remember

DORA metrics are trailing indicators over a rolling window, commonly 7, 30, or 90 days. One bad deploy should nudge the trend, not define it.

Security

Give the reporting token read-only scope, and restrict who can edit the deployment link on an incident. If the metric feeds evaluations, there is pressure to under-attribute incidents.

Production Best Practices & Common Pitfalls

  • Automate the deployment-to-incident link at incident creation time.
  • Report all four metrics on one dashboard so speed is never read without stability.
  • Use medians and a rolling window to smooth out unusually good or bad weeks.
  • Measure per service as well as org-wide, because one unstable service can hide in an average.
  • Filter to production only, or staging deploys will inflate frequency.
  • Use the metrics at team and system level. Using them in individual performance reviews leads to gaming, such as tiny no-op deploys or incidents quietly reclassified.

Quick Reference & Troubleshooting Commands

Symptom Command What to look for
Frequency looks too high gh api "repos/OWNER/REPO/deployments?environment=production" Staging or preview deploys in the count
Negative lead time Compare commit and deploy timestamps Time zone or rebased commit dates
Change Failure Rate is zero Query the incident join caused_by_deployment_id never populated
MTTR skewed high SELECT MAX(resolved_at - started_at) FROM incidents; One incident left open after the fix
Script gets rate limited gh api rate_limit Token missing or too many calls per run

Resources

Explore More in Deployment Strategies and GitOps

All 6 Topics

Frequently Asked Questions

Is Measuring CI/CD Performance with DORA Metrics free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Measuring CI/CD Performance with DORA Metrics topic cover?

Measure deployment frequency, lead time, change failure rate, and MTTR from real pipeline data, then use DORA bands to improve delivery.

Found a mistake, an outdated step or a broken link?