Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set x-elastic-product-origin header for ES requests #1195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion logstash-output-elasticsearch.gemspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 8 additions & 1 deletion spec/integration/outputs/compressed_indexing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions spec/integration/outputs/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down