Skip to content

Add workflow name and target labels#4240

Merged
nikola-jokic merged 1 commit intoactions:masterfrom
mumoshu:workflow-name-and-target-metric-labels
Sep 30, 2025
Merged

Add workflow name and target labels#4240
nikola-jokic merged 1 commit intoactions:masterfrom
mumoshu:workflow-name-and-target-metric-labels

Conversation

@mumoshu
Copy link
Copy Markdown
Collaborator

@mumoshu mumoshu commented Sep 8, 2025

Hey team 👋 Thank you very much for maintaining this awesome project!

This is for https://github.com/orgs/community/discussions/172708.

This PR adds job_workflow_name and job_workflow_target labels to all job-related Prometheus metrics, making it possible to track metrics by workflow name and differentiate between main branch builds, PRs, and tag releases.

# Job completed for pull request
gha_completed_jobs_total{
  enterprise="",
  event_name="pull_request",
  job_name="test-job",
  job_result="succeeded",
  job_workflow_name="ci-pipeline",              # NEW: workflow file name
  job_workflow_ref="example-org/example-repo/.github/workflows/ci-pipeline.yml@refs/pull/42/merge",
  job_workflow_target="pull/42",                # NEW: target ref (PR #42)
  organization="example-org",
  repository="example-repo"
} 1

# Job execution duration for branch push
gha_job_execution_duration_seconds_bucket{
  enterprise="",
  event_name="push",
  job_name="build",
  job_result="succeeded",
  job_workflow_name="deploy",                   # NEW: workflow file name
  job_workflow_ref="example-org/example-repo/.github/workflows/deploy.yml@refs/heads/main",
  job_workflow_target="heads/main",             # NEW: target ref (main branch)
  organization="example-org",
  repository="example-repo",
  le="30"
} 1

# Job startup duration for tag push
gha_job_startup_duration_seconds_sum{
  enterprise="",
  event_name="push",
  job_name="release",
  job_workflow_name="release-automation",       # NEW: workflow file name
  job_workflow_ref="example-org/example-repo/.github/workflows/release-automation.yml@refs/tags/v2.1.0",
  job_workflow_target="tags/v2.1.0",           # NEW: target ref (tag v2.1.0)
  organization="example-org",
  repository="example-repo"
} 15.5

I've tested this by locally running ARC on a kind cluster and triggering workflows against a test repo - the new labels are correctly populated for push, pull_request, and tag events.

While this could be a temporary solution until the Actions performance metrics page is enhanced with fine-grained metrics per job target (when applicable), I believe this is valuable to have today based on experience running ARC in production.

