Skip to content

Commit

Permalink
[8.7](backport #35024) x-pack/filebeat: Add Instance Id to trace file…
Browse files Browse the repository at this point in the history
…name (#35037)

* x-pack/filebeat: Add Instance Id to trace filename (#35024)

* Add Instance Id to trace filename

* Add for CEL input

* Add changelog

* fix lint issues

* restore lint changes

* Make * placeholder

* add docs

* update note

(cherry picked from commit 545f0f8)

* Update CHANGELOG.next.asciidoc

* Update CHANGELOG.next.asciidoc

---------

Co-authored-by: Bharat Pasupula <[email protected]>
  • Loading branch information
mergify[bot] and bhapas authored Apr 6, 2023
1 parent 68448f9 commit fd08baf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]

*Filebeat*
[Gcs Input] - Added missing locks for safe concurrency {pull}34914[34914]
- Add input instance id to request trace filename for httpjson and cel inputs {pull}35037[35037]

*Heartbeat*

Expand Down
3 changes: 3 additions & 0 deletions x-pack/filebeat/docs/inputs/input-cel.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ It is possible to log HTTP requests and responses in a CEL program to a local fi
This option is enabled by setting the `resource.tracer.filename` value. Additional options are available to
tune log rotation behavior.

To differentiate the trace files generated from different input instances, a placeholder `*` can be added to the filename and will be replaced with the input instance id.
For Example, `http-request-trace-*.ndjson`.

Enabling this option compromises security and should only be used for debugging.

[float]
Expand Down
3 changes: 3 additions & 0 deletions x-pack/filebeat/docs/inputs/input-httpjson.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ It is possible to log httpjson requests and responses to a local file-system for
This option is enabled by setting the `request.tracer.filename` value. Additional options are available to
tune log rotation behavior.

To differentiate the trace files generated from different input instances, a placeholder `*` can be added to the filename and will be replaced with the input instance id.
For Example, `http-request-trace-*.ndjson`.

Enabling this option compromises security and should only be used for debugging.

[float]
Expand Down
4 changes: 4 additions & 0 deletions x-pack/filebeat/input/cel/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (input) run(env v2.Context, src *source, cursor map[string]interface{}, pub

ctx := ctxtool.FromCanceller(env.Cancelation)

if cfg.Resource.Tracer != nil {
cfg.Resource.Tracer.Filename = strings.ReplaceAll(cfg.Resource.Tracer.Filename, "*", env.ID)
}

client, err := newClient(ctx, cfg, log)
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions x-pack/filebeat/input/httpjson/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func run(

stdCtx := ctxtool.FromCanceller(ctx.Cancelation)

if config.Request.Tracer != nil {
config.Request.Tracer.Filename = strings.ReplaceAll(config.Request.Tracer.Filename, "*", ctx.ID)
}

httpClient, err := newHTTPClient(stdCtx, config, log)
if err != nil {
return err
Expand Down

0 comments on commit fd08baf

Please sign in to comment.