diff --git a/CHANGELOG.md b/CHANGELOG.md index 045e3622..abc1247c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 11.22.10 + - Add `x-elastic-product-origin` header to Elasticsearch requests [#1194](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1194) + ## 11.22.9 - Vendor ECS template for Elasticsearch 9.x in built gem [#1188](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1188) diff --git a/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb b/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb index ba128007..c9e49ec7 100644 --- a/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb +++ b/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb @@ -2,7 +2,7 @@ require 'cgi' module LogStash; module Outputs; class ElasticSearch; class HttpClient; - DEFAULT_HEADERS = { "Content-Type" => "application/json" } + DEFAULT_HEADERS = { "Content-Type" => "application/json", 'x-elastic-product-origin' => 'logstash-output-elasticsearch' } class ManticoreAdapter attr_reader :manticore, :logger diff --git a/logstash-output-elasticsearch.gemspec b/logstash-output-elasticsearch.gemspec index f29aa5d5..d2e88631 100644 --- a/logstash-output-elasticsearch.gemspec +++ b/logstash-output-elasticsearch.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'logstash-output-elasticsearch' - s.version = '11.22.9' + s.version = '11.22.10' s.licenses = ['apache-2.0'] s.summary = "Stores logs in Elasticsearch" s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program" diff --git a/spec/integration/outputs/compressed_indexing_spec.rb b/spec/integration/outputs/compressed_indexing_spec.rb index 5d9afb85..3662f543 100644 --- a/spec/integration/outputs/compressed_indexing_spec.rb +++ b/spec/integration/outputs/compressed_indexing_spec.rb @@ -32,6 +32,13 @@ let(:http_client) do Manticore::Client.new(http_client_options) end + let(:expected_headers) { + { + "Content-Encoding" => "gzip", + "Content-Type" => "application/json", + 'x-elastic-product-origin' => 'logstash-output-elasticsearch' + } + } before do subject.register @@ -64,7 +71,7 @@ it "sets the correct content-encoding header and body is compressed" do expect(subject.client.pool.adapter.client).to receive(:send). - with(anything, anything, {:headers=>{"Content-Encoding"=>"gzip", "Content-Type"=>"application/json"}, :body => a_valid_gzip_encoded_string}). + with(anything, anything, {:headers=> expected_headers, :body => a_valid_gzip_encoded_string}). and_call_original subject.multi_receive(events) end diff --git a/spec/integration/outputs/index_spec.rb b/spec/integration/outputs/index_spec.rb index 90c59e6a..02f3fb76 100644 --- a/spec/integration/outputs/index_spec.rb +++ b/spec/integration/outputs/index_spec.rb @@ -214,10 +214,13 @@ def curl_and_get_json_response(url, method: :get, retrieve_err_payload: false); end it "sets the correct content-type header" do - expected_manticore_opts = {:headers => {"Content-Type" => "application/json"}, :body => anything} + expected_manticore_opts = { + :headers => {"Content-Type" => "application/json", 'x-elastic-product-origin' => 'logstash-output-elasticsearch'}, + :body => anything + } if secure expected_manticore_opts = { - :headers => {"Content-Type" => "application/json"}, + :headers => {"Content-Type" => "application/json", 'x-elastic-product-origin' => 'logstash-output-elasticsearch'}, :body => anything, :auth => { :user => user, diff --git a/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb b/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb index 85f601e0..626cf730 100644 --- a/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb +++ b/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb @@ -34,7 +34,7 @@ expect(subject.manticore).to receive(:get). with(expected_uri.to_s, { - :headers => {"Content-Type" => "application/json"}, + :headers => LogStash::Outputs::ElasticSearch::HttpClient::DEFAULT_HEADERS, :auth => { :user => user, :password => password,