Skip to content

Autodiscover: pass paths through builders instead of global paths#49537

Merged
orestisfl merged 13 commits intoelastic:mainfrom
orestisfl:autodiscover-global-paths
Apr 9, 2026
Merged

Autodiscover: pass paths through builders instead of global paths#49537
orestisfl merged 13 commits intoelastic:mainfrom
orestisfl:autodiscover-global-paths

Conversation

@orestisfl
Copy link
Copy Markdown
Contributor

@orestisfl orestisfl commented Mar 18, 2026

Proposed commit message

Thread an explicit *paths.Path parameter through the autodiscover subsystem (NewAutodiscoverBuildProviderAutodiscoverBuilderNewBuildersBuildBuilderBuilderConstructor) instead of relying on the global paths.Paths variable.

Also makes NewLogHints unexported (newLogHints) since it is only used via the autodiscover 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. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

How to test this PR locally

Create a filebeat.yml with hints-based autodiscover:

filebeat.autodiscover:
  providers:
    - type: docker
      hints.enabled: true
      hints.default_config:
        type: container
        paths:
          - /var/lib/docker/containers/${data.container.id}/*.log

output.console:
  pretty: true

Run filebeat and start a container with hint labels:

./filebeat -e -c filebeat.yml
# In another terminal:
docker run --label co.elastic.logs/module=nginx --rm nginx

Related issues

@orestisfl orestisfl self-assigned this Mar 18, 2026
@orestisfl orestisfl added bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-8.x Automated backport to the 8.x branch with mergify skip-changelog backport-9.2 Automated backport to the 9.2 branch backport-9.3 Automated backport to the 9.3 branch labels Mar 18, 2026
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

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

Pass *paths.Path from NewAutodiscover through BuildProvider and each
provider's AutodiscoverBuilder into NewBuilders, replacing the previous
nil/global approach. Also fixes a bug where the package name `paths`
was passed instead of the `path` parameter variable.
@orestisfl orestisfl marked this pull request as ready for review March 31, 2026 14:01
@orestisfl orestisfl requested review from a team as code owners March 31, 2026 14:01
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 859986c6-81d2-4a34-89e5-ba72f5324f48

📥 Commits

Reviewing files that changed from the base of the PR and between bde0009 and c9650af.

📒 Files selected for processing (1)
  • filebeat/beater/filebeat.go
✅ Files skipped from review due to trivial changes (1)
  • filebeat/beater/filebeat.go

📝 Walkthrough

Walkthrough

This change threads a *paths.Path parameter through the autodiscover initialization and builder/provider factory APIs. Constructor signatures for NewAutodiscover, builder and provider constructors, and registry Build functions were extended to accept a path *paths.Path and callers were updated to pass a paths instance or nil. Filebeat’s hints builder and related tests were changed to use an explicit paths object instead of the global paths singleton.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed PR successfully threads *paths.Path through autodiscover subsystem and replaces global paths.Paths dependency in hints builder, addressing #49460 requirements.
Out of Scope Changes check ✅ Passed All changes are scoped to autodiscover parameter threading and related builder signature updates; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Apr 3, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@pierrehilbert pierrehilbert added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Apr 3, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@gizas
Copy link
Copy Markdown
Contributor

gizas commented Apr 3, 2026

My only concern is if we have tested this in case of an upgrade from a previous version where the hints.paths dont exist.
What should happen in this case?

@gizas
Copy link
Copy Markdown
Contributor

gizas commented Apr 8, 2026

My only concern is if we have tested this in case of an upgrade from a previous version where the hints.paths dont exist. What should happen in this case?

We synced with Orestis, my comment was not accurate as this paths parameter refers to internal hints builder configuration.

@orestisfl orestisfl enabled auto-merge (squash) April 8, 2026 09:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

TL;DR

Both failed jobs are blocked by the same transient infrastructure error while provisioning the ECH test deployment: 502: Bad Gateway (POST /api/v1/deployments). Immediate action is to re-run the two FIPS ECH integration jobs.

Remediation

  • Re-run:
    • x-pack/filebeat: FIPS ECH Integration Tests
    • x-pack/metricbeat: FIPS ECH Integration Tests
  • If retries keep failing, investigate ECH API availability for deployment creation and use the logged request_id values for provider-side tracing.
Investigation details

Root Cause

The failures occur before beat test logic runs, during Terraform provisioning of the ECH deployment at testing/terraform-ech/ech.tf:54 (resource "ec_deployment" "default" {).

Evidence

Verification

  • Not run locally; failure is in external ECH deployment provisioning (POST /api/v1/deployments) rather than repository test code paths.

Follow-up

If this reproduces after retries, correlate those request_id values with ECH service logs and check for regional/provider-side instability.

Note

🔒 Integrity filtering filtered 1 item

Integrity filtering activated and filtered the following item during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.


What is this? | From workflow: PR Buildkite Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@orestisfl orestisfl merged commit 31d1c30 into elastic:main Apr 9, 2026
201 of 204 checks passed
mergify bot pushed a commit that referenced this pull request Apr 9, 2026
…9537)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)
mergify bot pushed a commit that referenced this pull request Apr 9, 2026
…9537)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)
@orestisfl orestisfl deleted the autodiscover-global-paths branch April 9, 2026 09:43
@orestisfl
Copy link
Copy Markdown
Contributor Author

@Mergifyio backport 8.19

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 9, 2026

backport 8.19

✅ Backports have been created

Details

Cherry-pick of 31d1c30 has failed:

On branch mergify/bp/8.19/pr-49537
Your branch is up to date with 'origin/8.19'.

You are currently cherry-picking commit 31d1c309a.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   filebeat/autodiscover/builder/hints/logs.go
	modified:   filebeat/beater/filebeat.go
	modified:   heartbeat/autodiscover/builder/hints/monitors.go
	modified:   heartbeat/beater/heartbeat.go
	modified:   libbeat/autodiscover/autodiscover.go
	modified:   libbeat/autodiscover/builder.go
	modified:   libbeat/autodiscover/builder_test.go
	modified:   libbeat/autodiscover/provider.go
	modified:   libbeat/autodiscover/providers/docker/docker.go
	modified:   libbeat/autodiscover/providers/docker/docker_integration_test.go
	modified:   libbeat/autodiscover/providers/jolokia/jolokia.go
	modified:   libbeat/autodiscover/providers/kubernetes/config_test.go
	modified:   libbeat/autodiscover/providers/kubernetes/kubernetes.go
	modified:   metricbeat/autodiscover/builder/hints/metrics.go
	modified:   metricbeat/beater/metricbeat.go
	modified:   x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go
	modified:   x-pack/libbeat/autodiscover/providers/aws/elb/provider.go
	modified:   x-pack/libbeat/autodiscover/providers/nomad/nomad.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   filebeat/autodiscover/builder/hints/logs_test.go
	both modified:   libbeat/autodiscover/autodiscover_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify bot pushed a commit that referenced this pull request Apr 9, 2026
…9537)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)

# Conflicts:
#	filebeat/autodiscover/builder/hints/logs_test.go
#	libbeat/autodiscover/autodiscover_test.go
orestisfl added a commit that referenced this pull request Apr 10, 2026
…9537) (#50023)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
orestisfl added a commit that referenced this pull request Apr 10, 2026
…9537) (#50024)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
orestisfl added a commit that referenced this pull request Apr 13, 2026
…tead of global paths (#50030)

* Autodiscover: pass paths through builders instead of global paths (#49537)

Thread an explicit `*paths.Path` parameter through the autodiscover subsystem (`NewAutodiscover` → `BuildProvider` → `AutodiscoverBuilder` → `NewBuilders` → `BuildBuilder` → `BuilderConstructor`) instead of relying on the global `paths.Paths` variable.

Also makes `NewLogHints` unexported (`newLogHints`) since it is only used via the autodiscover registry.

(cherry picked from commit 31d1c30)

# Conflicts:
#	filebeat/autodiscover/builder/hints/logs_test.go
#	libbeat/autodiscover/autodiscover_test.go

* Fix conflicts

---------

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify backport-9.2 Automated backport to the 9.2 branch backport-9.3 Automated backport to the 9.3 branch bug skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[beatreceiver] replace global paths in filebeat autodiscover hints builder

6 participants