File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
271
271
272
272
BUILD_FLAVOR_SERVERLESS = 'serverless' . freeze
273
273
DEFAULT_EAV_HEADER = { "Elastic-Api-Version" => "2023-10-31" } . freeze
274
+ INTERNAL_ORIGIN_HEADER = { 'x-elastic-product-origin' => 'logstash-input-elasticsearch' } . freeze
274
275
275
276
def initialize ( params = { } )
276
277
super ( params )
@@ -300,6 +301,7 @@ def register
300
301
fill_user_password_from_cloud_auth
301
302
302
303
transport_options = { :headers => { } }
304
+ transport_options [ :headers ] . merge! ( INTERNAL_ORIGIN_HEADER )
303
305
transport_options [ :headers ] . merge! ( setup_basic_auth ( user , password ) )
304
306
transport_options [ :headers ] . merge! ( setup_api_key ( api_key ) )
305
307
transport_options [ :headers ] . merge! ( { 'user-agent' => prepare_user_agent ( ) } )
Original file line number Diff line number Diff line change 50
50
client = plugin . send ( :client )
51
51
expect ( extract_transport ( client ) . options [ :transport_options ] [ :headers ] ) . not_to match hash_including ( "Elastic-Api-Version" => "2023-10-31" )
52
52
end
53
+
54
+ it "sets an x-elastic-product-origin header identifying this as an internal plugin request" do
55
+ plugin . register
56
+ client = plugin . send ( :client )
57
+ expect ( extract_transport ( client ) . options [ :transport_options ] [ :headers ] ) . to match hash_including ( "x-elastic-product-origin" => "logstash-input-elasticsearch" )
58
+ end
53
59
end
54
60
55
61
context "against not authentic Elasticsearch" do
90
96
client = plugin . send ( :client )
91
97
expect ( extract_transport ( client ) . options [ :transport_options ] [ :headers ] ) . to match hash_including ( "Elastic-Api-Version" => "2023-10-31" )
92
98
end
99
+
100
+ it "sets an x-elastic-product-origin header identifying this as an internal plugin request" do
101
+ plugin . register
102
+ client = plugin . send ( :client )
103
+ expect ( extract_transport ( client ) . options [ :transport_options ] [ :headers ] ) . to match hash_including ( "x-elastic-product-origin" => "logstash-input-elasticsearch" )
104
+ end
93
105
end
94
106
end
95
107
You can’t perform that action at this time.
0 commit comments