[TRUNK-17697] Document Prometheus metrics endpoint for merge queue#460
[TRUNK-17697] Document Prometheus metrics endpoint for merge queue#460samgutentag wants to merge 3 commits intomainfrom
Conversation
Add Prometheus scrape endpoint docs with available metrics, example scrape config, and Grafana queries. New section in metrics page and reference from API page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
✨ Submitted to Merge by github-actions[bot]. It will be added to the merge queue once all branch protection rules pass and there are no merge conflicts with the target branch. See more details here. |
|
Claude finished @samgutentag's task in 1m 53s —— View job Review complete
SummaryGood foundation — the structure is clear and the cross-reference from the API page is well done. A few issues to address before merging: Blocking issues:
Non-blocking:
The author's own open questions (endpoint URL, exact metric names, rate limits, plan availability) are the real blockers for this content being accurate — eng review is clearly needed before this merges. |
|
|
||
| **P95 wait time:** | ||
| ```promql | ||
| histogram_quantile(0.95, trunk_merge_queue_wait_time_seconds_bucket{repo="my-org/my-repo"}) |
There was a problem hiding this comment.
This histogram_quantile query is incomplete — it will produce incorrect results or errors. Prometheus histogram quantile requires wrapping with sum(rate(...)) by (le). The corrected form:
| histogram_quantile(0.95, trunk_merge_queue_wait_time_seconds_bucket{repo="my-org/my-repo"}) | |
| histogram_quantile(0.95, sum(rate(trunk_merge_queue_wait_time_seconds_bucket{repo="my-org/my-repo"}[5m])) by (le)) |
The [5m] range vector is also required by rate(). Adjust the window to your scrape interval needs.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…ndpoint details Replaces placeholder metric names (trunk_merge_queue_*) with actual implementation (mq_queue_depth_current, mq_pr_conclusions_1h_total, etc.). Adds correct endpoint path, auth mechanism, query params, histogram details, gauge semantics caveat, sample output, and PromQL examples from the Prometheus Metrics Spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @samgutentag's task in 1m 57s —— View job Review complete
SummaryThe two blocking issues from the previous review have been resolved in this update:
Non-blocking issues remaining:
The author's open questions about exact metric names, rate limits, and plan availability remain — eng sign-off is still needed before merging. |
|
/trunk merge |
| {% hint style="info" %} | ||
| The Prometheus metrics endpoint is available on select plans. Contact your Trunk representative for access. | ||
| {% endhint %} |
There was a problem hiding this comment.
It is available to all merge queue users currently
| | Parameter | Required | Description | | ||
| | --- | --- | --- | | ||
| | `repo` | No | Repository in `owner/name` format (e.g., `my-org/my-repo`). If omitted, returns metrics for all repositories in the organization. | | ||
| | `repoHost` | No | Repository host. Defaults to `github.com`. | |
There was a problem hiding this comment.
repo and repoHost must be provided together, if either is specified. It does not default to github. So either no query params, or both repo and repoHost.
For repoHost, I would keep the default text but make it an example instead ("Example: github.com")
| | `repo` | No | Repository in `owner/name` format (e.g., `my-org/my-repo`). If omitted, returns metrics for all repositories in the organization. | | ||
| | `repoHost` | No | Repository host. Defaults to `github.com`. | | ||
|
|
||
| The response uses content type `text/plain; version=0.0.4; charset=utf-8` (standard Prometheus format). Metrics are computed on-demand with a 60-second cache. |
There was a problem hiding this comment.
I would omit the computed on-demand cache part -- that is internal and subject to change and not relevant to the API contract exposed.
| | --- | --- | --- | | ||
| | `repo` | Repository name | `my-org/my-repo` | | ||
| | `branch` | Base branch name | `main`, `develop` | | ||
| | `queue_type` | Queue type | `main`, `bisection` | |
There was a problem hiding this comment.
to clarify: queue_type will be only main or bisection (it's an enum), whereas the examples for repo and branch are good but ultimately freeform text
|
|
||
| | Metric | Type | Description | | ||
| | --- | --- | --- | | ||
| | `mq_queue_depth_current` | Gauge | Number of PRs currently in the queue (excludes NOT\_READY PRs) | |
There was a problem hiding this comment.
| | `mq_queue_depth_current` | Gauge | Number of PRs currently in the queue (excludes NOT\_READY PRs) | | |
| | `mq_depth_current` | Gauge | Number of PRs currently in the queue (excludes PRs that are waiting to be mergeable before being admitted to the queue) | |
| | `mq_pr_restarts_1h_total` | Gauge | — | PR restarts (TESTING to PENDING transitions) in the last hour | | ||
| | `mq_pr_wait_duration_1h_seconds` | Histogram | `le` (bucket boundary) | Distribution of time PRs spent waiting before testing starts | | ||
| | `mq_pr_test_duration_1h_seconds` | Histogram | `le` (bucket boundary) | Distribution of time PRs spent in the testing phase | | ||
| | `mq_pr_time_in_queue_1h_seconds` | Histogram | `conclusion`, `le` | Distribution of total time in queue for PRs that concluded in the last hour | |
There was a problem hiding this comment.
this is not available yet - please remove for now
| # P95 total time in queue for merged PRs | ||
| histogram_quantile(0.95, mq_pr_time_in_queue_1h_seconds_bucket{conclusion="merged"}) |
There was a problem hiding this comment.
omit this until time in queue metric is added
| | Parameter | Required | Description | | ||
| | --- | --- | --- | | ||
| | `repo` | No | Repository in `owner/name` format. If omitted, returns metrics for all repositories in the organization. | | ||
| | `repoHost` | No | Repository host. Defaults to `github.com`. | |
There was a problem hiding this comment.
does not default, and is required if repo is passed - see note above
Summary
• Added new "Prometheus metrics endpoint" section to Metrics and monitoring with metrics table, scrape config, and Grafana query examples
• Added "Metrics Endpoints" section to API reference linking to the Prometheus docs
Context links
Files changed
merge-queue/administration/metrics.md— new Prometheus sectionmerge-queue/reference/merge.md— new Metrics Endpoints sectionOpen questions
/v1/merge-queue/metricsonapi.trunk.io)Test plan
🤖 Generated with Claude Code