From cb6c629c0e2f372f445a7821a423dcfbdb75b8e5 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Mon, 22 Jan 2024 06:40:23 +1030 Subject: [PATCH] x-pack/filebeat/input/httpjson: propagate request trace configuration to chain children This ensures that all chain child clients will log request traces with the same details as the top level request trace logger. --- CHANGELOG.next.asciidoc | 1 + x-pack/filebeat/input/httpjson/input.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index c6b4b4e6e4f3..9afbaf2e5871 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -167,6 +167,7 @@ Setting environmental variable ELASTIC_NETINFO:false in Elastic Agent pod will d - Update CEL extensions library to v1.7.0. {pull}37172[37172] - Add support for complete URL replacement in HTTPJSON chain steps. {pull}37486[37486] - Add support for user-defined query selection in EntraID entity analytics provider. {pull}37653[37653] +- Add request trace logging for chained API requests. {issue}37551[36551] {pull}37682[37682] *Auditbeat* diff --git a/x-pack/filebeat/input/httpjson/input.go b/x-pack/filebeat/input/httpjson/input.go index 928c056d2d39..17877b607013 100644 --- a/x-pack/filebeat/input/httpjson/input.go +++ b/x-pack/filebeat/input/httpjson/input.go @@ -122,6 +122,16 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso if cfg.Request.Tracer != nil { id := sanitizeFileName(ctx.ID) cfg.Request.Tracer.Filename = strings.ReplaceAll(cfg.Request.Tracer.Filename, "*", id) + + // Propagate tracer behaviour to all chain children. + for i, c := range cfg.Chain { + if c.Step != nil { // Request is validated as required. + cfg.Chain[i].Step.Request.Tracer = cfg.Request.Tracer + } + if c.While != nil { // Request is validated as required. + cfg.Chain[i].While.Request.Tracer = cfg.Request.Tracer + } + } } metrics := newInputMetrics(reg)