logstash-output-solr 0.2.0 → 0.3.0

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: 38b9cc03511ee8a4bf31c90c2dd774fc22e18ac6
4
- data.tar.gz: 817cce20b93a0adfd67908a074cf7c2066bdb61c
3
+ metadata.gz: 5cbd829a77c764d7b526d66cc7416606e484cdd0
4
+ data.tar.gz: 0d697136ead9938e9b75067021d2d106326d8173
5
5
  SHA512:
6
- metadata.gz: 57828ac60e065ecf652c49ba91500bef3fb962b2246c2a8868fbd62fb0428cadfab8ff159b7078d1774f6944feae080e0a31fd751882e3e9a6aa733e065567c9
7
- data.tar.gz: b8fadbde9a065fbbfeff162929e4b344163fecef1bd2703a3617b3a70b6e491fd7d07f1c05d147df4881110542c06304b64e8419ad305a9f759b4d4a4e4672e2
6
+ metadata.gz: a57339df7bb7aa5b38497a7db8d4fad4586a82ce32ba39bf847fc5d16bb424f63acabc52cb28d50b6df02605b46a736d422d44c06fb8bcaafa606f579dc3e9c8
7
+ data.tar.gz: 322ccddd33ac5e2248ff94abf5383fc0ee9a9140975caed9946a4c29e1d0169a6e3c33d8929f6293b50aa688d346cb09850a6d8d941ba63b5820f24d5a3cfac1
@@ -1,2 +1,8 @@
1
+ ## 0.2.0
2
+ - Bug fix.
3
+
4
+ ## 0.2.0
5
+ - Supports SolrCloud.
6
+
1
7
  ## 0.1.0
2
8
  - First release.
