diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml index 27bed4d5602e..5007ef0781a7 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml @@ -39,5 +39,7 @@ output: hosts: - 127.0.0.1:9200 - 127.0.0.1:9300 + headers: + h1: test-header username: elastic password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml index d6cc2627a95e..2a97f96a3019 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml @@ -39,5 +39,7 @@ output: hosts: - 127.0.0.1:9200 - 127.0.0.1:9300 + headers: + h1: test-header username: elastic password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml index c0c6066b55fc..7a0fad5c9df6 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml @@ -8,6 +8,8 @@ fleet: output: elasticsearch: hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header username: fleet password: fleetpassword diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml index 0516a0ff05ed..ead9bb86042d 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml @@ -68,6 +68,9 @@ output: hosts: - 127.0.0.1:9200 - 127.0.0.1:9300 + headers: + h1: test-header + namespace: test_namespace username: elastic password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml index c03696aff1f0..b306cf402773 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml @@ -8,6 +8,8 @@ fleet: output: elasticsearch: hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header username: fleet password: fleetpassword diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml index 178014ab1fc1..a9df045afff0 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml @@ -88,6 +88,9 @@ metricbeat: output: elasticsearch: hosts: [127.0.0.1:9200, 127.0.0.1:9300] + headers: + h1: test-header + namespace: test_namespace username: elastic password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml index c0c4bbbe9f80..f99c903e4365 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml @@ -68,6 +68,8 @@ output: hosts: - 127.0.0.1:9200 - 127.0.0.1:9300 + headers: + h1: test-header username: elastic password: changeme bulk_max_size: 23 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml index c03696aff1f0..b306cf402773 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml @@ -8,6 +8,8 @@ fleet: output: elasticsearch: hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header username: fleet password: fleetpassword diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml index 3a78db4fd328..c4d63964e855 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml @@ -88,6 +88,8 @@ metricbeat: output: elasticsearch: hosts: [127.0.0.1:9200, 127.0.0.1:9300] + headers: + h1: test-header username: elastic password: changeme bulk_max_size: 23 diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/rules.go b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go index 0541e874b090..d215a35b38a8 100644 --- a/x-pack/elastic-agent/pkg/agent/transpiler/rules.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go @@ -1638,12 +1638,12 @@ func (r *InjectHeadersRule) Apply(agentInfo AgentInfo, ast *AST) (err error) { return nil } - outputsNode, found := Lookup(ast, "outputs") + outputNode, found := Lookup(ast, "output") if !found { return nil } - elasticsearchNode, found := outputsNode.Find("elasticsearch") + elasticsearchNode, found := outputNode.Find("elasticsearch") if found { headersNode, found := elasticsearchNode.Find("headers") if found { diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go b/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go index 2c743d16203f..939a1d5f681c 100644 --- a/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go @@ -725,7 +725,7 @@ rest: of "inject auth headers: no headers": { givenYAML: ` -outputs: +output: elasticsearch: hosts: - "127.0.0.1:9201" @@ -734,7 +734,7 @@ outputs: port: 5 `, expectedYAML: ` -outputs: +output: elasticsearch: headers: h1: test-header @@ -753,7 +753,7 @@ outputs: "inject auth headers: existing headers": { givenYAML: ` -outputs: +output: elasticsearch: headers: sample-header: existing @@ -764,7 +764,7 @@ outputs: port: 5 `, expectedYAML: ` -outputs: +output: elasticsearch: headers: sample-header: existing