fluent-plugin-azuresearch 0.1.2 → 0.2.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: 5e676e6a3c79df3f6064dc64e0a36c6f75909d23
4
- data.tar.gz: a5c371a85bff5fab8abf3e80cd5e9eea35146de3
3
+ metadata.gz: 76f573ed22cba02133e8bebf6c70a5f70710c636
4
+ data.tar.gz: 8d5e301c6c5bf5f0ea36b890c21029cbfee95182
5
5
  SHA512:
6
- metadata.gz: b9c867f9cca43eb788cfc9182f239c5d3dbcdfac863fcb800fbd604ec5194e02a286e1b9b5bc67ff5d87567631a03ec04693c6afd013ce9fa05af549500225f9
7
- data.tar.gz: 1cebebbcfaf3fccda57d184f8d9fcaa0e2f1ea21dab0d59dc53d4a5728d3a29471e7d83b0d61cb1cceec3159677ac8d26eaa991c8234fd0e68b64a96f409153a
6
+ metadata.gz: 02b7facbaaf3dd9694fd146953c91638326d67c4c41508db7b4571f490145c201027c8e44f2b0d98e2b76cbe85c3148b8364879ece9cc0209906f3dfd264677c
7
+ data.tar.gz: 7478e66492a848353d8e3b0dce39a4e77b19ab5ed4dc212c8f5b003e67706fe99534a06be961454ec2d69f79c126e17abdafb289cb43d94b74c12f71d17ab2dc
@@ -0,0 +1,17 @@
1
+ ## 0.2.0
2
+
3
+ * Migrate to use fluentd v0.14 API - [PR#3](https://github.com/yokawasa/fluent-plugin-azuresearch/pull/3)
4
+ * Support plugin specific log level - [PR#2](https://github.com/yokawasa/fluent-plugin-azuresearch/pull/2)
5
+ * Added example script and configuration
6
+
7
+ ## 0.1.2
8
+
9
+ * Change gem package dependency option for rest-client from add_development_dependency to add_dependency
10
+
11
+ ## 0.1.1
12
+
13
+ * Security enhanced option: Added secret option to api_key
14
+
15
+ ## 0.1.0
16
+
17
+ * Inital Release
data/README.md CHANGED
@@ -20,6 +20,7 @@ To use Microsoft Azure Search, you must create an Azure Search service in the Az
20
20
 
21
21
  <match azuresearch.*>
22
22
  @type azuresearch
23
+ @log_level info
23
24
  endpoint https://AZURE_SEARCH_ACCOUNT.search.windows.net
24
25
  api_key AZURE_SEARCH_API_KEY
25
26
  search_index messages
@@ -33,6 +34,8 @@ To use Microsoft Azure Search, you must create an Azure Search service in the Az
33
34
  * **column\_names (required)** - Column names in a target Azure search index. Each column needs to be separated by a comma.
34
35
  * **key\_names (optional)** - Default:nil. Key names in incomming record to insert. Each key needs to be separated by a comma. ${time} is placeholder for Time.at(time).strftime("%Y-%m-%dT%H:%M:%SZ"), and ${tag} is placeholder for tag. By default, **key\_names** is as same as **column\_names**
35
36
 
37
+ [note] @log_level is a fluentd built-in parameter (optional) that controls verbosity of logging: fatal|error|warn|info|debug|trace (See also [Logging of Fluentd](http://docs.fluentd.org/articles/logging#log-level))
38
+
36
39
  ## Sample Configurations
37
40
  ### Case1 - column_names is as same as key_names
38
41
 
@@ -197,6 +200,14 @@ Please don't forget that you need forward input configuration to receive the mes
197
200
  ## TODOs
198
201
  * Input validation for Azure Search - check total size of columns to add
199
202
 
203
+ ## Change log
204
+ * [Changelog](ChangeLog.md)
205
+
206
+ ## Links
207
+
208
+ * http://yokawasa.github.io/fluent-plugin-azuresearch
209
+ * https://rubygems.org/gems/fluent-plugin-azuresearch
210
+
200
211
  ## Contributing
201
212
 
202
213
  Bug reports and pull requests are welcome on GitHub at https://github.com/yokawasa/fluent-plugin-azuresearch.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+
3
+ SERVICE_NAME='Azure Search Service Name'
4
+ ADMIN_KEY='Azure Search API Admin Key'
5
+ API_VER='2015-02-28-Preview'
6
+ CONTENT_TYPE='application/json'
7
+ URL="https://${SERVICE_NAME}.search.windows.net/indexes?api-version=${API_VER}"
8
+
9
+ curl -s\
10
+ -H "Content-Type: ${CONTENT_TYPE}"\
11
+ -H "api-key: ${ADMIN_KEY}"\
12
+ -XPOST ${URL} -d'{
13
+ "name": "messages",
14
+ "fields": [
15
+ { "name":"id", "type":"Edm.String", "key": true, "searchable": false },
16
+ { "name":"user_name", "type":"Edm.String" },
17
+ { "name":"message", "type":"Edm.String", "filterable":false, "sortable":false, "facetable":false, "analyzer":"en.lucene" },
18
+ { "name":"created_at", "type":"Edm.DateTimeOffset", "facetable":false}
19
+ ]
20
+ }'
@@ -0,0 +1,14 @@
1
+ <source>
2
+ @type forward
3
+ @id forward_input
4
+ </source>
5
+
6
+ <match azuresearch.*>
7
+ @type azuresearch
8
+ @log_level info
9
+ endpoint https://<AzureSearchServiceName>.search.windows.net
10
+ api_key <Azure Search API Admin Key>
11
+ search_index messages
12
+ column_names id,user_name,message,created_at
13
+ key_names postid,user,content,posttime
14
+ </match>
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ echo ' { "postid":"1", "user":"ladygaga", "content":"post by ladygaga", "posttime":"2017-05-20T00:00:00Z"}' | fluent-cat azuresearch.msg
4
+
@@ -18,10 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
21
+ gem.add_dependency "fluentd", [">= 0.14.15", "< 2"]
22
22
  gem.add_dependency "rest-client"
23
23
  gem.add_development_dependency "bundler", "~> 1.11"
24
24
  gem.add_development_dependency "rake", "~> 10.0"
25
25
  gem.add_development_dependency "test-unit"
26
26
  end
27
-
@@ -1,4 +1,4 @@
1
- module Fluent
1
+ module Fluent::Plugin
2
2
  module AzureSearch
3
3
  class Client
4
4
 
@@ -16,8 +16,8 @@ module Fluent
16
16
  end
17
17
 
18
18
  def add_documents(index_name, documents, merge=true)
19
- raise ConfigError, 'no index_name' if index_name.empty?
20
- raise ConfigError, 'no documents' if documents.empty?
19
+ raise Fluent::ConfigError, 'no index_name' if index_name.empty?
20
+ raise Fluent::ConfigError, 'no documents' if documents.empty?
21
21
  action = merge ? 'mergeOrUpload' : 'upload'
22
22
  for document in documents
23
23
  document['@search.action'] = action
@@ -1,15 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- module Fluent
4
- class AzureSearchOutput < BufferedOutput
5
- Plugin.register_output('azuresearch', self)
3
+ require 'fluent/plugin/output'
4
+ require 'msgpack'
5
+ require 'time'
6
+ require 'fluent/plugin/azuresearch/client'
6
7
 
7
- def initialize
8
- super
9
- require 'msgpack'
10
- require 'time'
11
- require 'fluent/plugin/azuresearch/client'
12
- end
8
+ module Fluent::Plugin
9
+ class AzureSearchOutput < Output
10
+ Fluent::Plugin.register_output('azuresearch', self)
11
+
12
+ helpers :compat_parameters
13
+
14
+ DEFAULT_BUFFER_TYPE = "memory"
13
15
 
14
16
  config_param :endpoint, :string,
15
17
  :desc => "Azure Search Endpoint URL"
@@ -26,23 +28,29 @@ ${time} is placeholder for Time.at(time).strftime("%Y-%m-%dT%H:%M:%SZ"),
26
28
  and ${tag} is placeholder for tag
27
29
  DESC
28
30
 
31
+ config_section :buffer do
32
+ config_set_default :@type, DEFAULT_BUFFER_TYPE
33
+ config_set_default :chunk_keys, ['tag']
34
+ end
35
+
29
36
  def configure(conf)
37
+ compat_parameters_convert(conf, :buffer)
30
38
  super
31
- raise ConfigError, 'no endpoint' if @endpoint.empty?
32
- raise ConfigError, 'no api_key' if @api_key.empty?
33
- raise ConfigError, 'no search_index' if @search_index.empty?
34
- raise ConfigError, 'no column_names' if @column_names.empty?
35
-
39
+ raise Fluent::ConfigError, 'no endpoint' if @endpoint.empty?
40
+ raise Fluent::ConfigError, 'no api_key' if @api_key.empty?
41
+ raise Fluent::ConfigError, 'no search_index' if @search_index.empty?
42
+ raise Fluent::ConfigError, 'no column_names' if @column_names.empty?
43
+
36
44
  @column_names = @column_names.split(',')
37
45
  @key_names = @key_names.nil? ? @column_names : @key_names.split(',')
38
- raise ConfigError, 'NOT match keys number: column_names and key_names' \
46
+ raise Fluent::ConfigError, 'NOT match keys number: column_names and key_names' \
39
47
  if @key_names.length != @column_names.length
40
48
  end
41
49
 
42
50
  def start
43
51
  super
44
52
  # start
45
- @client=Fluent::AzureSearch::Client::new( @endpoint, @api_key )
53
+ @client=Fluent::Plugin::AzureSearch::Client::new( @endpoint, @api_key )
46
54
  end
47
55
 
48
56
  def shutdown
@@ -65,6 +73,14 @@ DESC
65
73
  [tag, time, values].to_msgpack
66
74
  end
67
75
 
76
+ def formatted_to_msgpack_binary?
77
+ true
78
+ end
79
+
80
+ def multi_workers_ready?
81
+ true
82
+ end
83
+
68
84
  def write(chunk)
69
85
  documents = []
70
86
  chunk.msgpack_each do |tag, time, values|
@@ -79,7 +95,7 @@ DESC
79
95
  res = @client.add_documents(@search_index, documents)
80
96
  puts res
81
97
  rescue Exception => ex
82
- $log.fatal "UnknownError: '#{ex}'"
98
+ log.fatal "UnknownError: '#{ex}'"
83
99
  + ", data=>" + (documents.to_json).to_s
84
100
  end
85
101
  end
@@ -23,7 +23,10 @@ unless ENV.has_key?('VERBOSE')
23
23
  $log = nulllogger
24
24
  end
25
25
 
26
+ require 'fluent/test/driver/output'
27
+ require 'fluent/test/helpers'
26
28
  require 'fluent/plugin/out_azuresearch'
27
29
 
28
30
  class Test::Unit::TestCase
31
+ include Fluent::Test::Helpers
29
32
  end
@@ -18,57 +18,57 @@ class AzureSearchOutputTest < Test::Unit::TestCase
18
18
  # utc
19
19
  # ]
20
20
 
21
- def create_driver(conf = CONFIG, tag='azuresearch.test')
22
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::AzureSearchOutput, tag).configure(conf)
21
+ def create_driver(conf = CONFIG)
22
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::AzureSearchOutput).configure(conf)
23
23
  end
24
24
 
25
25
  def test_configure
26
- #### set configurations
27
- # d = create_driver %[
28
- # path test_path
29
- # compress gz
30
- # ]
31
- #### check configurations
32
- # assert_equal 'test_path', d.instance.path
33
- # assert_equal :gz, d.instance.compress
26
+ d = create_driver
27
+
28
+ assert_equal 'https://AZURE_SEARCH_ACCOUNT.search.windows.net', d.instance.endpoint
29
+ assert_equal 'AZURE_SEARCH_API_KEY', d.instance.api_key
30
+ assert_equal 'messages', d.instance.search_index
31
+ assert_equal ["id", "user_name", "message", "tag", "created_at"], d.instance.column_names
34
32
  end
35
33
 
36
34
  def test_format
37
35
  d = create_driver
38
36
 
39
- # time = Time.parse("2011-01-02 13:14:15 UTC").to_i
40
- # d.emit({"a"=>1}, time)
41
- # d.emit({"a"=>2}, time)
42
-
43
- # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
44
- # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
37
+ time = event_time("2011-01-02 13:14:15 UTC")
38
+ d.run(default_tag: 'documentdb.test') do
39
+ d.feed(time, {"a"=>1})
40
+ d.feed(time, {"a"=>2})
41
+ end
45
42
 
46
- # d.run
43
+ # assert_equal EXPECTED1, d.formatted[0]
44
+ # assert_equal EXPECTED2, d.formatted[1]
47
45
  end
48
46
 
49
47
  def test_write
50
48
  d = create_driver
51
49
 
52
- time = Time.parse("2016-01-28 13:14:15 UTC").to_i
53
- d.emit(
54
- {
55
- "postid" => "10001",
56
- "user"=> "ladygaga",
57
- "content" => "post by ladygaga",
58
- "tag" => "azuresearch.msg",
59
- "posttime" =>"2016-01-31T00:00:00Z"
60
- }, time)
50
+ time = event_time("2016-01-28 13:14:15 UTC")
51
+ data = d.run(default_tag: 'azuresearch.test') do
52
+ d.feed(
53
+ time,
54
+ {
55
+ "postid" => "10001",
56
+ "user"=> "ladygaga",
57
+ "content" => "post by ladygaga",
58
+ "tag" => "azuresearch.msg",
59
+ "posttime" =>"2016-01-31T00:00:00Z"
60
+ })
61
61
 
62
- d.emit(
63
- {
64
- "postid" => "10002",
65
- "user"=> "katyperry",
66
- "content" => "post by katyperry",
67
- "tag" => "azuresearch.msg",
68
- "posttime" => "2016-01-31T00:00:00Z"
69
- }, time)
70
-
71
- data = d.run
62
+ d.feed(
63
+ time,
64
+ {
65
+ "postid" => "10002",
66
+ "user"=> "katyperry",
67
+ "content" => "post by katyperry",
68
+ "tag" => "azuresearch.msg",
69
+ "posttime" => "2016-01-31T00:00:00Z"
70
+ })
71
+ end
72
72
  puts data
73
73
  # ### FileOutput#write returns path
74
74
  # path = d.run
@@ -76,4 +76,3 @@ class AzureSearchOutputTest < Test::Unit::TestCase
76
76
  # assert_equal expect_path, path
77
77
  end
78
78
  end
79
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-azuresearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichi Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-20 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.58
19
+ version: 0.14.15
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.10.58
29
+ version: 0.14.15
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
@@ -94,11 +94,14 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
- - ChangeLog
97
+ - ChangeLog.md
98
98
  - Gemfile
99
99
  - README.md
100
100
  - Rakefile
101
101
  - VERSION
102
+ - examples/createindex-messages.sh
103
+ - examples/fluent.conf
104
+ - examples/send-event.sh
102
105
  - fluent-plugin-azuresearch.gemspec
103
106
  - lib/fluent/plugin/azuresearch/client.rb
104
107
  - lib/fluent/plugin/out_azuresearch.rb
@@ -124,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
127
  version: '0'
125
128
  requirements: []
126
129
  rubyforge_project:
127
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.5.2
128
131
  signing_key:
129
132
  specification_version: 4
130
133
  summary: Azure Search output plugin for Fluentd
data/ChangeLog DELETED
@@ -1,11 +0,0 @@
1
- Release 0.1.2 - 2016/02/20
2
-
3
- * Change gem package dependency option for rest-client from add_development_dependency to add_dependency
4
-
5
- Release 0.1.1 - 2016/02/20
6
-
7
- * Security enhanced option: Added secret option to api_key
8
-
9
- Release 0.1.0 - 2016/02/11
10
-
11
- * Inital Release