data/README.md CHANGED
@@ -4,16 +4,169 @@ This is a plugin for [Logstash](https://github.com/elastic/logstash). It support
4
4
 
5
5
  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.
6
6
 
7
- ## Documentation
7
+ ## Config parameters
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
9
+ ### url
10
10
 
11
- - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
11
+ The Solr server url (for example http://localhost:8983/solr/collection1).
12
+
13
+ ```
14
+ url http://localhost:8983/solr/collection1
15
+ ```
16
+
17
+ ### zk_host
18
+
19
+ The ZooKeeper connection string that SolrCloud refers to (for example localhost:2181/solr).
20
+
21
+ ```
22
+ zk_host localhost:2181/solr
23
+ ```
24
+
25
+ ### collection
26
+
27
+ The SolrCloud collection name (default collection1).
28
+
29
+ ```
30
+ collection collection1
31
+ ```
32
+
33
+ ### defined_fields
34
+
35
+ The defined fields in the Solr schema.xml. If omitted, it will get fields via Solr Schema API.
36
+
37
+ ```
38
+ defined_fields ["id", "title"]
39
+ ```
40
+
41
+ ### ignore_undefined_fields
42
+
43
+ Ignore undefined fields in the Solr schema.xml.
44
+
45
+ ```
46
+ ignore_undefined_fields false
47
+ ```
48
+
49
+ ### unique_key_field
50
+
51
+ A field name of unique key in the Solr schema.xml. If omitted, it will get unique key via Solr Schema API.
52
+
53
+ ```
54
+ unique_key_field id
55
+ ```
56
+
57
+ ### timestamp_field
58
+
59
+ A field name of event timestamp in the Solr schema.xml (default event_timestamp).
60
+
61
+ ```
62
+ timestamp_field event_timestamp
63
+ ```
64
+
65
+ ### flush_size
66
+
67
+ A number of events to queue up before writing to Solr (default 100).
68
+
69
+ ```
70
+ flush_size 100
71
+ ```
72
+
73
+ ## Plugin setup examples
74
+
75
+ ### Sent to standalone Solr using data-driven schemaless mode.
76
+ ```
77
+ output {
78
+ solr {
79
+ url => "http://localhost:8983/solr/collection1"
80
+ }
81
+ }
82
+
83
+ ```
84
+
85
+ ### Sent to SolrCloud using data-driven schemaless mode.
86
+ ```
87
+ output {
88
+ solr {
89
+ zk_host => "localhost:2181/solr"
90
+ collection => "collection1"
91
+ }
92
+ }
93
+ ```
94
+
95
+ ## Solr setup examples
96
+
97
+ ### How to setup Standalone Solr using data-driven schemaless mode.
98
+
99
+ 1.Download and install Solr
100
+
101
+ ```sh
102
+ $ mkdir $HOME/solr
103
+ $ cd $HOME/solr
104
+ $ wget https://archive.apache.org/dist/lucene/solr/5.4.0/solr-5.4.0.tgz
105
+ $ tar zxvf solr-5.4.0.tgz
106
+ $ cd solr-5.4.0
107
+ ```
108
+
109
+ 2.Start standalone Solr
110
+
111
+ ```sh
112
+ $ ./bin/solr start -p 8983 -s server/solr
113
+ ```
114
+
115
+ 3.Create core
116
+
117
+ ```sh
118
+ $ ./bin/solr create -c collection1 -d server/solr/configsets/data_driven_schema_configs -n collection1_configs
119
+ ```
120
+
121
+ ### How to setup SolrCloud using data-driven schemaless mode (shards=1 and replicationfactor=2).
122
+
123
+ 1.Download and install ZooKeeper
124
+
125
+ ```sh
126
+ $ mkdir $HOME/zookeeper
127
+ $ cd $HOME/zookeeper
128
+ $ wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
129
+ $ tar zxvf zookeeper-3.4.6.tar.gz
130
+ $ cd zookeeper-3.4.6
131
+ $ cp -p ./conf/zoo_sample.cfg ./conf/zoo.cfg
132
+ ```
133
+
134
+ 2.Start standalone ZooKeeper
135
+
136
+ ```sh
137
+ $ ./bin/zkServer.sh start
138
+ ```
139
+
140
+ 3.Download an install Solr
141
+
142
+ ```sh
143
+ $ mkdir $HOME/solr
144
+ $ cd $HOME/solr
145
+ $ wget https://archive.apache.org/dist/lucene/solr/5.4.0/solr-5.4.0.tgz
146
+ $ tar zxvf solr-5.4.0.tgz
147
+ $ cd solr-5.4.0
148
+ $ ./server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181 -cmd clear /solr
149
+ $ ./server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181 -cmd makepath /solr
150
+ $ cp -pr server/solr server/solr1
151
+ $ cp -pr server/solr server/solr2
152
+ ```
153
+
154
+ 4.Start SolrCloud
155
+
156
+ ```sh
157
+ $ ./bin/solr start -h localhost -p 8983 -z localhost:2181/solr -s server/solr1
158
+ $ ./bin/solr start -h localhost -p 8985 -z localhost:2181/solr -s server/solr2
159
+ ```
160
+
161
+ 5.Create collection
162
+
163
+ ```sh
164
+ $ ./bin/solr create -c collection1 -d server/solr1/configsets/data_driven_schema_configs -n collection1_configs -shards 1 -replicationFactor 2
165
+ ```
13
166
 
14
167
  ## Need Help?
15
168
 
16
- Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
169
+ Need help? Try #logstash on freenode IRC or the [https://discuss.elastic.co/c/logstash](https://discuss.elastic.co/c/logstash) discussion forum.
17
170
 
18
171
  ## Developing
19
172
 
@@ -48,17 +201,23 @@ bundle exec rspec
48
201
  #### 2.1 Run in a local Logstash clone
49
202
 
50
203
  - Edit Logstash `Gemfile` and add the local plugin path, for example:
204
+
51
205
  ```ruby
52
- gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
206
+ gem "logstash-output-solr", :path => "/your/local/logstash-output-solr"
53
207
  ```
208
+
54
209
  - Install plugin
210
+
55
211
  ```sh
56
212
  bin/plugin install --no-verify
57
213
  ```
214
+
58
215
  - Run Logstash with your plugin
216
+
59
217
  ```sh
60
- bin/logstash -e 'filter {awesome {}}'
218
+ bin/logstash -e 'output {solr {}}'
61
219
  ```
220
+
62
221
  At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
222
 
64
223
  #### 2.2 Run in an installed Logstash
@@ -66,13 +225,17 @@ At this point any modifications to the plugin code will be applied to this local
66
225
  You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
226
 
68
227
  - Build your plugin gem
228
+
69
229
  ```sh
70
- gem build logstash-filter-awesome.gemspec
230
+ gem build logstash-output-solr.gemspec
71
231
  ```
232
+
72
233
  - Install the plugin from the Logstash home
234
+
73
235
  ```sh
74
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
236
+ bin/plugin install /your/local/plugin/logstash-output-solr.gem
75
237
  ```
238
+
76
239
  - Start Logstash and proceed to test the plugin
77
240
 
78
241
  ## Contributing
@@ -77,7 +77,8 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
77
77
  def flush(events, close=false)
78
78
  documents = []
79
79
 
80
- @fields = @defined_fields.nil? ? get_fields : @defined_fields
80
+ @fields = @defined_fields.nil? || @defined_fields.empty? ? get_fields : @defined_fields
81
+
81
82
  @unique_key = @unique_key_field.nil? ? get_unique_key : @unique_key_field
82
83
 
83
84
  events.each do |event|
@@ -99,21 +100,21 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
99
100
  end
100
101
  end
101
102
 
102
- @logger.info "Record: %s" % document.inspect
103
+ @logger.info 'Record: %s' % document.inspect
103
104
 
104
105
  documents.push(document)
105
106
  end
106
107
 
107
108
  if @mode == MODE_STANDALONE then
108
109
  @solr.add documents, :params => {:commit => true}
109
- @logger.info "Added %d document(s) to Solr" % documents.count
110
+ @logger.info 'Added %d document(s) to Solr' % documents.count
110
111
  elsif @mode == MODE_SOLRCLOUD then
111
112
  @solr.add documents, collection: @collection, :params => {:commit => true}
112
- @logger.info "Added %d document(s) to Solr" % documents.count
113
+ @logger.info 'Added %d document(s) to Solr' % documents.count
113
114
  end
114
115
 
115
116
  rescue Exception => e
116
- @logger.warn("An error occurred while indexing: #{e.message}")
117
+ @logger.warn('An error occurred while indexing: #{e.message}')
117
118
  end # def flush
118
119
 
119
120
  public
@@ -134,12 +135,12 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
134
135
  end
135
136
 
136
137
  unique_key = response['uniqueKey']
137
- @logger.info "Unique key: #{unique_key}"
138
+ @logger.info 'Unique key: #{unique_key}'
138
139
 
139
140
  return unique_key
140
141
 
141
142
  rescue Exception => e
142
- @logger.warn "Unique key: #{e.message}"
143
+ @logger.warn 'Unique key: #{e.message}'
143
144
  end # def get_unique_key
144
145
 
145
146
  private
@@ -156,11 +157,11 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
156
157
  response['fields'].each do |field|
157
158
  fields.push(field['name'])
158
159
  end
159
- @logger.info "Fields: #{fields}"
160
+ @logger.info 'Fields: #{fields}'
160
161
 
161
162
  return fields
162
163
 
163
164
  rescue Exception => e
164
- @logger.warn "Fields: #{e.message}"
165
+ @logger.warn 'Fields: #{e.message}'
165
166
  end # def get_fields
166
167
  end # class LogStash::Outputs::Solr
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-solr'
3
- s.version = "0.2.0"
3
+ s.version = "0.3.0"
4
4
  s.licenses = ["Apache License (2.0)"]
5
5
  s.summary = "Logstash output plugin for sending data to Solr."
6
6
  s.description = "Logstash output plugin for sending data to Solr. It support SolrCloud not only Standalone Solr."
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency "logstash-codec-plain"
23
23
  s.add_runtime_dependency 'rsolr', '~> 1.0.13'
24
24
  s.add_runtime_dependency 'zk', '~> 1.9.6'
25
- s.add_runtime_dependency 'rsolr-cloud', '~> 1.0.0'
25
+ s.add_runtime_dependency 'rsolr-cloud', '~> 1.1.0'
26
26
  s.add_runtime_dependency 'stud', '~> 0.0.22'
27
27
 
28
28
  s.add_development_dependency "logstash-devutils", '~> 0.0.18'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-solr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minoru Osuka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: 1.0.0
80
+ version: 1.1.0
81
81
  name: rsolr-cloud
82
82
  prerelease: false
83
83
  type: :runtime
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 1.0.0
88
+ version: 1.1.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements: