Skip to content

feat(inputs.webhooks.github): Add run_id field to workflow events - #19157

Merged
srebhan merged 7 commits into
influxdata:masterfrom
warintara:master
Jul 31, 2026
Merged

srebhan merged 7 commits into
influxdata:masterfrom
warintara:master

Conversation

@warintara

@warintara warintara commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Added run_id field to the Telegraf GitHub webhook plugin's workflow_run event parsing.

Changes:

  • Added ID int64 to the workflowRun struct to deserialize the id field from the GitHub webhook JSON payload
  • Added run_id to the InfluxDB fields map in workflowRunEvent.newMetric() so the value is stored in the database

Why: The GitHub Actions run ID is the unique identifier used in GitHub Action URLs (/actions/runs/<run_id>). Without
storing it, there was no way to build direct links from the Grafana dashboard back to the specific GitHub Actions
run. This change enables linking each row in the dashboard to its corresponding GitHub Actions page.

Checklist

Related issues

resolves #19158

@telegraf-tiger

Copy link
Copy Markdown
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@warintara

warintara commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor Author

!signed-cla

@warintara
warintara marked this pull request as ready for review June 29, 2026 08:49
@warintara warintara changed the title Added run_id field to the Telegraf GitHub webhook plugin's workflow_r… feat(github_webhooks): add run_id field to workflow_run events Jun 30, 2026
@telegraf-tiger telegraf-tiger Bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 30, 2026
@warintara
warintara marked this pull request as draft June 30, 2026 11:54
@warintara
warintara marked this pull request as ready for review June 30, 2026 11:54
@warintara

Copy link
Copy Markdown
Contributor Author

Hello @srebhan @skartikey, could you please take a look at this PR when you have a moment? Let me know if you have any questions or need any clarifications. Thank you!

@skartikey

Copy link
Copy Markdown
Contributor

plugins/inputs/webhooks/github/README.md:456-459 - the workflow_run event section documents every emitted field (the "Fields:" list at line 454), and the new run_id is missing. Please add it to that list:

* 'run_id' = `event.workflow_run.id` int

@skartikey skartikey changed the title feat(github_webhooks): add run_id field to workflow_run events feat(inputs.webhooks.github): Add run_id field to workflow_run events Jul 13, 2026
@skartikey skartikey self-assigned this Jul 13, 2026
@warintara

Copy link
Copy Markdown
Contributor Author

Done, I have added run_id to the Fields list in the README. Thanks for the feedback! @skartikey

@skartikey

Copy link
Copy Markdown
Contributor

README entry looks good now, and the field itself is the right call: as a tag a run id would blow up series cardinality, and int64 avoids the wrap a plain int would hit on the i386 build.

Two things before I approve. TestWorkflowRun only checks for a 200, so nothing catches a misspelled json tag or a value that never reaches the metric, and the fixture already carries "id": 12537003369 so the assertion is nearly free. The workflow_job payload also carries the parent run in workflow_job.run_id (there id is the job id), and the link use case is the same, so it would be good to cover both events in one go.

The patch below does both: adds run_id to workflow_job with a README entry, and makes both workflow tests assert the full metric. Tests, golangci-lint and markdownlint are clean locally, and each assertion does fail if the matching run_id line is removed. Take it, adapt it, or say the word if you would rather keep this PR to workflow_run and do jobs separately. If you take the workflow_job half, please retitle to something like feat(inputs.webhooks.github): Add run_id field to workflow events and mention both events in the description, since release notes come from the title and #19158 is scoped to workflow_run only.

diff --git a/plugins/inputs/webhooks/github/README.md b/plugins/inputs/webhooks/github/README.md
--- a/plugins/inputs/webhooks/github/README.md
+++ b/plugins/inputs/webhooks/github/README.md
@@ -437,6 +437,7 @@ where the data is sourced from.
 * 'run_time' = `event.workflow_job.completed_at - event.workflow_job.started_at`
                 at `event.action = completed in milliseconds` int
 * 'head_branch' = `event.workflow_job.head_branch` string
+* 'run_id' = `event.workflow_job.run_id` int
 
 ### [`workflow_run` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run)
 
