> ## Documentation Index
> Fetch the complete documentation index at: https://bilanc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Metrics

> API endpoints for CI/CD workflow and pipeline metrics

## Workflow Metrics

Workflow metrics provide insights into the performance, reliability, and cost of your CI/CD pipelines.

### Available Metrics

<ParamField path="workflow-runs-count" type="string">
  Number of workflow runs
</ParamField>

<ParamField path="workflow-run-duration" type="string">
  Average workflow run duration
</ParamField>

<ParamField path="workflow-run-duration-p95" type="string">
  95th percentile workflow run duration
</ParamField>

<ParamField path="workflow-run-success-rate" type="string">
  Percentage of workflow runs that succeeded
</ParamField>

<ParamField path="artifact-sizes" type="string">
  Size of build artifacts produced by workflow runs
</ParamField>

<ParamField path="estimated-workflow-run-cost" type="string">
  Estimated compute cost of workflow runs
</ParamField>

## Workflow Runs Count

Retrieve the number of workflow runs over time, grouped by workflow name.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/workflow-runs-count' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "repositories": [{"repository_name": "backend-api"}],
        "run_conclusions": ["success", "failure"],
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "group_by": ["workflow_name", "run_conclusion"],
      "date_level": "week",
      "date_field": "created_at"
    }'
  ```

  ```json Response theme={null}
  [
    {
      "week_date": "2024-01-01",
      "workflow_name": "CI",
      "run_conclusion": "success",
      "workflow_runs_count": 42
    },
    {
      "week_date": "2024-01-01",
      "workflow_name": "CI",
      "run_conclusion": "failure",
      "workflow_runs_count": 3
    },
    {
      "week_date": "2024-01-08",
      "workflow_name": "CI",
      "run_conclusion": "success",
      "workflow_runs_count": 38
    }
  ]
  ```
</CodeGroup>

## Workflow Run Duration

Retrieve the average or percentile duration of workflow runs to identify slow pipelines.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/workflow-run-duration' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "workflow_names": ["CI", "Deploy"],
        "run_conclusions": ["success"],
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "group_by": ["workflow_name"],
      "date_level": "month",
      "aggregation": "AVG",
      "date_field": "created_at"
    }'
  ```

  ```json Response theme={null}
  [
    {
      "month_date": "2024-01-01",
      "workflow_name": "CI",
      "avg_workflow_run_duration": 245
    },
    {
      "month_date": "2024-01-01",
      "workflow_name": "Deploy",
      "avg_workflow_run_duration": 380
    },
    {
      "month_date": "2024-02-01",
      "workflow_name": "CI",
      "avg_workflow_run_duration": 220
    },
    {
      "month_date": "2024-02-01",
      "workflow_name": "Deploy",
      "avg_workflow_run_duration": 355
    }
  ]
  ```
</CodeGroup>

## Workflow Run Success Rate

Track the success rate of your CI/CD pipelines over time.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/workflow-run-success-rate' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "team": ["team123"],
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "group_by": ["team_name"],
      "date_level": "month",
      "date_field": "created_at"
    }'
  ```

  ```json Response theme={null}
  [
    {
      "month_date": "2024-01-01",
      "team_name": "Backend",
      "workflow_run_success_rate": 0.93
    },
    {
      "month_date": "2024-01-01",
      "team_name": "Frontend",
      "workflow_run_success_rate": 0.97
    },
    {
      "month_date": "2024-02-01",
      "team_name": "Backend",
      "workflow_run_success_rate": 0.95
    }
  ]
  ```
</CodeGroup>

## Parameter Notes

<ResponseField name="date_field" type="string">
  For workflow metrics, the following date fields are available:

  * `created_at`: When the workflow run was triggered
  * `updated_at`: When the workflow run last changed state
</ResponseField>

<ResponseField name="aggregation" type="string">
  Required for duration and cost metrics. Accepted values: `SUM`, `MAX`, `MIN`, `AVG`.
  Count and rate metrics (`workflow-runs-count`, `workflow-run-success-rate`) do not require an aggregation.
</ResponseField>

<ResponseField name="filters" type="object">
  Applicable filters for workflow metrics:

  * `workflow_names`: Filter by workflow names (e.g. `CI`, `Deploy`)
  * `workflow_run_ids`: Filter by specific workflow run IDs
  * `run_conclusions`: Workflow run conclusions — `success`, `failure`, `cancelled`, `skipped`, `timed_out`
  * `branches`: Filter by the branch that triggered the workflow
  * `repositories`: Array of `{"repository_name": "..."}` objects
  * `team`: Filter by team IDs
  * `squad_ids`: Filter by squad IDs
  * `squad_levels`: Filter by squad hierarchy level
  * `manager_ids`: Filter by manager user IDs
  * `departments`: Filter by department names
  * `locations`: Filter by employee location
  * `levels`: Filter by employee level
  * `member`: Filter by triggering user merged user IDs
  * `associated_pr_ids`: Filter by associated PR IDs
</ResponseField>

## Common Use Cases

* **Pipeline Performance**: Track duration trends to catch regressions early
* **Reliability Monitoring**: Monitor success rate to identify flaky workflows
* **Cost Analysis**: Use `estimated-workflow-run-cost` to track and reduce CI spend
* **Team Ownership**: Compare workflow metrics across teams using `group_by: ["team_name"]`
* **Branch Filtering**: Isolate metrics for specific branches (e.g. `main`) using the `branches` filter
