logstash-output-elasticsearch 12.0.6-java → 12.0.7-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed4936a4ade53b1bfabb21a6a217a2587ee38235a3219be044ca59a664fd25a1
4
- data.tar.gz: c06797095dd77c26bd7c70d1d851fcc50ca8e2b4db35485e9f5c018941e54cd2
3
+ metadata.gz: 6da132cfd797a627e8a5fac299cc7b94a35750c3aec1ed3f046900ed7032c10f
4
+ data.tar.gz: 8a95530785c4fe01c075addd6a7d7b91ac486b8fcdf9259345e07ad51d372e92
5
5
  SHA512:
6
- metadata.gz: 163f1e9cd1127527b6ce207f18f451c6dfd7510c6f752739908d6804c3fa70b2fced78b22668f6388d02a92d9969dd7f47f079e0180abacf8f0305d56ad14441
7
- data.tar.gz: 77dc391a2d5ef77f76d07a52b6f00375eb6b9ffb9c8dbb731c849b2bffd8fb25f819c3070a729a9f1c72e7ba4ff845359ba5109aa2e5eb1242461c4b0cab5719
6
+ metadata.gz: c17d66090ac80e1af81d6cc4e83367c41c1c32645fc113045a77355d00483bcaf9ec78e55594ce94e7034ef285beac5b8463b92dcb57ba33e5b25c2cb12a48a8
7
+ data.tar.gz: 1b475b8b4f912715c114781dcb0d7a30190efd5cb5dc7afc2a6905ac372f19b53915ce0a0b75f57068225e73e9fbaa41fdbb027730c9bfd8be367da61f22a11c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 12.0.7
2
+ - Support both, encoded and non encoded api-key formats on plugin configuration [#1223](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1223)
3
+
1
4
  ## 12.0.6
2
5
  - Add headers reporting uncompressed size and doc count for bulk requests [#1217](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1217)
3
6
 
data/docs/index.asciidoc CHANGED
@@ -303,12 +303,17 @@ single request.
303
303
  ==== DNS Caching
304
304
 
305
305
  This plugin uses the JVM to lookup DNS entries and is subject to the value of
306
- https://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html[networkaddress.cache.ttl],
307
- a global setting for the JVM.
306
+ https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/doc-files/net-properties.html#address-cache-heading[Address Cache settings]
307
+ such as `networkaddress.cache.ttl` and `networkaddress.cache.negative.ttl`, global settings for the JVM.
308
308
 
309
309
  As an example, to set your DNS TTL to 1 second you would set
310
310
  the `LS_JAVA_OPTS` environment variable to `-Dnetworkaddress.cache.ttl=1`.
311
311
 
312
+ The default value for `networkaddress.cache.ttl` depends on the JVM implementation,
313
+ which is 30 seconds for the JDK bundled with Logstash.
314
+ The `networkaddress.cache.negative.ttl` setting, that controls how long Java caches
315
+ the result of failed DNS lookups, defaults to 10 seconds.
316
+
312
317
  Keep in mind that a connection with keepalive enabled will
313
318
  not reevaluate its DNS value while the keepalive is in effect.
314
319
 
@@ -188,25 +188,37 @@ module LogStash; module Outputs; class ElasticSearch;
188
188
  def self.setup_api_key(logger, params)
189
189
  api_key = params["api_key"]
190
190
 
191
- return {} unless (api_key && api_key.value)
191
+ return {} unless (api_key&.value)
192
192
 
193
- { "Authorization" => "ApiKey " + Base64.strict_encode64(api_key.value) }
194
- end
193
+ value = is_base64?(api_key.value) ? api_key.value : Base64.strict_encode64(api_key.value)
195
194
 
196
- private
197
- def self.dedup_slashes(url)
198
- url.gsub(/\/+/, "/")
195
+ { "Authorization" => "ApiKey #{value}" }
199
196
  end
200
197
 
201
- # Set a `filter_path` query parameter if it is not already set to be
202
- # `filter_path=errors,items.*.error,items.*.status` to reduce the payload between Logstash and Elasticsearch
203
- def self.resolve_filter_path(url)
204
- return url if url.match?(/(?:[&|?])filter_path=/)
205
- ("#{url}#{query_param_separator(url)}filter_path=errors,items.*.error,items.*.status")
206
- end
198
+ class << self
199
+ private
200
+ def dedup_slashes(url)
201
+ url.gsub(/\/+/, "/")
202
+ end
203
+
204
+ # Set a `filter_path` query parameter if it is not already set to be
205
+ # `filter_path=errors,items.*.error,items.*.status` to reduce the payload between Logstash and Elasticsearch
206
+ def resolve_filter_path(url)
207
+ return url if url.match?(/(?:[&|?])filter_path=/)
208
+ ("#{url}#{query_param_separator(url)}filter_path=errors,items.*.error,items.*.status")
209
+ end
207
210
 
208
- def self.query_param_separator(url)
209
- url.match?(/\?[^\s#]+/) ? '&' : '?'
211
+ def query_param_separator(url)
212
+ url.match?(/\?[^\s#]+/) ? '&' : '?'
213
+ end
214
+
215
+ def is_base64?(string)
216
+ begin
217
+ string == Base64.strict_encode64(Base64.strict_decode64(string))
218
+ rescue ArgumentError
219
+ false
220
+ end
221
+ end
210
222
  end
211
223
  end
212
224
  end; end; end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '12.0.6'
3
+ s.version = '12.0.7'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  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"
@@ -5,7 +5,10 @@ describe "metrics", :integration => true do
5
5
  require "logstash/outputs/elasticsearch"
6
6
  settings = {
7
7
  "manage_template" => false,
8
- "hosts" => "#{get_host_port()}"
8
+ "hosts" => "#{get_host_port()}",
9
+ # write data to a random non templated index to ensure the bulk partially fails
10
+ # don't use streams like "logs-*" as those have failure stores enabled, causing the bulk to succeed instead
11
+ "index" => "custom_index_#{rand(10000)}"
9
12
  }
10
13
  plugin = LogStash::Outputs::ElasticSearch.new(settings)
11
14
  end
@@ -26,6 +26,44 @@ describe LogStash::Outputs::ElasticSearch::HttpClientBuilder do
26
26
  end
27
27
  end
28
28
 
29
+ describe "auth setup with api-key" do
30
+ let(:klass) { LogStash::Outputs::ElasticSearch::HttpClientBuilder }
31
+
32
+ context "when api-key is not encoded (id:api-key)" do
33
+ let(:api_key) { "id:api-key" }
34
+ let(:api_key_secured) do
35
+ secured = double("api_key")
36
+ allow(secured).to receive(:value).and_return(api_key)
37
+ secured
38
+ end
39
+ let(:options) { { "api_key" => api_key_secured } }
40
+ let(:logger) { double("logger") }
41
+ let(:api_key_header) { klass.setup_api_key(logger, options) }
42
+
43
+ it "returns the correct encoded api-key header" do
44
+ expected = "ApiKey #{Base64.strict_encode64(api_key)}"
45
+ expect(api_key_header["Authorization"]).to eql(expected)
46
+ end
47
+ end
48
+
49
+ context "when api-key is already encoded" do
50
+ let(:api_key) { Base64.strict_encode64("id:api-key") }
51
+ let(:api_key_secured) do
52
+ secured = double("api_key")
53
+ allow(secured).to receive(:value).and_return(api_key)
54
+ secured
55
+ end
56
+ let(:options) { { "api_key" => api_key_secured } }
57
+ let(:logger) { double("logger") }
58
+ let(:api_key_header) { klass.setup_api_key(logger, options) }
59
+
60
+ it "returns the api-key header as is" do
61
+ expected = "ApiKey #{api_key}"
62
+ expect(api_key_header["Authorization"]).to eql(expected)
63
+ end
64
+ end
65
+ end
66
+
29
67
  describe "customizing action paths" do
30
68
  let(:hosts) { [ ::LogStash::Util::SafeURI.new("http://localhost:9200") ] }
31
69
  let(:options) { {"hosts" => hosts } }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.6
4
+ version: 12.0.7
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-29 00:00:00.000000000 Z
10
+ date: 2025-09-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: manticore