doc/ci/testing/metrics_reports.md
{{< details >}}
{{< /details >}}
Metrics reports display custom metrics in merge requests to track performance, memory usage, and other measurements between branches.
Use metrics reports to:
When a pipeline runs, GitLab reads metrics from the report artifact and stores them as string values
for comparison. The default filename is metrics.txt.
For a merge request, GitLab compares the metrics from the feature branch to the values from the target branch and displays them in the merge request widget in this order:
To compare metrics between branches, GitLab identifies a baseline pipeline on the target branch using this process:
The baseline pipeline selection:
success, failed, canceled, or skipped)
can be selected as the baseline.The metrics comparison widget appears only when the feature branch pipeline is in a completed state and has metrics report artifacts.
The type of pipeline affects which commit SHA is matched first:
To ensure a baseline is always available for comparison:
Add metrics reports to your CI/CD pipeline to track custom metrics in merge requests.
Prerequisites:
To configure metrics reports:
.gitlab-ci.yml file, add a job that generates a metrics report.artifacts:reports:metrics.For example:
metrics:
stage: test
script:
- echo 'memory_usage_bytes 2621440' > metrics.txt
- echo 'response_time_seconds 0.234' >> metrics.txt
- echo 'test_coverage_percent 87.5' >> metrics.txt
- echo '# EOF' >> metrics.txt
artifacts:
reports:
metrics: metrics.txt
After the pipeline runs, the metrics reports display in the merge request widget.
For additional format specifications and examples, see Prometheus text format details.
When working with metrics reports, you might encounter the following issues.
You might see Metrics report scanning detected no new changes when viewing metrics reports in merge requests.
This issue occurs when:
To resolve this issue: