Introducing a new way to review your PRs.

Read the announcement

hcavarsan / pipedash

One dashboard for CI/CD pipelines across multiple providers

View on GitHub

19 documents · Updated Nov 23, 2026

docs / metrics-observability

Pipeline metrics and observability

Pipeline metrics turn finished runs into time-based signals that help engineers track speed, reliability, and activity. The system stores these signals under collection and retention settings, serves grouped views to the client, and presents them as pipeline summaries or detailed charts and tables.

Metrics lifecycle

The metrics lifecycle links run history to a monitoring view. The pipeline view starts collection after history is available and re-reads history after a configuration save. The client then reads grouped data and refreshes the view when a matching event changes the source.

flowchart LR
    A[Finished run history] --> B[Metric collection]
    B --> C[Stored metric observations]
    C --> D[Grouped dashboard query]
    D --> E[Summary cards]
    D --> F[Detailed chart and table]
    B --> G[Metrics event]
    G --> D
    H[Retention cleanup] --> C

References: crates/…/pipeline_service.rs• L824-875 crates/…/metrics_service.rs• L127-155 src/…/PipelineMetricsView.tsx• L53-115 src/…/useMetricsEventListeners.ts• L8-131

Run collection

Run collection is the bridge between pipeline monitoring and stored metrics. It accepts only finished, non-snapshot runs within the active retention window. Repeated regular history does not add another observation, while native history marked as bounded reconciliation can replace an observation when its source record changes. A native-looking run without that provenance keeps its first observation instead of being refreshed.

The collected signals are:

  • run_duration: the run time in seconds when the run reports a duration.
  • success_rate: 100 for a successful run and 0 for a failed or cancelled run.
  • run_frequency: one count for each successful, failed, or cancelled run.

Skipped runs do not create these signal entries. A run can therefore be finished and still contribute no metric when its status or duration does not produce an entry.

References: crates/…/metrics_service.rs• L125-160 crates/…/extract.rs• L1-200 crates/…/tests.rs• L24-220 crates/…/metrics.rs• L10-24

Collection scope

Metrics collection has a global default and a pipeline-level setting. A pipeline setting controls that pipeline, while the global setting supplies the default for new or unconfigured pipelines. Each scope also has a retention period that limits how long observations remain available.

The client offers common periods of 7, 14, 30, 60, or 90 days and permits a custom whole-day value. Disabling collection is a destructive action because it deletes the stored metrics at the selected scope. A rejected configuration save does not announce a change to monitoring views.

References: src/…/MetricsSection.tsx• L28-85 src/…/MetricsCollectionFields.tsx• L12-45 src/…/MetricsConfigForm.tsx• L28-117 src/…/metricsRetention.ts• L1-4 crates/…/tests.rs• L698-736

Metrics persistence

Metrics persistence keeps settings, observations, processing progress, and storage summaries in the application database. The core metrics migrations provide the shared product shape across SQLite and PostgreSQL, while migration logic carries earlier metric data into that shape and keeps pipeline identities valid.

Observation records

An observation belongs to one pipeline and one time period. It stores the metric type and value with context such as run number, status, branch, or actor when that context exists. Processing progress and source hashes let collection distinguish a new run from a repeated or changed source record.

The migration path matters because metrics are long-lived data. The current merged schema is the target for both database backends, and startup migration preserves prior settings and observations rather than treating the new schema as an empty store.

References: crates/…/20250128000003_merge_metrics.sql• L1-77 crates/…/20250128000003_merge_metrics.sql• L1-75 crates/…/migration.rs• L945-1007

Deduplication and refresh

Deduplication protects frequency and count values when history is read more than once or collection tasks overlap. Regular runs use stored run identity and a per-pipeline checkpoint to keep the first observation. Native-history records marked as bounded reconciliation use source hashes to detect changes and refresh their metric set. This refresh path does not apply to records without the native-history provenance marker.

This keeps a corrected duration or status visible without counting the same run twice. The persistence operation also keeps one pipeline refresh consistent when more than one refresh request arrives.