diff --git a/plugins/inputs/webhooks/github/github_webhooks_models.go b/plugins/inputs/webhooks/github/github_webhooks_models.go
--- a/plugins/inputs/webhooks/github/github_webhooks_models.go
+++ b/plugins/inputs/webhooks/github/github_webhooks_models.go
@@ -76,6 +76,7 @@ type pullRequestReviewComment struct {
 }
 
 type workflowJob struct {
+	RunID       int64     `json:"run_id"`
 	RunAttempt  int       `json:"run_attempt"`
 	HeadBranch  string    `json:"head_branch"`
 	CreatedAt   time.Time `json:"created_at"`
@@ -701,6 +702,7 @@ func (s workflowJobEvent) newMetric() telegraf.Metric {
 		"queue_time":  queueTimeMs,
 		"run_time":    runTimeMs,
 		"head_branch": s.WorkflowJob.HeadBranch,
+		"run_id":      s.WorkflowJob.RunID,
 	}
 	m := metric.New(meas, t, f, time.Now())
 	return m
diff --git a/plugins/inputs/webhooks/github/github_webhooks_test.go b/plugins/inputs/webhooks/github/github_webhooks_test.go
--- a/plugins/inputs/webhooks/github/github_webhooks_test.go
+++ b/plugins/inputs/webhooks/github/github_webhooks_test.go
@@ -5,13 +5,16 @@ import (
 	"net/http/httptest"
 	"strings"
 	"testing"
+	"time"
 
 	"github.com/stretchr/testify/require"
 
+	"github.com/influxdata/telegraf"
+	"github.com/influxdata/telegraf/metric"
 	"github.com/influxdata/telegraf/testutil"
 )
 
-func githubWebhookRequest(t *testing.T, event, jsonString string) {
+func githubWebhookRequest(t *testing.T, event, jsonString string) *testutil.Accumulator {
 	var acc testutil.Accumulator
 	gh := &Webhook{Path: "/github", acc: &acc, log: testutil.Logger{}}
 	req, err := http.NewRequest("POST", "/github", strings.NewReader(jsonString))
@@ -22,6 +25,7 @@ func githubWebhookRequest(t *testing.T, event, jsonString string) {
 	if w.Code != http.StatusOK {
 		t.Errorf("POST "+event+" returned HTTP status code %v.\nExpected %v", w.Code, http.StatusOK)
 	}
+	return &acc
 }
 
 func githubWebhookRequestWithSignature(t *testing.T, event, jsonString, signature string, expectedStatus int) {
@@ -127,11 +131,60 @@ func TestEventWithSignatureSuccess(t *testing.T) {
 }
 
 func TestWorkflowJob(t *testing.T) {
-	githubWebhookRequest(t, "workflow_job", WorkflowJobJSON())
+	acc := githubWebhookRequest(t, "workflow_job", WorkflowJobJSON())
+
+	expected := []telegraf.Metric{
+		metric.New(
+			"github_webhooks",
+			map[string]string{
+				"event":      "workflow_job",
+				"action":     "completed",
+				"repository": "DeusDeorum1/yhome-controller",
+				"private":    "true",
+				"user":       "DeusDeorum1",
+				"admin":      "false",
+				"name":       "Run build",
+				"conclusion": "success",
+			},
+			map[string]any{
+				"run_attempt": 1,
+				"queue_time":  int64(0),
+				"run_time":    int64(27000),
+				"head_branch": "feature/test",
+				"run_id":      int64(12537003369),
+			},
+			time.Unix(0, 0),
+		),
+	}
+	testutil.RequireMetricsEqual(t, expected, acc.GetTelegrafMetrics(), testutil.IgnoreTime())
 }
 
 func TestWorkflowRun(t *testing.T) {
-	githubWebhookRequest(t, "workflow_run", WorkflowRunJSON())
+	acc := githubWebhookRequest(t, "workflow_run", WorkflowRunJSON())
+
+	expected := []telegraf.Metric{
+		metric.New(
+			"github_webhooks",
+			map[string]string{
+				"event":      "workflow_run",
+				"action":     "completed",
+				"repository": "DeusDeorum1/yhome-controller",
+				"private":    "true",
+				"user":       "DeusDeorum1",
+				"admin":      "false",
+				"name":       ".NET",
+				"conclusion": "success",
+			},
+			map[string]any{
+				"run_attempt": 1,
+				"run_time":    int64(86000),
+				"head_branch": "feature/test",
+				"run_id":      int64(12537003369),
+			},
+			time.Unix(0, 0),
+		),
+	}
+	testutil.RequireMetricsEqual(t, expected, acc.GetTelegrafMetrics(), testutil.IgnoreTime())
 }
 
 func TestCheckSignatureSuccess(t *testing.T) {

@telegraf-tiger

Copy link
Copy Markdown
Contributor

@warintara

Copy link
Copy Markdown
Contributor Author

Hello @skartikey, all changes from your patch have been applied : run_id added to workflow_job in the models, both test functions now assert the full metric including run_id, and the README entry for workflow_job is in place too. The PR title has been updated to reflect both events. Thanks for the thorough review!

@skartikey skartikey changed the title feat(inputs.webhooks.github): Add run_id field to workflow_run events feat(inputs.webhooks.github): Add run_id field to workflow events Jul 29, 2026

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@warintara Thanks!

@skartikey skartikey added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 29, 2026
@skartikey skartikey removed their assignment Jul 30, 2026

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. Thanks @warintara for your contribution!

@srebhan
srebhan merged commit ff83bab into influxdata:master Jul 31, 2026
29 checks passed
@github-actions github-actions Bot added this to the v1.40.0 milestone Jul 31, 2026
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
telegraf 1.40.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v1.40.0 [2026-09-07]

### Important Changes

- PR [#19440](influxdata/telegraf#19440) fixes an issue
  in `inputs.cisco_telemetry_mdt` by now respecting the configured aliases. This
  might change the metric name for microburst and RIB data if set aliases.
  Please check your metric names and remove aliases if necessary.
- PR [#19451](influxdata/telegraf#19451) fixes an issue
  in `inputs.cisco_telemetry_mdt` by avoiding spurious metrics for RIB data.
  Please check your metrics and queries for the mentioned data.
- PR [#19456](influxdata/telegraf#19456) fixes the row
  numbering for table data in `inputs.cisco_telemetry_mdt`.
  Please check your metrics and queries for the mentioned data.
- PR [#19463](influxdata/telegraf#19463) fixes an issue
  in `inputs.cisco_telemetry_mdt` by avoiding spurious tags leaking into parent
  metrics. Please check your metrics and queries for the mentioned data.
- PR [#19624](influxdata/telegraf#19624) fixes the unit
  of `power_on_hours` in `inputs.smart` for drives reporting the attribute as
  a duration (e.g. `182h+39m+24.879s`). The value was previously reported in
  seconds and is now reported in hours. Please check your queries and
  dashboards for the mentioned field.

### Breaking Changes

- [#19125](influxdata/telegraf#19125) `inputs.aerospike` Remove deprecated plugin
- [#19451](influxdata/telegraf#19451) `inputs.cisco_telemetry_mdt` Avoid spurious metrics by collecting tags first
- [#19456](influxdata/telegraf#19456) `inputs.cisco_telemetry_mdt` Emit correct row numbers
- [#19463](influxdata/telegraf#19463) `inputs.cisco_telemetry_mdt` Prevent tags leaking to parent structures
- [#19440](influxdata/telegraf#19440) `inputs.cisco_telemetry_mdt` Respect aliases for RIB and microburst metric names
- [#19131](influxdata/telegraf#19131) `inputs.kafka_consumer` Remove deprecated connection_strategy option
- [#19130](influxdata/telegraf#19130) `inputs.openstack` Remove deprecated server_diagnotics option
- [#19118](influxdata/telegraf#19118) `inputs.procstat` Remove deprecated options
- [#19124](influxdata/telegraf#19124) `inputs.sflow` Remove deprecated plugin
- [#19132](influxdata/telegraf#19132) `inputs.tail` Remove deprecated from_beginning option
- [#19123](influxdata/telegraf#19123) `outputs.amon` Remove deprecated plugin

### New Plugins

- [#19551](influxdata/telegraf#19551) `inputs.fritzbox_smarthome` Add plugin
- [#19444](influxdata/telegraf#19444) `outputs.zerobus` Add plugin

### Features

- [#19331](influxdata/telegraf#19331) `agent` Add command for removing secrets from a store
- [#19092](influxdata/telegraf#19092) `config` Add setting to skip processors before aggregators
- [#19326](influxdata/telegraf#19326) `inputs.elasticsearch_query` Add ES v7 support
- [#19368](influxdata/telegraf#19368) `inputs.elasticsearch_query` Add ES v8 support
- [#19392](influxdata/telegraf#19392) `inputs.elasticsearch_query` Add ES v9 support
- [#19135](influxdata/telegraf#19135) `inputs.filecount` Adding timeout option
- [#19377](influxdata/telegraf#19377) `inputs.internet_speed` Allow binding to local address
- [#19320](influxdata/telegraf#19320) `inputs.kapacitor` Allow to add url tag for nested metrics
- [#19455](influxdata/telegraf#19455) `inputs.nvidia_smi` Add clock event fields for schema v11, v12, and v13
- [#19407](influxdata/telegraf#19407) `inputs.nvidia_smi` Add thermal, power and PCIe fields for schema v12
- [#19406](influxdata/telegraf#19406) `inputs.nvidia_smi` Add throttle counter, thermal, power and PCIe fields for schema v13
- [#19005](influxdata/telegraf#19005) `inputs.opcua_listener` Add workaround to split large subscriptions
- [#19116](influxdata/telegraf#19116) `inputs.ping` Add interface argument support for Windows
- [#19080](influxdata/telegraf#19080) `inputs.ping` Add support for unprivileged SOCK_DGRAM sockets
- [#19570](influxdata/telegraf#19570) `inputs.prometheus` Allow configuring the pod name tag name
- [#19046](influxdata/telegraf#19046) `inputs.proxmox` Add disk and network I/O metrics
- [#19617](influxdata/telegraf#19617) `inputs.ras` Add ECC error counter
- [#18679](influxdata/telegraf#18679) `inputs.smartctl` Add new metric version avoiding attribute overriding device name
- [#19157](influxdata/telegraf#19157) `inputs.webhooks.github` Add run_id field to workflow events
- [#19321](influxdata/telegraf#19321) `inputs.win_eventlog` Mark subscription failures as retriable startup errors
- [#19098](influxdata/telegraf#19098) `migrations` Add migration for inputs.zookeeper TLS option
- [#19097](influxdata/telegraf#19097) `migrations` Add migration for outputs.kafka TLS options
- [#19447](influxdata/telegraf#19447) `outputs.kafka` Add configurable produce request timeouts
- [#19581](influxdata/telegraf#19581) `outputs.parquet` Introduce partial write errors
- [#19040](influxdata/telegraf#19040) `outputs.socket_writer` Implement startup error behavior handling
- [#19044](influxdata/telegraf#19044) `outputs.sql` Remove need for init_sql on mysql connections
- [#19437](influxdata/telegraf#19437) `packaging` Extract govulncheck info from release binaries
- [#19493](influxdata/telegraf#19493) `packaging` Use signed binary in MacOS tar archives
- [#19365](influxdata/telegraf#19365) `parsers.grok` Allow parsing messages longer than 64KiB
- [#19329](influxdata/telegraf#19329) `secretstores.jose` Add support for removing secrets
- [#19328](influxdata/telegraf#19328) `secretstores.os` Add support for removing secrets
- [#19330](influxdata/telegraf#19330) `secretstores.vault` Add support for removing secrets
- [#19622](influxdata/telegraf#19622) `secretstores.vault` Allow using namespace

### Bugfixes

- [#19358](influxdata/telegraf#19358) `common.socket` Add interface name extraction and validation
- [#19572](influxdata/telegraf#19572) `config` Handle quotes at end of file without a trailing newline
- [#19575](influxdata/telegraf#19575) `inputs.amqp_consumer` Restore configuration to successfully reconnect
- [#19547](influxdata/telegraf#19547) `inputs.cloudwatch` Avoid caching failed listings
- [#19548](influxdata/telegraf#19548) `inputs.cloudwatch` Restore empty value to match all dimensions
- [#19513](influxdata/telegraf#19513) `inputs.cloudwatch` Restore explicit queries for non-wildcard namespaces
- [#19564](influxdata/telegraf#19564) `inputs.cloudwatch_metric_streams` Initialize close channel
- [#19450](influxdata/telegraf#19450) `inputs.internet_speed` Honor the local address setting
- [#19405](influxdata/telegraf#19405) `inputs.nvidia_smi` Parse integer fields as 64 bit
- [#19610](influxdata/telegraf#19610) `inputs.opcua` Respect the server's MaxNodesPerRead limit
- [#19443](influxdata/telegraf#19443) `inputs.procstat` Switch to more robust PidExists for liveness checks
- [#19624](influxdata/telegraf#19624) `inputs.smart` Report duration raw values in hours
- [#19445](influxdata/telegraf#19445) `inputs.win_eventlog` Do not replay the channel on restart
- [#19566](influxdata/telegraf#19566) `migrations.inputs_sflow` Set protocol on migrated config
- [#19464](influxdata/telegraf#19464) `outputs.amqp` Return error when the broker is unavailable
- [#19553](influxdata/telegraf#19553) `outputs.parquet` Mark value columns as nullable
- [#19555](influxdata/telegraf#19555) `outputs.parquet` Reserve the timestamp column for the metric time
- [#19573](influxdata/telegraf#19573) `outputs.parquet` Restrict files to configured directory
- [#19612](influxdata/telegraf#19612) `outputs.stackdriver` Classify write errors and stop abandoning chunks
- [#19623](influxdata/telegraf#19623) `processors.reverse_dns` Handle NXDOMAIN error correctly
- [#19412](influxdata/telegraf#19412) `serializers.prometheusremotewrite` Accumulate histogram samples in a batch

### Dependency Updates

- [#19421](influxdata/telegraf#19421) `deps` Bump cloud.google.com/go/auth from 0.22.0 to 0.23.0
- [#19474](influxdata/telegraf#19474) `deps` Bump cloud.google.com/go/auth from 0.23.0 to 0.23.1
- [#19534](https://github.com/influxdat

See merge request: Harmonybrew/homebrew-core!18657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inputs/webhooks/github: add run_id field to workflow_run event

3 participants