Skip to content

Fix panic in winlog input#45730

Merged
faec merged 4 commits intoelastic:mainfrom
faec:winlog-crash-fix
Aug 4, 2025
Merged

Fix panic in winlog input#45730
faec merged 4 commits intoelastic:mainfrom
faec:winlog-crash-fix

Conversation

@faec
Copy link
Contributor

@faec faec commented Aug 4, 2025

Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:

  • winlog always uses a source id that is the same as its input id
  • winlog still used the global input metrics helpers in the inputmon package instead of the metrics registry provided by the Filebeat inputs API
  • winlog is the only input that did not add a scope prefix on the id provided to inputmon.NewInputRegistry, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@faec faec self-assigned this Aug 4, 2025
@faec faec requested review from a team as code owners August 4, 2025 17:06
@faec faec added bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Aug 4, 2025
@faec faec requested review from leehinman and mauri870 August 4, 2025 17:06
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 4, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @faec? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.
@faec faec added the backport-active-all Automated backport with mergify to all the active branches label Aug 4, 2025
Copy link
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! I don't see anything wrong with the code, but I'm not experienced enough with Winlogbeat to give detailed feedback. Appreciate you adding a test.

@faec faec merged commit 4081f24 into elastic:main Aug 4, 2025
204 of 207 checks passed
@faec faec deleted the winlog-crash-fix branch August 4, 2025 21:42
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2025

backport 8.17 8.18 8.19 9.0 9.1

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Aug 4, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

# Conflicts:
#	libbeat/monitoring/inputmon/httphandler.go
#	libbeat/monitoring/inputmon/input_test.go
#	winlogbeat/beater/eventlogger.go
#	winlogbeat/eventlog/metrics.go
#	winlogbeat/eventlog/wineventlog.go
mergify bot pushed a commit that referenced this pull request Aug 4, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

# Conflicts:
#	filebeat/input/winlog/input.go
#	libbeat/monitoring/inputmon/httphandler.go
#	libbeat/monitoring/inputmon/input_test.go
#	winlogbeat/beater/eventlogger.go
#	winlogbeat/eventlog/metrics.go
#	winlogbeat/eventlog/runner.go
#	winlogbeat/eventlog/wineventlog.go
mergify bot pushed a commit that referenced this pull request Aug 4, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

# Conflicts:
#	winlogbeat/eventlog/metrics.go
#	winlogbeat/eventlog/wineventlog.go
mergify bot pushed a commit that referenced this pull request Aug 4, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

# Conflicts:
#	libbeat/monitoring/inputmon/httphandler.go
#	libbeat/monitoring/inputmon/input_test.go
mergify bot pushed a commit that referenced this pull request Aug 4, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)
faec added a commit that referenced this pull request Aug 4, 2025
* Fix panic in winlog input (#45730)

Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

* fix changelog merge

---------

Co-authored-by: Fae Charlton <fae.charlton@elastic.co>
ebeahan pushed a commit that referenced this pull request Aug 5, 2025
* Fix panic in winlog input (#45730)

Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry #45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.

(cherry picked from commit 4081f24)

# Conflicts:
#	winlogbeat/eventlog/metrics.go
#	winlogbeat/eventlog/wineventlog.go

* fix merge

* fix merge for raw event logs that only exist in 8.x

* remove nil access of unused field

---------

Co-authored-by: Fae Charlton <fae.charlton@elastic.co>
rdner pushed a commit to colleenmcginnis/beats that referenced this pull request Aug 7, 2025
Fixes a panic in the winlog input that happened because of a conflict in the internal id of its metrics registry elastic#45693.

When checking whether a registry input id already exists, the check didn't include the ids of input registries with "nested" type (which are unreported containers for cursor-based inputs that can have several sub-inputs inside).

This is usually not a problem because the default (and what most inputs use even when overriding their id, e.g. I think this is why it probably didn't hit the GCP input) is to use a scoped id like "input_id::source_id", so they don't conflict with the container which has bare id "input_id".
This hit winlog in particular because:
- winlog always uses a source id that is the same as its input id
- winlog still used the global input metrics helpers in the `inputmon` package instead of the metrics registry provided by the Filebeat inputs API
- winlog is the only input that did not add a scope prefix on the id provided to `inputmon.NewInputRegistry`, so the globally-created registry conflicted with the input manager's container (and this conflict was missed because of the missed "nested" type check above).

Fixing the missed "nested" collision check would prevent the input panic, but the collision itself would still exist and prevent winlog input metrics from being reported.

This PR both fixes the missed "nested" conflict check and removes the deprecated global metrics call from the winlog input, replacing it with the API-provided registry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

5 participants