-
Notifications
You must be signed in to change notification settings - Fork 5k
javascript processor: replace global paths with per-beat paths #47870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Changes: - Add SetPaths(path *paths.Path) method to jsProcessor that accepts a per-beat paths configuration - Defer file-based source initialization until SetPaths is called - For inline sources, initialization still happens immediately in NewFromConfig - loadSources now takes a *paths.Path parameter and uses pathConfig.Resolve() instead of the global paths.Resolve() Fixes elastic#46988
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
🤖 GitHub commentsJust comment with:
|
|
@qcorporation we will need someone from your team to review here please. |
jrmolin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see how the change encapsulates the original implementation
| assert.ErrorContains(t, err, "SetPaths must be called") | ||
| }) | ||
|
|
||
| t.Run("after SetPaths on inline source", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should also test that it works without SetPaths on an inline source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in with inline source
| assert.Equal(t, true, v) | ||
| }) | ||
|
|
||
| t.Run("without SetPaths fails", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you test that it works with a SetPaths call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit that covers it in the with file test
| var err error | ||
|
|
||
| switch { | ||
| case p.File != "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see where p.File or p.Files would be set -- are they in the config? i don't know that this is getting executed anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, NewFromConfig which sets Config which is embedded in:
type jsProcessor struct {
Config
@jrmolin do you mean if the change intends to be backwards compatible from an API perspective? If yes, we settled on not allowing using with the default global paths: #47353 (comment) so the SetPaths call is mandatory. |
Proposed commit message
Changes:
Fixes #46988
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability.I have added an entry in./changelog/fragmentsusing the changelog tool.How to test this PR locally
Run filebeat with:
myconfig/test_processor.js:write some logs:
See output:
{ "@timestamp": "2025-12-02T18:09:36.488Z", "@metadata": { "beat": "filebeat", "type": "_doc", "version": "9.3.0" }, "ecs": { "version": "8.0.0" }, "log": { "offset": 89586, "file": { "path": "/tmp/logs/a.log", "device_id": "38", "inode": "73159", "fingerprint": "83016ba24a8d31ccb16d2230eabcb1f043fa4c65914339eb954619b5c13fd55a" } }, "message": "some log", "input": { "type": "filestream" }, "js_processor": { "processed": true, "timestamp": "2025-12-02T18:09:36.488Z" }, "message_upper": "SOME LOG", "host": { "name": "laptop" }, "agent": { "version": "9.3.0", "ephemeral_id": "f6bb5c64-d2d1-4dad-a0e1-bbc553b617ec", "id": "40aef7d0-efcb-4613-a1df-d9bc42ff36b9", "name": "laptop", "type": "filebeat" } }Related issues