logstash-output-elasticsearch 2.5.1-java → 2.5.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2be6702ec45ea049c714fc3d3481405c8d9d4b5
4
- data.tar.gz: 376cb1122b3bc91c2747813dee512cd89bef4bcd
3
+ metadata.gz: d828f1e289c77ea6baff44c741445806d2269d57
4
+ data.tar.gz: a2dd7280157da88097c32701db5a394748de4378
5
5
  SHA512:
6
- metadata.gz: f06e6bc71c5faa1ba4296231e0c2f555c4c7caf73031a09a776ec1ff17a127afeaa7967396a41ecbb2ecbf9fd939858fcbd042855d0b72c4e2cffb5edd9f9f63
7
- data.tar.gz: c2c403a0690b04aa328eb005312cc1d69d43bc50585e5ef6a0900e0258a8eafa59a7c2c475048e7b15077d5c3982e225bbcb3b6371456cc951b7ae6f1f736ade
6
+ metadata.gz: 0590f8743db7c23025c4816d82f0d32d1f053b6a4f2aae8204c9cbbc2a43277ba082f3dc89cbeb92215ce3c63d897c985177c2124baff41e25ffee04f250584f
7
+ data.tar.gz: e9522c843c2a8d89b7187ec43f9e64e5c309114c13a2af4b6164518f702594e713a10f0bdcfa10e5b4d42bea8fb153ad3f976c0924a4f14007685a0c2e4655b0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.5.3
2
+ - Fix bug with update document with doc_as_upsert and scripting (#364, #359)
3
+ - Make error messages more verbose and easier to parse by humans
4
+
5
+ ## 2.5.2
6
+ - Retryable failures are now logged at the info level instead of warning. (issue #372)
7
+
1
8
  ## 2.5.1
2
9
  - Fix bug where SSL would sometimes not be enabled
3
10
 
data/CONTRIBUTORS CHANGED
@@ -8,6 +8,7 @@ Contributors:
8
8
  * Dmitry Koprov (dkoprov)
9
9
  * Graham Bleach (bleach)
10
10
  * Hao Chen (haoch)
11
+ * Ivan Babrou (bobrik)
11
12
  * James Turnbull (jamtur01)
12
13
  * John E. Vincent (lusis)
13
14
  * Jordan Sissel (jordansissel)
@@ -107,12 +107,13 @@ module LogStash; module Outputs; class ElasticSearch;
107
107
  bulk_response["items"].each_with_index do |response,idx|
108
108
  action_type, action_props = response.first
109
109
  status = action_props["status"]
110
+ error = action_props["error"]
110
111
  action = actions[idx]
111
112
 
112
113
  if SUCCESS_CODES.include?(status)
113
114
  next
114
115
  elsif RETRYABLE_CODES.include?(status)
115
- @logger.warn "retrying failed action with response code: #{status}"
116
+ @logger.info "retrying failed action with response code: #{status} (#{error})"
116
117
  actions_to_retry << action
117
118
  else
118
119
  @logger.warn "Failed action. ", status: status, action: action, response: response
@@ -166,9 +167,9 @@ module LogStash; module Outputs; class ElasticSearch;
166
167
  @logger.error(
167
168
  "Attempted to send a bulk request to Elasticsearch configured at '#{@client.client_options[:hosts]}',"+
168
169
  " but Elasticsearch appears to be unreachable or down!",
169
- :client_config => @client.client_options,
170
170
  :error_message => e.message,
171
- :class => e.class.name
171
+ :class => e.class.name,
172
+ :client_config => @client.client_options,
172
173
  )
173
174
  @logger.debug("Failed actions for last bad bulk request!", :actions => actions)
174
175
 
@@ -181,10 +182,10 @@ module LogStash; module Outputs; class ElasticSearch;
181
182
  "Attempted to send a bulk request to Elasticsearch configured at '#{@client.client_options[:hosts]}'," +
182
183
  " but an error occurred and it failed! Are you sure you can reach elasticsearch from this machine using " +
183
184
  "the configuration provided?",
184
- :client_config => @client.client_options,
185
185
  :error_message => e.message,
186
186
  :error_class => e.class.name,
187
- :backtrace => e.backtrace
187
+ :backtrace => e.backtrace,
188
+ :client_config => @client.client_options,
188
189
  )
189
190
 
190
191
  @logger.debug("Failed actions for last bad bulk request!", :actions => actions)
@@ -203,10 +203,13 @@ module LogStash; module Outputs; class ElasticSearch;
203
203
  # Use the event as a hash from your script with variable name defined
204
204
  # by script_var_name (default: "event")
205
205
  # Ex: event["@timestamp"]
206
- source = { 'script' => {'params' => { @options[:script_var_name] => source }} }
206
+ source_orig = source
207
+ source = { 'script' => {'params' => { @options[:script_var_name] => source_orig }} }
207
208
  if @options[:scripted_upsert]
208
209
  source['scripted_upsert'] = true
209
210
  source['upsert'] = {}
211
+ elsif @options[:doc_as_upsert]
212
+ source['upsert'] = source_orig
210
213
  else
211
214
  source['upsert'] = args.delete(:_upsert) if args[:_upsert]
212
215
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-elasticsearch'
4
- s.version = '2.5.1'
4
+ s.version = '2.5.2'
5
5
  s.licenses = ['apache-2.0']
6
6
  s.summary = "Logstash Output to Elasticsearch"
7
7
  s.description = "Output events to elasticsearch"
@@ -77,17 +77,47 @@ describe "Update actions", :integration => true do
77
77
  it "should increment a counter with event/doc 'count' variable with inline script" do
78
78
  subject = get_es_output({
79
79
  'document_id' => "123",
80
- 'script' => 'ctx._source.counter += event["count"]',
80
+ 'script' => 'ctx._source.counter += event["counter"]',
81
81
  'script_lang' => 'groovy',
82
82
  'script_type' => 'inline'
83
83
  })
84
84
  subject.register
85
- subject.receive(LogStash::Event.new("count" => 3 ))
85
+ subject.receive(LogStash::Event.new("counter" => 3 ))
86
86
  subject.flush
87
87
  r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
88
88
  insist { r["_source"]["counter"] } == 4
89
89
  end
90
90
 
91
+ it "should increment a counter with event/doc 'count' variable with event/doc as upsert and inline script" do
92
+ subject = get_es_output({
93
+ 'document_id' => "123",
94
+ 'doc_as_upsert' => true,
95
+ 'script' => 'if( ctx._source.containsKey("counter") ){ ctx._source.counter += event["counter"]; } else { ctx._source.counter = event["counter"]; }',
96
+ 'script_lang' => 'groovy',
97
+ 'script_type' => 'inline'
98
+ })
99
+ subject.register
100
+ subject.receive(LogStash::Event.new("counter" => 3 ))
101
+ subject.flush
102
+ r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
103
+ insist { r["_source"]["counter"] } == 4
104
+ end
105
+
106
+ it "should, with new doc, set a counter with event/doc 'count' variable with event/doc as upsert and inline script" do
107
+ subject = get_es_output({
108
+ 'document_id' => "456",
109
+ 'doc_as_upsert' => true,
110
+ 'script' => 'if( ctx._source.containsKey("counter") ){ ctx._source.counter += event["count"]; } else { ctx._source.counter = event["count"]; }',
111
+ 'script_lang' => 'groovy',
112
+ 'script_type' => 'inline'
113
+ })
114
+ subject.register
115
+ subject.receive(LogStash::Event.new("counter" => 3 ))
116
+ subject.flush
117
+ r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "456", :refresh => true)
118
+ insist { r["_source"]["counter"] } == 3
119
+ end
120
+
91
121
  it "should increment a counter with event/doc 'count' variable with indexed script" do
92
122
  @es.put_script lang: 'groovy', id: 'indexed_update', body: { script: 'ctx._source.counter += event["count"]' }
93
123
  subject = get_es_output({
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby