logstash-output-elasticsearch 2.1.4-java → 2.1.5-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
  SHA1:
3
- metadata.gz: 83b2c74b37b6266cc97c1801321c858302faf85d
4
- data.tar.gz: f47adea8d8172e63fd433e2e58135dd6657bff07
3
+ metadata.gz: e1c06d07d392d4fba071aa01553091dd85461b3b
4
+ data.tar.gz: 368990ab9b1464f955418125388028940e8576aa
5
5
  SHA512:
6
- metadata.gz: 0db5b0f53f6611fd0b7a5587d4d4a2764d849c02a984dea4dcf735c4f72986085d03acc0dc5ccd08fdc4817c01509aacc2dc98f52ddbb0dbfd74d297bf158d23
7
- data.tar.gz: 07cc0da34006d0c84e756d54ea4938df4fbaa822c7c5a284770b50ad040e8270f5fe8ea021a743777fac00e83f0a9c918114a5ab0b145161a2a753b2d7eaa834
6
+ metadata.gz: 221ea508978c3bef5e9f03794b4af02d7e96234b60b7b2b1cf3f8b18a263b90e8bb1ef8d4a372bd1f6d376ccefe65d54fca7272b573a5762011e116057051506
7
+ data.tar.gz: daa946bd260816118bb2e88aa3173220f0999352417bc00af7974fc8b21365f1e1218096fb2e6430c987e04b0a48175b93139bb908c9cac52d672e5f2b68df55
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.5
2
+ - Sprintf style 'action' parameters no longer raise a LogStash::ConfigurationError
3
+
1
4
  ## 2.1.4
2
5
  - Improved the default template to disable fielddata on analyzed string fields. #309
3
6
  - Dependend on logstash-core 2.0.0 released version, rather than RC1
data/README.md CHANGED
@@ -5,6 +5,8 @@ ATTN: This plugin is undergoing a [major refactor](https://github.com/logstash-p
5
5
  [![Build
6
6
  Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-elasticsearch-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-elasticsearch-unit/)
7
7
 
8
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-elasticsearch.svg)](https://travis-ci.org/logstash-plugins/logstash-output-elasticsearch)
9
+
8
10
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
9
11
 
10
12
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
@@ -14,6 +14,7 @@ module LogStash; module Outputs; class ElasticSearch;
14
14
  build_client
15
15
  install_template
16
16
  setup_buffer_and_handler
17
+ check_action_validity
17
18
 
18
19
  @logger.info("New Elasticsearch output", :class => self.class.name, :hosts => @hosts)
19
20
  end
@@ -56,6 +57,22 @@ module LogStash; module Outputs; class ElasticSearch;
56
57
  end
57
58
  end
58
59
 
60
+ def check_action_validity
61
+ raise LogStash::ConfigurationError, "No action specified!" unless @action
62
+
63
+ # If we're using string interpolation, we're good!
64
+ return if @action =~ /%{.+}/
65
+ return if valid_actions.include?(@action)
66
+
67
+ raise LogStash::ConfigurationError, "Action '#{@action}' is invalid! Pick one of #{valid_actions} or use a sprintf style statement"
68
+ end
69
+
70
+ # To be overidden by the -java version
71
+ VALID_HTTP_ACTIONS=["index", "delete", "create", "update"]
72
+ def valid_actions
73
+ VALID_HTTP_ACTIONS
74
+ end
75
+
59
76
  def retrying_submit(actions)
60
77
  retries_left = @max_retries+1 # +1 for the first attempt
61
78
 
@@ -69,9 +69,11 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
69
69
  # - create: indexes a document, fails if a document by that id already exists in the index.
70
70
  # - update: updates a document by id. Update has a special case where you can upsert -- update a
71
71
  # document if not already present. See the `upsert` option
72
+ # - A sprintf style string to change the action based on the content of the event. The value `%{[foo]}`
73
+ # would use the foo field for the action
72
74
  #
73
75
  # For more details on actions, check out the http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html[Elasticsearch bulk API documentation]
74
- config :action, :validate => %w(index delete create update), :default => "index"
76
+ config :action, :validate => :string, :default => "index"
75
77
 
76
78
  # Username to authenticate to a secure Elasticsearch cluster
77
79
  config :user, :validate => :string
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-elasticsearch'
4
- s.version = '2.1.4'
4
+ s.version = '2.1.5'
5
5
  s.licenses = ['apache-2.0']
6
6
  s.summary = "Logstash Output to Elasticsearch"
7
7
  s.description = "Output events to elasticsearch"
@@ -78,8 +78,8 @@ describe "index template expected behavior", :integration => true do
78
78
  insist { results["hits"]["hits"][0]["_source"]["geoip"]["location"] } == [ 0.0, 0.0 ]
79
79
  end
80
80
 
81
- it "should index stopwords like 'at' " do
82
- results = @es.search(:body => { "aggregations" => { "my_agg" => { "terms" => { "field" => "country" } } } })["aggregations"]["my_agg"]
81
+ it "aggregate .raw results correctly " do
82
+ results = @es.search(:body => { "aggregations" => { "my_agg" => { "terms" => { "field" => "country.raw" } } } })["aggregations"]["my_agg"]
83
83
  terms = results["buckets"].collect { |b| b["key"] }
84
84
 
85
85
  insist { terms }.include?("us")
@@ -131,4 +131,26 @@ describe "outputs/elasticsearch" do
131
131
  sleep(options["timeout"] + 0.5)
132
132
  end
133
133
  end
134
+
135
+ describe "the action option" do
136
+ subject(:eso) {LogStash::Outputs::ElasticSearch.new(options)}
137
+ context "with a sprintf action" do
138
+ let(:options) { {"action" => "%{myactionfield}"} }
139
+
140
+ let(:event) { LogStash::Event.new("myactionfield" => "update", "message" => "blah") }
141
+
142
+ it "should interpolate the requested action value when creating an event_action_tuple" do
143
+ expect(eso.event_action_tuple(event).first).to eql("update")
144
+ end
145
+ end
146
+
147
+ context "with an invalid action" do
148
+ let(:options) { {"action" => "SOME Garbaaage"} }
149
+
150
+ it "should raise a configuration error" do
151
+ expect { subject.register }.to raise_error(LogStash::ConfigurationError)
152
+ end
153
+ end
154
+ end
155
+
134
156
  end
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.1.4
4
+ version: 2.1.5
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement