Schedule icon
Request icon
If icon
SlackIncomingWebhook icon
Log icon

GitLab CI pipeline duration regression and execution latency watchdog

Audit GitLab CI pipelines via GraphQL API for execution duration regressions and alert DevOps teams in Slack to prevent slow builds and runner cost spikes.

Categories
CloudInfrastructure

Prevent CI/CD pipelines from silently ballooning in duration, slowing engineering feedback loops and inflating cloud runner infrastructure bills. In active software engineering teams, additions of un-cached Docker builds, un-parallelized end-to-end integration tests, or saturated shared runner pools often cause pipeline execution times to gradually double or triple without anyone noticing until sprint velocity grinds to a halt. This blueprint runs an hourly audit via the GitLab GraphQL API (io.kestra.plugin.graphql.Request), inspects duration timings across recent successful pipelines, and dispatches a Slack alert whenever a pipeline breaches your maximum runtime budget.

How it works

  1. A Schedule trigger executes an hourly audit across recent pipelines (shipped disabled by default).
  2. Task fetch_recent_pipelines queries {{ inputs.gitlab_host }}/api/graphql using a project or personal token (GITLAB_API_TOKEN). The GraphQL query fetches recent successful pipelines with their unique iid, execution duration (in seconds), Git branch ref, creation timestamp, and commit title.
  3. Task evaluate_pipeline_duration (io.kestra.plugin.core.flow.If) applies a jq filter to count pipelines whose runtime exceeded inputs.max_duration_seconds:
    • If any slow pipelines are detected: Task alert_slow_pipelines delivers an itemized Slack alert displaying pipeline identifiers, duration in minutes, branch refs, and commit messages.
    • If all pipelines finished within budget: Task log_duration_healthy logs that performance is healthy.
  4. Task log_audit_summary records total evaluated and slow pipeline counts.
  5. Top-level errors handler catches network drops or authentication issues.

What you get

  • Continuous automated detection of CI/CD build and test runtime regressions in GitLab.
  • Faster developer feedback cycles by maintaining tight build duration budgets.
  • Proactive visibility into runner saturation and test suite flakiness.
  • Reduced compute spend on GitLab Shared and self-hosted CI runners.

Who it's for

  • DevOps and Platform Engineers managing GitLab CI/CD infrastructure.
  • Quality Assurance (QA) Leads overseeing automated end-to-end test execution.
  • Engineering Managers maintaining developer experience and PR turnaround velocity.

Why orchestrate this with Kestra

Tracking pipeline duration trends natively in GitLab requires manually navigating analytics dashboards. Kestra provides automated, scheduled orchestration that queries GitLab's GraphQL API directly, evaluates duration metrics mathematically with jq expressions, and delivers alerts to Slack channels with zero custom bot maintenance.

Prerequisites

  • A GitLab project (on gitlab.com or self-hosted GitLab).
  • A GitLab Personal Access Token or Project Access Token with read_api scope.
  • A Slack Incoming Webhook URL.

Secrets

  • GITLAB_API_TOKEN: GitLab access token passed in the Authorization: Bearer header.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to post duration alerts.

Quick start

  1. Generate a GitLab Project Access Token under Project Settings > Access Tokens with read_api scope.
  2. Store GITLAB_API_TOKEN and SLACK_WEBHOOK_URL in Kestra Secrets.
  3. Set gitlab_project_path to your repository path (e.g. gitlab-org/gitlab) and configure max_duration_seconds (e.g. 1800).
  4. Execute the flow manually in Kestra to confirm that pipelines and durations are fetched.
  5. Enable the hourly_pipeline_sweep schedule to activate hourly duration monitoring.

How to extend

  • Compare average pipeline durations week-over-week to produce automated engineering productivity digests.
  • Automatically profile which individual pipeline stage (e.g. test, build, deploy) contributed the most time.
  • Push duration metrics to Datadog or Prometheus to graph pipeline latency histograms.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.