diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 2bdfe580681..f9adc3a1424 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -104,6 +104,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff] - [Gcs Input] - Added missing locks for safe concurrency {pull}34914[34914] - Fix the ignore_inactive option being ignored in Filebeat's filestream input {pull}34770[34770] - Fix TestMultiEventForEOFRetryHandlerInput unit test of CometD input {pull}34903[34903] +- Add input instance id to request trace filename for httpjson and cel inputs {pull}35024[35024] *Heartbeat* diff --git a/x-pack/filebeat/docs/inputs/input-cel.asciidoc b/x-pack/filebeat/docs/inputs/input-cel.asciidoc index 83ec572d859..0fd432b96a8 100644 --- a/x-pack/filebeat/docs/inputs/input-cel.asciidoc +++ b/x-pack/filebeat/docs/inputs/input-cel.asciidoc @@ -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] diff --git a/x-pack/filebeat/docs/inputs/input-httpjson.asciidoc b/x-pack/filebeat/docs/inputs/input-httpjson.asciidoc index 92fd6d15936..87efc658dc0 100644 --- a/x-pack/filebeat/docs/inputs/input-httpjson.asciidoc +++ b/x-pack/filebeat/docs/inputs/input-httpjson.asciidoc @@ -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] diff --git a/x-pack/filebeat/input/cel/input.go b/x-pack/filebeat/input/cel/input.go index 716e581da72..07c20a3680e 100644 --- a/x-pack/filebeat/input/cel/input.go +++ b/x-pack/filebeat/input/cel/input.go @@ -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 diff --git a/x-pack/filebeat/input/httpjson/input.go b/x-pack/filebeat/input/httpjson/input.go index 2abf2d7e730..c10c2e80098 100644 --- a/x-pack/filebeat/input/httpjson/input.go +++ b/x-pack/filebeat/input/httpjson/input.go @@ -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