References: crates/…/metrics_service.rs• L163-304 crates/…/extract.rs• L41-212 crates/…/tests.rs• L104-220 crates/…/tests.rs• L278-476 crates/…/processing.rs• L1-220 crates/…/records.rs• L1-260 crates/…/batch.rs• L1-240

Retention and deletion

Retention controls the oldest data that collection and cleanup keep. Scheduled cleanup removes observations beyond the effective cutoff. Users can also delete metrics for one pipeline or for all pipelines from the settings flow.

Deletion resets the matching processing progress. A later collection pass can therefore rebuild deleted data that still falls inside the active retention period.

References: crates/…/refresh_manager.rs• L153-189 crates/…/retention.rs• L1-220 crates/…/stats.rs• L1-180 src/…/useMetricsQueries.ts• L165-207

Metrics query service

The metrics query service turns stored observations into data for monitoring. A dashboard request selects a pipeline, metric type, date range, time grouping, aggregation, and optional table order. The result includes the grouped periods, summary values, observed-period flags, and range information that the client needs to explain gaps.

The supported metric views are:

MetricProduct meaningDefault aggregation
run_durationTime used by runsAverage
success_rateShare of runs that succeededAverage
run_frequencyNumber of runsTotal

The service supports hourly, daily, weekly, and monthly periods. It also supports average, total, minimum, maximum, 95th percentile, and 99th percentile aggregation.

References: crates/…/metrics.rs• L93-147 crates/…/query.rs• L1-250 crates/…/aggregation.rs• L1-280 src/…/metricsUtils.ts• L5-57

Query gaps

The query result keeps periods with no runs so the client can show a gap instead of a false zero. The chart and table use an observed flag to separate a real metric value from an empty period. This distinction is important for duration and success rate because no run is not the same as a zero value.

The client marks ranges beyond retention as unavailable when the service reports that the stored history cannot cover them. If the selected range has no observations, the view offers a wider available range or a refresh.

References: src/…/useMetricsQueries.ts• L54-93 src/…/MetricsEmptyState.tsx• L15-47 src/…/MetricsChart.tsx• L88-99 src/…/MetricShellRow.tsx• L22-35

API surfaces

Metrics use one service contract whether the core runs through the server or the desktop app. Both entry points provide configuration, dashboard query, storage summary, and deletion actions. The client query layer hides that runtime choice from the presentation layer.

References: crates/…/metrics.rs• L77-90 crates/…/metrics.rs• L151-287 crates/…/commands.rs• L924-1189 src/…/service.ts• L1-10 src/…/api.ts• L655-723

Metrics presentation

Metrics presentation gives engineers two levels of view. The pipeline view compares the three core signals in compact cards. The detail view focuses on one signal and links its chart, data table, filters, and export actions. Each metric can report its own load failure, so one unavailable signal does not hide the others.

flowchart TD
    A[Pipeline metrics view] --> B{Collection enabled?}
    B -- No --> C[Enable metrics]
    B -- Yes --> D[Choose range and period]
    D --> E[Duration, success, and frequency cards]
    E --> F[Open one metric]
    F --> G[Choose aggregation and sort]
    G --> H[Chart and data table]
    H --> I[PNG or CSV export]

References: src/…/PipelineMetricsView.tsx• L43-131 src/…/PipelineMetricCards.tsx• L30-119 src/…/MetricsDetailPage.tsx• L39-175

Summary cards

Summary cards provide a quick comparison of duration, success rate, and frequency for the selected range. Each card shows latest and average values, plus a compact plot when observations exist. Selecting a card opens the matching detailed view.

The layout adapts to the desktop and mobile shell without changing the metric meaning. The plot loads separately from the card action and has its own recovery boundary, so an engineer can still open the detail view when the compact plot cannot render. A failure in one card remains local to that metric.