Copilot AI review requested due to automatic review settings September 8, 2025 05:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances Prometheus metrics for GitHub Actions Runner Controller by adding workflow name and target labels to job-related metrics. This enables better tracking and filtering of metrics by workflow name and distinguishing between different deployment targets (main branch, PRs, tags).

  • Adds job_workflow_name and job_workflow_target labels to all job-related metrics
  • Implements workflow reference parsing logic to extract meaningful workflow names and target information
  • Updates Helm chart documentation to reflect the new metric labels

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/ghalistener/metrics/workflow_ref_parser.go Implements parsing logic to extract workflow name and target from GitHub workflow references
cmd/ghalistener/metrics/workflow_ref_parser_test.go Comprehensive test suite for the workflow reference parser with various reference formats
cmd/ghalistener/metrics/metrics_integration_test.go Integration tests verifying the new labels are correctly populated in job metrics
cmd/ghalistener/metrics/metrics.go Updates job label creation to include the new workflow name and target labels
charts/gha-runner-scale-set/values.yaml Updates example metric configurations to include the new labels

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Extract PR number from refs/pull/{number}/merge
// Keep "pull/" prefix to indicate pull request
prPart := strings.TrimPrefix(ref, prPrefix)
if idx := strings.Index(prPart, "/"); idx > 0 {
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition idx > 0 should be idx >= 0 to handle the case where the PR number is at the start of the string. Currently, if prPart starts with the separator, the target won't be set.

Suggested change
if idx := strings.Index(prPart, "/"); idx > 0 {
if idx := strings.Index(prPart, "/"); idx >= 0 {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This intends to extract {number} out of refs/pull/{number}/merge by (1)TrimPrefix producing {number}/merge and (2)the idx here points the position of /.

If we allowed idx to be 0 like suggested, info.Target could potentially be pull/ without any number, which isn't useful anyway.

@mumoshu mumoshu force-pushed the workflow-name-and-target-metric-labels branch from 6f300de to 5585eaf Compare September 8, 2025 06:11
@nikola-jokic
Copy link
Copy Markdown
Collaborator

Hey @mumoshu,

First of all, your PRs are always well appreciated!

Quick question: since the workflow ref introduces a bit higher cardinality, wouldn't it be better to split the ref and only use these fields? We can split on '@' and use the first part as the workflow, and the second part as the target? I'd love to deduplicate information and reduce the storage. Since the next release is 0.13.0, we can create a breaking change as long as we call it out in the release. The way you explained the problem, it seems to me that it is more beneficial to users to have the ref split than to have it as a single label. I'm not sure that is why I have to ask ☺️

And feedback from others on this PR is always appreciated as well!

@nikola-jokic nikola-jokic added the gha-runner-scale-set Related to the gha-runner-scale-set mode label Sep 16, 2025
@mumoshu
Copy link
Copy Markdown
Collaborator Author

mumoshu commented Sep 30, 2025

Hey @nikola-jokic!

Removing the existing job_workflow_ref in favor of the new job_workflow_name (or call it job_workflow? Although I slightly prefer having _name) and job_workflow_target works if that's what you mean!

To be more precise about high cardinality, I was to omit the existing job_workflow_ref from my listenerMetrics. I.e., users won't suffer from high cardinality as long as they keep their previous listenerMetrics settings as-is. Pls let me know if I'm missing anything 🙏

Moving this forward, how about adding job_wofklow_name and job_workflow_target in this PR, and following up with another PR that removes job_workflow_ref?

That way, we can have some grace period to hear back from the community if we can safely remove job_worfklow_ref.

@Steve-Glass
Copy link
Copy Markdown
Collaborator

Moving this forward, how about adding job_wofklow_name and job_workflow_target in this PR, and following up with another PR that removes job_workflow_ref? That way, we can have some grace period to hear back from the community if we can safely remove job_worfklow_ref.

100% agree with this approach. Lets add it to the 0.13.0 release. We will maintain job_workflow_ref until the 0.14.0 release 😄

Copy link
Copy Markdown
Collaborator

@nikola-jokic nikola-jokic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@nikola-jokic nikola-jokic merged commit f731873 into actions:master Sep 30, 2025
20 of 21 checks passed
@mumoshu mumoshu deleted the workflow-name-and-target-metric-labels branch October 6, 2025 23:18
Okabe-Junya added a commit to mercari/actions-runner-controller that referenced this pull request Jan 5, 2026
* Updates: runner to v2.318.0 container-hooks to v0.6.1 (actions#3684)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Updates: runner to v2.319.0 (actions#3702)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Updates: runner to v2.319.1 (actions#3708)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bassem Dghaidi <[email protected]>

* Add exponential backoff when generating runner reg tokens (actions#3724)

* Updates: runner to v2.320.0 (actions#3763)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Updates: runner to v2.321.0 container-hooks to v0.6.2 (actions#3809)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix ARC e2e tests (actions#3836)

* Make EphemeralRunnerController MaxConcurrentReconciles configurable (actions#3832)

Co-authored-by: Bassem Dghaidi <[email protected]>

* Make EphemeralRunnerReconciler create runner pods earlier (actions#3831)

Co-authored-by: Bassem Dghaidi <[email protected]>

* Bump github.com/bradleyfalzon/ghinstallation/v2 from 2.8.0 to 2.12.0 (actions#3837)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bassem Dghaidi <[email protected]>

* Update docs with details for the dashboard visualizations (actions#3696)

Co-authored-by: Bassem Dghaidi <[email protected]>

* Make k8s client rate limiter parameters configurable (actions#3848)

Co-authored-by: Taketoshi Fujiwara <[email protected]>

* Bump golang.org/x/crypto from 0.22.0 to 0.31.0 (actions#3844)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bassem Dghaidi <[email protected]>

* Prepare `0.10.0` release (actions#3849)

* Fix helm chart bug related to `runnerMaxConcurrentReconciles` (actions#3858)

* Prepare `0.10.1` release (actions#3859)

* Update dependabot config to group packages (& include actions eco) (actions#3880)

* Fix template tests and add go test on gha-validate-chart (actions#3886)

* cmd/ghalistener/config: export Validate (actions#3870)

Co-authored-by: Han-Wen Nienhuys <[email protected]>

* Updated dead link (actions#3830)

Co-authored-by: Nikola Jokic <[email protected]>

* docs: end markdown code block correctly (actions#3736)

* Clarify syntax for `githubConfigSecret` (actions#3812)

Co-authored-by: Bassem Dghaidi <[email protected]>

* Bump golang.org/x/net from 0.25.0 to 0.33.0 (actions#3881)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nikola Jokic <[email protected]>

* Updates: runner to v2.322.0 (actions#3893)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Sanitize labels ending in hyphen, underscore, and dot (actions#3664)

* metrics cardinality for ghalistener (actions#3671)

Co-authored-by: Bassem Dghaidi <[email protected]>
Co-authored-by: Nikola Jokic <[email protected]>

* Rename log from target/actual to build/autoscalingRunnerSet version (actions#3957)

* Use Ready from the pod conditions when setting it to the EphemeralRunner (actions#3891)

* AutoscalingRunnerSet env: not Rendering correctly (actions#3826)

Co-authored-by: Nikola Jokic <[email protected]>

* Drop verbose flag from runner scale set init-dind-externals copy (actions#3805)

* Include custom annotations and labels to all resources created by `gha-runner-scale-set` chart (actions#3934)

* Remove old githubrunnerscalesetlistener, remove warning and fix config bug (actions#3937)

* Wrap errors in controller helper methods and swap logic in cleanups (actions#3960)

* Clean up as much as possible in a single pass for the EphemeralRunner reconciler (actions#3941)

* Use gha-runner-scale-set-controller.chart instead of .Chart.Version (actions#3729)

Co-authored-by: Nikola Jokic <[email protected]>

* Trim volume and container helpers in gha-runner-scale-set (actions#3807)

Co-authored-by: Bassem Dghaidi <[email protected]>

* Small readme updates for readability  (actions#3860)

* Update all dependencies, conforming to the new controller-runtime API (actions#3949)

* feat: allow namespace overrides (actions#3797)

Signed-off-by: Jesús Fernández <[email protected]>
Co-authored-by: Nikola Jokic <[email protected]>

* chore: Added `OwnerReferences` during resource creation for `EphemeralRunnerSet`, `EphemeralRunner`, and `EphemeralRunnerPod` (actions#3575)

* Updates: runner to v2.323.0 (actions#3976)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Bump github.com/golang-jwt/jwt/v4 from 4.5.1 to 4.5.2 (actions#3984)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add events role permission to leader_election_role (actions#3988)

* Create configurable metrics (actions#3975)

* Prepare 0.11.0 release (actions#3992)

* Fix busy runners metric (actions#4016)

* Bump the gomod group across 1 directory with 7 updates (actions#4008)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nikola Jokic <[email protected]>

* Include more context to errors raised by github/actions client (actions#4032)

Co-authored-by: Copilot <[email protected]>

* Pin third party actions (actions#3981)

* upgrade(golangci-lint): v2.1.2  (actions#4023)

Signed-off-by: karamaru-alpha <[email protected]>

* Revised dashboard (actions#4022)

* feat(helm): move dind to sidecar (actions#3842)

* Fix code block fences (actions#3140)

Co-authored-by: Mosè Giordano <[email protected]>

* Add missing backtick to metrics.serviceMonitor.namespace line to correct formatting (actions#3790)

* Bump go version (actions#4075)

* Create backoff mechanism for failed runners and allow re-creation of failed ephemeral runners (actions#4059)

* Updates: runner to v2.324.0 container-hooks to v0.7.0 (actions#4086)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix docker lint warnings (actions#4074)

* Relax version requirements to allow patch version mismatch (actions#4080)

Co-authored-by: Copilot <[email protected]>

* Refactor resource naming removing unnecessary calculations (actions#4076)

* Allow use of client id as an app id (actions#4057)

* Updates: runner to v2.325.0 (actions#4109)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add job_workflow_ref label to listener metrics (actions#4054)

Signed-off-by: rskmm0chang <[email protected]>

* Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 (actions#4118)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add startup probe to dind side-car (actions#4117)

* Avoid nil point when config.Metrics is nil and expose all metrics if none are configured (actions#4101)

Co-authored-by: Nikola Jokic <[email protected]>

* Add response body to error when fetching access token (actions#4005)

Co-authored-by: mluffman <[email protected]>
Co-authored-by: Nikola Jokic <[email protected]>

* Delete config secret when listener pod gets deleted (actions#4033)

Co-authored-by: Nikola Jokic <[email protected]>

* Azure Key Vault integration to resolve secrets (actions#4090)

* Bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 (actions#4120)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Prepare 0.12.0 release (actions#4122)

* Bump build-push-action to 6.18.0 (actions#4123)

* Remove cache for build-push-action (actions#4124)

* Fix indentation of startupProbe attributes in dind sidecar (actions#4126)

* Fix dind sidecar template (actions#4128)

* Remove duplicate float64 call (actions#4139)

* Remove check if runner exists after exit code 0 (actions#4142)

* Explicitly requeue during backoff ephemeral runner (actions#4152)

* Prepare 0.12.1 release (actions#4153)

* Update CodeQL workflow for v3 (global-run-codeql.yaml) (actions#4157)

* Bump the actions group across 1 directory with 5 updates (actions#4160)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(runner): add ubuntu 24.04 support (actions#3598)

* Fix image pull secrets list arguments in the chart (actions#4164)

* Remove workflow actions version comments since upgrades are done via dependabot (actions#4161)

* Updates: runner to v2.326.0 (actions#4176)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update example GitHub URLs in values.yaml to include an example for enterprise account-level runners (actions#4181)

* Add Missing Languages to CodeQL Advanced Configuration (actions#4179)

* Updates: runner to v2.327.0 (actions#4185)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove deprecated preserveUnknownFields from CRDs (actions#4135)

* Updates: runner to v2.327.1 (actions#4188)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove JIT config from ephemeral runner status field (actions#4191)

* Fix usage of underscore in Runner Scale Set name (actions#3545)

Co-authored-by: Nikola Jokic <[email protected]>

* Bump docker/login-action from 3.4.0 to 3.5.0 in the actions group (actions#4196)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/checkout from 4 to 5 in the actions group (actions#4205)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updates: runner to v2.328.0 (actions#4209)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Requeue if create pod returns already exists error (actions#4201)

* docs: fix repo path typo (actions#4229)

* Update CODEOWNERS (actions#4251)

* Update CODEOWNERS to include new maintainer (actions#4253)

* Remove ephemeral runner when exit code != 0 and is patched with the job (actions#4239)

* Add workflow name and target labels (actions#4240)

* Bump the actions group across 1 directory with 5 updates (actions#4262)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Introduce new kubernetes-novolume mode (actions#4250)

Co-authored-by: Copilot <[email protected]>

* Ensure ephemeral runner is deleted from the service on exit != 0 (actions#4260)

* docs: fix broken Grafana dashboard JSON path (actions#4270)

* Potential fix for code scanning alert no. 3: Workflow does not contain permissions (actions#4273)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 1: Workflow does not contain permissions (actions#4274)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: jiaren-wu <[email protected]>
Co-authored-by: Copilot <[email protected]>

* Bump all dependencies (actions#4266)

* Bump the gomod group across 1 directory with 4 updates (actions#4277)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Prepare 0.13.0 release (actions#4280)

* Revert "gha: customize client-go rate limiter params (#4)"

This reverts commit 8728190.
Keep several instrumentations

* Revert "gha: make MaxConcurrentReconciles for each reconciler configurable (#1)"

This reverts commit 057a1e7.

* chore(chart): bump version to 0.13.0-rc.1 for testing

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Jesús Fernández <[email protected]>
Signed-off-by: karamaru-alpha <[email protected]>
Signed-off-by: rskmm0chang <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bassem Dghaidi <[email protected]>
Co-authored-by: Yusuke Kuoka <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ken Muse <[email protected]>
Co-authored-by: Taketoshi Fujiwara <[email protected]>
Co-authored-by: Rob Herley <[email protected]>
Co-authored-by: Nikola Jokic <[email protected]>
Co-authored-by: Han-Wen Nienhuys <[email protected]>
Co-authored-by: Han-Wen Nienhuys <[email protected]>
Co-authored-by: Matteo Bianchi <[email protected]>
Co-authored-by: James Ward <[email protected]>
Co-authored-by: John Wesley Walker III <[email protected]>
Co-authored-by: &es <[email protected]>
Co-authored-by: Chris Johnston <[email protected]>
Co-authored-by: thinkbiggerltd <[email protected]>
Co-authored-by: Cees-Jan Kiewiet <[email protected]>
Co-authored-by: Mikey Smet <[email protected]>
Co-authored-by: Patrick Vickery <[email protected]>
Co-authored-by: Salman Chishti <[email protected]>
Co-authored-by: J. Fernández <[email protected]>
Co-authored-by: kahirokunn <[email protected]>
Co-authored-by: David Maxwell <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Ryosei Karaki <[email protected]>
Co-authored-by: Borislav Velkov <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Co-authored-by: scodef <[email protected]>
Co-authored-by: Ryo Sakamoto <[email protected]>
Co-authored-by: Tingluo Huang <[email protected]>
Co-authored-by: Nash Luffman <[email protected]>
Co-authored-by: mluffman <[email protected]>
Co-authored-by: Wim Fournier <[email protected]>
Co-authored-by: Jeev B <[email protected]>
Co-authored-by: Mark Huijgen <[email protected]>
Co-authored-by: calx <[email protected]>
Co-authored-by: adjn <[email protected]>
Co-authored-by: Ho Kim <[email protected]>
Co-authored-by: Cory Calahan <[email protected]>
Co-authored-by: Kylie Stradley <[email protected]>
Co-authored-by: Alex Hatzenbuhler <[email protected]>
Co-authored-by: clechevalli <[email protected]>
Co-authored-by: zkpepe <[email protected]>
Co-authored-by: Dennis Stone <[email protected]>
Co-authored-by: Berat Postalcioglu <[email protected]>
Co-authored-by: Jiaren Wu <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: jiaren-wu <[email protected]>
Co-authored-by: Junya Okabe <[email protected]>
unpollito pushed a commit to DistruApp/actions-runner-controller that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gha-runner-scale-set Related to the gha-runner-scale-set mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants