You can't improve what you don't measure. This lesson teaches which metrics to track, how to build pipeline dashboards, and when to alert — turning your CI/CD from a black box into an observable system.

The DORA Metrics (Revisited as an Architect)

MetricWhat to MeasureAlert WhenTarget (Elite)
Deployment frequencyDeploys per day/weekDrops below baselineMultiple per day
Lead timeCommit → running in prod> 1 hour< 1 hour
Change failure rateRollbacks / total deploys> 10%< 5%
MTTRIncident → recovery time> 30 min< 1 hour

Pipeline-Specific Metrics

MetricWhy It MattersWhere to Get It
CI duration (P50, P95)Developer experienceGitHub Actions API / workflow logs
CI success ratePipeline reliabilityFailed runs / total runs
Queue timeRunner availabilityTime between trigger and first step start
Cache hit rateOptimization effectivenessCache action output
Image build timeContainer pipeline speeddocker/build-push-action duration
ArgoCD sync durationGitOps deploy speedArgoCD metrics endpoint
Flaky test rateTrust in CITests that pass/fail inconsistently

Building a Pipeline Dashboard

      - name: Emit metrics
        if: always()
        run: |
          # Write to GitHub Step Summary (free, built-in)
          echo "## ⏱️ Pipeline Metrics" >> $GITHUB_STEP_SUMMARY
          echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
          echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
          echo "| Run | #${{ github.run_number }} |" >> $GITHUB_STEP_SUMMARY
          echo "| Duration | ${SECONDS}s |" >> $GITHUB_STEP_SUMMARY
          echo "| Status | ${{ job.status }} |" >> $GITHUB_STEP_SUMMARY

          # Push to your observability platform (Datadog, Prometheus, etc.)
          curl -X POST "$METRICS_ENDPOINT" -d '{
            "metric": "cicd.duration",
            "value": "'$SECONDS'",
            "tags": ["repo:${{ github.repository }}", "status:${{ job.status }}"]
          }' 2>/dev/null || true

When to Alert

🚨 Page (immediate) • Prod deploy failed + no rollback • ArgoCD lost sync > 30 min • Secret exposure detected ⚠️ Warn (next day) • CI success rate < 90% • CI duration P95 > 10 min • Cache hit rate < 70% 📊 Track (weekly review) • Deployment frequency trend • Lead time trend • Cost per deploy

🧠 Recall Check

  1. Name the four DORA metrics and their elite-level targets.
  2. What should you alert on IMMEDIATELY vs review weekly?
  3. Why track "flaky test rate" as a CI metric?
Reveal answers
  1. Deployment frequency (multiple/day), Lead time (<1 hour), Change failure rate (<5%), MTTR (<1 hour).
  2. Immediate: production failure without rollback, prolonged drift, secret exposure. Weekly: trends in duration, success rate, deployment frequency — these are optimization signals, not emergencies.
  3. Flaky tests erode trust in CI. Developers start ignoring failures ("it's probably flaky") → real bugs slip through. A consistently green CI pipeline requires fixing or quarantining flaky tests.

Next lesson: Disaster Recovery — what to do when everything breaks.