References: src/…/CompactMetricsCard.tsx• L57-143 src/…/LazyMetricsChart.tsx• L1-18 src/…/PipelineMetricCards.tsx• L30-67 src/…/MetricPlotMarks.tsx• L41-70

Detailed charts

The detail chart shows one grouped metric series with average, latest, and maximum summaries. Engineers can change the date range, grouping period, and aggregation. A selected point links the chart to the matching table row.

The chart keeps missing periods disconnected and labels them as having no runs. On the mobile shell, touch or slide selection reads the value for a period without changing the underlying query. During a new query, the view keeps the last resolved title and data until the new result arrives, while showing a compact update state.

References: src/…/MetricsDetailPage.tsx• L47-161 src/…/MetricsChart.tsx• L64-181 src/…/MetricsPlot.tsx• L52-175 src/…/MetricShellRow.tsx• L22-35

Data tables

The data table gives the grouped series a precise view. It shows the period value, observation count, minimum, and maximum, then lets the engineer sort by date or a numeric column. Selecting a row selects the same period in the chart.

Long result sets use a windowed list, so the screen does not need to mount every row at once. The mobile shell uses the same data with a sort menu and compact rows.

References: src/…/MetricsDataTable.tsx• L30-157 src/…/MetricShellRow.tsx• L22-35 src/…/MetricsTableSortMenu.tsx• L22-53

Settings and storage views

Global settings control the default collection state and retention. Pipeline settings control one pipeline and show its storage scope. Both flows expose stored usage and a destructive delete action so an engineer can manage data growth.

Global changes save as the field changes and show an optimistic enable state. Pipeline changes use a draft form that validates retention before save. The custom retention field also submits the dialog when the engineer presses Enter after entering a whole-day value. Disable and delete is confirmed as one destructive action, while a failed save or delete stays visible with a retry path and does not replace newer input.

References: src/…/MetricsSection.tsx• L21-90 src/…/MetricsConfigModal.tsx• L17-70 src/…/MetricsConfigForm.tsx• L84-183 src/…/MetricsCollectionFields.tsx• L27-140 src/…/MetricsStorageSection.tsx• L30-107 src/…/RetentionDaysInput.tsx• L10-26 src/…/MetricsConfigForm.test.ts• L49-86

Live updates and export

An open pipeline metrics view listens for metric, configuration, run, cancellation, and pipeline-status events. It refreshes only when the event matches the viewed pipeline. A configuration event first reloads the effective setting, while a saved configuration also refreshes run history before it refreshes metric queries.

The detail view exports the current grouped result as CSV or captures the displayed chart as PNG. Export stays unavailable while data loads or another export is pending. A failed metrics refresh keeps the loaded chart visible and offers retry, while a failed export reports an error and leaves the action available for retry.

References: src/…/useMetricsEventListeners.ts• L18-131 src/…/PipelineMetricsView.tsx• L87-115 src/…/useExportMetrics.ts• L8-85 src/…/MetricsDetailPage.tsx• L100-187 src/…/useMetricsQueries.ts• L26-33

Cross-page relationships

Metrics provide the long-term trend view for pipeline monitoring. Use Pipeline monitoring for the wider monitoring model, Pipeline dashboard for dashboard presentation, and Run detail and logs for the per-run evidence that feeds collection.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep metric names, aggregation names, observed-period flags, and table sort fields aligned between core responses, service adapters, query keys, charts, tables, and exports.
  • Keep the SQLite and PostgreSQL migration shapes aligned when observation identity, source hashes, processing progress, or retention data changes.
  • If the rules for finished runs, snapshot exclusion, or native-history provenance move, review both duplicate handling and native-history refresh behavior.
  • If a delete or disable flow changes, preserve the processing reset and invalidate the affected global, pipeline, storage, and dashboard queries.
  • If event payloads change, update the core publisher and the client listener that scopes refreshes to one pipeline.
  • If grouped output changes, update gap display, chart/table selection, sorting, and CSV export as one contract.
  • If a chart or card action changes, keep plot errors isolated from the expand action and keep desktop and mobile presentations aligned.
  • If configuration save timing changes, preserve the distinction between confirmed settings, draft values, and any required run-history refresh.
  • If the custom retention field or dialog submit behavior changes, preserve Enter submission for valid whole-day values and keep the form-level save contract covered.

Important failure modes

TriggerConsequenceGuard
Collection is disabled at the effective scopeNo new metric observations appearThe pipeline view checks the effective setting before it queries or fetches history
Snapshot or unfinished runs enter collectionReliability and frequency trends show false dataCollection accepts only finished non-snapshot runs
A skipped run is treated as a successful or failed runFrequency and success trends include a signal that the source did not provideMetric extraction creates success and frequency entries only for success, failure, or cancellation
The same run is processed againFrequency and period counts become too highCheckpoints, source hashes, and duplicate-safe persistence reject repeats
A changed native-history record is not refreshedCorrected duration or status stays absent from later chartsSource changes replace the run's metric set when refresh support applies
A run lacks bounded-reconciliation provenanceLater changes to that run do not replace its first observationOnly native history with the required source and scope markers uses refresh behavior
A range extends beyond retentionThe dashboard shows empty or partial periodsRange options mark unavailable history and the empty state offers a wider valid range
A grouped result loses its observed flagsMissing runs can appear as zero valuesChart, table, and export treat unobserved periods as empty
A chart render error bubbles into the card actionThe engineer cannot open metric detailsThe lazy chart boundary isolates plot errors from card actions
An export is started while another export is pendingDuplicate files or duplicate completion notices can occurThe export action disables until the save operation finishes
A retention save fails after a newer draft is enteredThe newer value is overwritten by stale server stateSettings compare the saved draft with the current draft before clearing it
History refresh fails after a configuration saveNew retention data may not be collected at onceThe view reports the refresh error and still refreshes the metrics queries
One metric query failsOne signal is unavailable while the whole pipeline view may be unusableEach metric card owns its error state and retry action
Enter does not submit a valid custom retention valueThe dialog keeps the old retention settingThe custom field submits the form on Enter and the form test verifies the saved days

Key files

FileWhy to read it
crates/…/metrics_service.rsDefines collection configuration, query access, cleanup, storage stats, and processing reset behavior
crates/…/extract.rsDefines which run records become metrics and when native history can refresh them
crates/…/tests.rsShows the guarantees for snapshots, retention, late runs, native-history refresh, and concurrent deduplication
crates/…/metrics_repository.rsDefines the metrics persistence boundary and repository operations
crates/…/query.rsShows how dashboard queries become grouped periods and table results
crates/…/20250128000003_merge_metrics.sqlShows the current SQLite metrics schema after the core migration
crates/…/20250128000003_merge_metrics.sqlShows the current PostgreSQL metrics schema after the core migration
crates/…/migration.rsShows how older metric data moves into the current database shape
src/…/PipelineMetricsView.tsxDefines the pipeline metrics flow, filters, configuration, and live refresh entry point
src/…/MetricsDetailPage.tsxDefines detailed filters, chart/table coordination, loading recovery, and export actions
src/…/MetricsChart.tsxDefines metric summaries, period gaps, and chart interaction
src/…/MetricsDataTable.tsxDefines grouped data display, sorting, selection, and windowed rows
src/…/MetricsSection.tsxDefines global collection defaults and retention behavior
src/…/MetricsConfigForm.tsxDefines pipeline settings, draft validation, and destructive deletion behavior
src/…/MetricsCollectionFields.tsxDefines shared collection and retention controls across desktop and mobile settings views
src/…/MetricsConfigForm.test.tsVerifies that Enter submits a custom retention value through the configuration dialog
src/…/useMetricsEventListeners.tsDefines the event-to-refresh link for an open pipeline view
src/…/useMetricsQueries.tsDefines client query keys, cache invalidation, configuration mutations, and storage deletion
src/…/useExportMetrics.tsDefines CSV and PNG output from the current detail view