fluent-plugin-azuresearch 0.1.0
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 +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +214 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/fluent-plugin-azuresearch.gemspec +27 -0
- data/lib/fluent/plugin/azuresearch/client.rb +38 -0
- data/lib/fluent/plugin/out_azuresearch.rb +88 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_azuresearch.rb +79 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 362fb7a695da9953905fd8faf91ab2d376ae2c02
|
4
|
+
data.tar.gz: 64357c3dd45fc907c104810462704a8f436cb817
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5035b607d6d772ef9edc0e7d766d05deb6110038026c395ae98f1af13bbcbbbcfe65f699beef2cc7a932147b378d327937398196aa5eefa8344b3ae7a0efd176
|
7
|
+
data.tar.gz: 255287d1b9c4c62894089574a5b0b5012b17ec4216e7cef960f064a07a6379afaf4ee618c0bde178cf6f5a7a34af7d94df7ace2fb7751ec3b41d1bb59f9b6cd9
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
# Azure Search output plugin for Fluentd
|
2
|
+
|
3
|
+
fluent-plugin-azuresearch is a fluent plugin to output to Azure Search
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install fluent-plugin-azuresearch
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
### Azure Search
|
12
|
+
|
13
|
+
To use Microsoft Azure Search, you must create an Azure Search service in the Azure Portal. Also you must have an index, persisted storage of documents to which fluent-plugin-azuresearch writes event stream out. Here are instructions:
|
14
|
+
|
15
|
+
* [Create a service](https://azure.microsoft.com/en-us/documentation/articles/search-create-service-portal/)
|
16
|
+
* [Create an index](https://azure.microsoft.com/en-us/documentation/articles/search-what-is-an-index/)
|
17
|
+
|
18
|
+
|
19
|
+
### Fluentd - fluent.conf
|
20
|
+
|
21
|
+
<match azuresearch.*>
|
22
|
+
type azuresearch
|
23
|
+
endpoint https://AZURE_SEARCH_ACCOUNT.search.windows.net
|
24
|
+
api_key AZURE_SEARCH_API_KEY
|
25
|
+
search_index messages
|
26
|
+
column_names id,user_name,message,tag,created_at
|
27
|
+
key_names postid,user,content,tag,posttime
|
28
|
+
</match>
|
29
|
+
|
30
|
+
* **endpoint (required)** - Azure Search service endpoint URI
|
31
|
+
* **api\_key (required)** - Azure Search API key
|
32
|
+
* **search\_index (required)** - Azure Search Index name to insert records
|
33
|
+
* **column\_names (required)** - Column names in a target Azure search index. Each column needs to be separated by a comma.
|
34
|
+
* **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
|
+
## Sample Configurations
|
37
|
+
### Case1 - column_names is as same as key_names
|
38
|
+
|
39
|
+
Suppose you have the following fluent.conf and azure search index schema:
|
40
|
+
|
41
|
+
<u>fluent.conf</u>
|
42
|
+
|
43
|
+
<match azuresearch.*>
|
44
|
+
type azuresearch
|
45
|
+
endpoint https://yoichidemo.search.windows.net
|
46
|
+
api_key 2XX3D2456052A9AD21E54CB03C3ABF6A(dummy)
|
47
|
+
search_index messages
|
48
|
+
column_names id,user_name,message,created_at
|
49
|
+
</match>
|
50
|
+
|
51
|
+
<u>Azure Search Schema: messages</u>
|
52
|
+
|
53
|
+
{
|
54
|
+
"name": "messages",
|
55
|
+
"fields": [
|
56
|
+
{ "name":"id", "type":"Edm.String", "key": true, "searchable": false },
|
57
|
+
{ "name":"user_name", "type":"Edm.String" },
|
58
|
+
{ "name":"message", "type":"Edm.String", "filterable":false, "sortable":false, "facetable":false, "analyzer":"en.lucene" },
|
59
|
+
{ "name":"created_at", "type":"Edm.DateTimeOffset", "facetable":false}
|
60
|
+
]
|
61
|
+
}
|
62
|
+
|
63
|
+
The plugin will write event stream out to Azure Ssearch like this:
|
64
|
+
|
65
|
+
<u>Input event stream</u>
|
66
|
+
|
67
|
+
{ "id": "1", "user_name": "taylorswift13", "message":"post by taylorswift13", "created_at":"2016-01-29T00:00:00Z" },
|
68
|
+
{ "id": "2", "user_name": "katyperry", "message":"post by katyperry", "created_at":"2016-01-30T00:00:00Z" },
|
69
|
+
{ "id": "3", "user_name": "ladygaga", "message":"post by ladygaga", "created_at":"2016-01-31T00:00:00Z" }
|
70
|
+
|
71
|
+
|
72
|
+
<u>Search results</u>
|
73
|
+
|
74
|
+
"value": [
|
75
|
+
{ "@search.score": 1, "id": "1", "user_name": "taylorswift13", "message": "post by taylorswift13", "created_at": "2016-01-29T00:00:00Z" },
|
76
|
+
{ "@search.score": 1, "id": "2", "user_name": "katyperry", "message": "post by katyperry", "created_at": "2016-01-30T00:00:00Z" },
|
77
|
+
{ "@search.score": 1, "id": "3", "user_name": "ladygaga", "message": "post by ladygaga", "created_at": "2016-01-31T00:00:00Z" }
|
78
|
+
]
|
79
|
+
|
80
|
+
|
81
|
+
### Case2 - column_names is NOT as same as key_names
|
82
|
+
|
83
|
+
Suppose you have the following fluent.conf and azure search index schema:
|
84
|
+
|
85
|
+
<u>fluent.conf</u>
|
86
|
+
|
87
|
+
<match azuresearch.*>
|
88
|
+
type azuresearch
|
89
|
+
endpoint https://yoichidemo.search.windows.net
|
90
|
+
api_key 2XX3D2456052A9AD21E54CB03C3ABF6A(dummy)
|
91
|
+
search_index messages
|
92
|
+
column_names id,user_name,message,created_at
|
93
|
+
key_names postid,user,content,posttime
|
94
|
+
</match>
|
95
|
+
|
96
|
+
<u>Azure Search Schema: messages</u>
|
97
|
+
|
98
|
+
{
|
99
|
+
"name": "messages",
|
100
|
+
"fields": [
|
101
|
+
{ "name":"id", "type":"Edm.String", "key": true, "searchable": false },
|
102
|
+
{ "name":"user_name", "type":"Edm.String" },
|
103
|
+
{ "name":"message", "type":"Edm.String", "filterable":false, "sortable":false, "facetable":false, "analyzer":"en.lucene" },
|
104
|
+
{ "name":"created_at", "type":"Edm.DateTimeOffset", "facetable":false}
|
105
|
+
]
|
106
|
+
}
|
107
|
+
|
108
|
+
The plugin will write event stream out to Azure Ssearch like this:
|
109
|
+
|
110
|
+
<u>Input event stream</u>
|
111
|
+
|
112
|
+
{ "postid": "1", "user": "taylorswift13", "content":"post by taylorswift13", "posttime":"2016-01-29T00:00:00Z" },
|
113
|
+
{ "postid": "2", "user": "katyperry", "content":"post by katyperry", "posttime":"2016-01-30T00:00:00Z" },
|
114
|
+
{ "postid": "3", "user": "ladygaga", "content":"post by ladygaga", "posttime":"2016-01-31T00:00:00Z" }
|
115
|
+
|
116
|
+
|
117
|
+
<u>Search results</u>
|
118
|
+
|
119
|
+
"value": [
|
120
|
+
{ "@search.score": 1, "id": "1", "user_name": "taylorswift13", "message": "post by taylorswift13", "created_at": "2016-01-29T00:00:00Z" },
|
121
|
+
{ "@search.score": 1, "id": "2", "user_name": "katyperry", "message": "post by katyperry", "created_at": "2016-01-30T00:00:00Z" },
|
122
|
+
{ "@search.score": 1, "id": "3", "user_name": "ladygaga", "message": "post by ladygaga", "created_at": "2016-01-31T00:00:00Z" }
|
123
|
+
]
|
124
|
+
|
125
|
+
|
126
|
+
### Case3 - column_names is NOT as same as key_names, Plus, key_names includes ${time} and ${tag}
|
127
|
+
|
128
|
+
<u>fluent.conf</u>
|
129
|
+
|
130
|
+
<match azuresearch.*>
|
131
|
+
type azuresearch
|
132
|
+
endpoint https://yoichidemo.search.windows.net
|
133
|
+
api_key 2XX3D2456052A9AD21E54CB03C3ABF6A(dummy)
|
134
|
+
search_index messages
|
135
|
+
column_names id,user_name,message,tag,created_at
|
136
|
+
key_names postid,user,content,${tag},${time}
|
137
|
+
</match>
|
138
|
+
|
139
|
+
<u>Azure Search Schema: messages</u>
|
140
|
+
|
141
|
+
{
|
142
|
+
"name": "messages",
|
143
|
+
"fields": [
|
144
|
+
{ "name":"id", "type":"Edm.String", "key": true, "searchable": false },
|
145
|
+
{ "name":"user_name", "type":"Edm.String" },
|
146
|
+
{ "name":"message", "type":"Edm.String", "filterable":false, "sortable":false, "facetable":false, "analyzer":"en.lucene" },
|
147
|
+
{ "name":"created_at", "type":"Edm.DateTimeOffset", "facetable":false}
|
148
|
+
]
|
149
|
+
}
|
150
|
+
|
151
|
+
The plugin will write event stream out to Azure Ssearch like this:
|
152
|
+
|
153
|
+
<u>Input event stream</u>
|
154
|
+
|
155
|
+
{ "id": "1", "user_name": "taylorswift13", "message":"post by taylorswift13" },
|
156
|
+
{ "id": "2", "user_name": "katyperry", "message":"post by katyperry" },
|
157
|
+
{ "id": "3", "user_name": "ladygaga", "message":"post by ladygaga" }
|
158
|
+
|
159
|
+
<u>Search results</u>
|
160
|
+
|
161
|
+
"value": [
|
162
|
+
{ "@search.score": 1, "id": "1", "user_name": "taylorswift13", "message": "post by taylorswift13", "tag": "azuresearch.msg", "created_at": "2016-01-31T21:03:41Z" },
|
163
|
+
{ "@search.score": 1, "id": "2", "user_name": "katyperry", "message": "post by katyperry", "tag": "azuresearch.msg", "created_at": "2016-01-31T21:03:41Z" },
|
164
|
+
{ "@search.score": 1, "id": "3", "user_name": "ladygaga", "message": "post by ladygaga", "tag": "azuresearch.msg", "created_at": "2016-01-31T21:03:41Z" }
|
165
|
+
]
|
166
|
+
[note] the value of created_at above is the time when fluentd actually recieves its corresponding input event.
|
167
|
+
|
168
|
+
|
169
|
+
## Tests
|
170
|
+
### Running test code
|
171
|
+
$ git clone https://github.com/yokawasa/fluent-plugin-azuresearch.git
|
172
|
+
$ cd fluent-plugin-azuresearch
|
173
|
+
|
174
|
+
# edit CONFIG params of test/plugin/test_azuresearch.rb
|
175
|
+
$ vi test/plugin/test_azuresearch.rb
|
176
|
+
|
177
|
+
# run test
|
178
|
+
$ rake test
|
179
|
+
|
180
|
+
### Creating package, running and testing locally
|
181
|
+
$ rake build
|
182
|
+
$ rake install:local
|
183
|
+
|
184
|
+
# running fluentd with your fluent.conf
|
185
|
+
$ fluentd -c fluent.conf -vv &
|
186
|
+
|
187
|
+
# send test input event to test plugin using fluent-cat
|
188
|
+
$ echo ' { "postid": "100", "user": "ladygaga", "content":"post by ladygaga"}' | fluent-cat azuresearch.msg
|
189
|
+
|
190
|
+
Please don't forget that you need forward input configuration to receive the message from fluent-cat
|
191
|
+
|
192
|
+
<source>
|
193
|
+
type forward
|
194
|
+
</source>
|
195
|
+
|
196
|
+
|
197
|
+
## TODOs
|
198
|
+
* Input validation for Azure Search - check total size of columns to add
|
199
|
+
|
200
|
+
## Contributing
|
201
|
+
|
202
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yokawasa/fluent-plugin-azuresearch.
|
203
|
+
|
204
|
+
## Copyright
|
205
|
+
|
206
|
+
<table>
|
207
|
+
<tr>
|
208
|
+
<td>Copyright</td><td>Copyright (c) 2016- Yoichi Kawasaki</td>
|
209
|
+
</tr>
|
210
|
+
<tr>
|
211
|
+
<td>License</td><td>Apache License, Version 2.0</td>
|
212
|
+
</tr>
|
213
|
+
</table>
|
214
|
+
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "fluent-plugin-azuresearch"
|
7
|
+
gem.version = File.read("VERSION").strip
|
8
|
+
gem.authors = ["Yoichi Kawasaki"]
|
9
|
+
gem.email = ["yoichi.kawasaki@outlook.com"]
|
10
|
+
gem.summary = %q{Azure Search output plugin for Fluentd}
|
11
|
+
gem.description = gem.summary
|
12
|
+
gem.homepage = "http://github.com/yokawasa/fluent-plugin-azuresearch"
|
13
|
+
gem.license = "Apache-2.0"
|
14
|
+
gem.has_rdoc = false
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
23
|
+
gem.add_development_dependency "test-unit"
|
24
|
+
gem.add_development_dependency "rest-client"
|
25
|
+
gem.add_runtime_dependency "fluentd"
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fluent
|
2
|
+
module AzureSearch
|
3
|
+
class Client
|
4
|
+
|
5
|
+
def initialize (api_url, api_key, api_version="2015-02-28")
|
6
|
+
require 'rest-client'
|
7
|
+
require 'json'
|
8
|
+
@api_url = api_url
|
9
|
+
@api_version = api_version
|
10
|
+
@headers = {
|
11
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
12
|
+
'Api-Key' => api_key,
|
13
|
+
'Accept' => "application/json",
|
14
|
+
'Accept-Charset' => "UTF-8"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
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?
|
21
|
+
action = merge ? 'mergeOrUpload' : 'upload'
|
22
|
+
for document in documents
|
23
|
+
document['@search.action'] = action
|
24
|
+
end
|
25
|
+
req_body = { :value => documents }.to_json
|
26
|
+
# p "REQ_BODY= #{req_body}"
|
27
|
+
# p "URI= #{@api_url}/indexes/#{index_name}/docs/index?api-version=#{@api_version}"
|
28
|
+
res = RestClient.post(
|
29
|
+
"#{@api_url}/indexes/#{index_name}/docs/index?api-version=#{@api_version}",
|
30
|
+
req_body,
|
31
|
+
@headers)
|
32
|
+
res
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class AzureSearchOutput < BufferedOutput
|
5
|
+
Plugin.register_output('azuresearch', self)
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
require 'msgpack'
|
10
|
+
require 'time'
|
11
|
+
require 'fluent/plugin/azuresearch/client'
|
12
|
+
end
|
13
|
+
|
14
|
+
config_param :endpoint, :string,
|
15
|
+
:desc => "Azure Search Endpoint URL"
|
16
|
+
config_param :api_key, :string,
|
17
|
+
:desc => "Azure Search API key"
|
18
|
+
config_param :search_index, :string,
|
19
|
+
:desc => "Azure Search Index name to insert records"
|
20
|
+
config_param :column_names, :string,
|
21
|
+
:desc => "Column names in a target Azure search index (comman separated)"
|
22
|
+
config_param :key_names, :string, default: nil,
|
23
|
+
:desc => <<-DESC
|
24
|
+
Key names in incomming record to insert (comman separated).
|
25
|
+
${time} is placeholder for Time.at(time).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
26
|
+
and ${tag} is placeholder for tag
|
27
|
+
DESC
|
28
|
+
|
29
|
+
def configure(conf)
|
30
|
+
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
|
+
|
36
|
+
@column_names = @column_names.split(',')
|
37
|
+
@key_names = @key_names.nil? ? @column_names : @key_names.split(',')
|
38
|
+
raise ConfigError, 'NOT match keys number: column_names and key_names' \
|
39
|
+
if @key_names.length != @column_names.length
|
40
|
+
end
|
41
|
+
|
42
|
+
def start
|
43
|
+
super
|
44
|
+
# start
|
45
|
+
@client=Fluent::AzureSearch::Client::new( @endpoint, @api_key )
|
46
|
+
end
|
47
|
+
|
48
|
+
def shutdown
|
49
|
+
super
|
50
|
+
# destroy
|
51
|
+
end
|
52
|
+
|
53
|
+
def format(tag, time, record)
|
54
|
+
values = []
|
55
|
+
@key_names.each_with_index do |key, i|
|
56
|
+
if key == '${time}'
|
57
|
+
value = Time.at(time).strftime('%Y-%m-%dT%H:%M:%SZ')
|
58
|
+
elsif key == '${tag}'
|
59
|
+
value = tag
|
60
|
+
else
|
61
|
+
value = record.include?(key) ? record[key] : ''
|
62
|
+
end
|
63
|
+
values << value
|
64
|
+
end
|
65
|
+
[tag, time, values].to_msgpack
|
66
|
+
end
|
67
|
+
|
68
|
+
def write(chunk)
|
69
|
+
documents = []
|
70
|
+
chunk.msgpack_each do |tag, time, values|
|
71
|
+
document = {}
|
72
|
+
@column_names.each_with_index do|k, i|
|
73
|
+
document[k] = values[i]
|
74
|
+
end
|
75
|
+
documents.push(document)
|
76
|
+
end
|
77
|
+
|
78
|
+
begin
|
79
|
+
res = @client.add_documents(@search_index, documents)
|
80
|
+
puts res
|
81
|
+
rescue Exception => ex
|
82
|
+
$log.fatal "UnknownError: '#{ex}'"
|
83
|
+
+ ", data=>" + (documents.to_json).to_s
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'fluent/test'
|
16
|
+
unless ENV.has_key?('VERBOSE')
|
17
|
+
nulllogger = Object.new
|
18
|
+
nulllogger.instance_eval {|obj|
|
19
|
+
def method_missing(method, *args)
|
20
|
+
# pass
|
21
|
+
end
|
22
|
+
}
|
23
|
+
$log = nulllogger
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'fluent/plugin/out_azuresearch'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AzureSearchOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
endpoint https://AZURE_SEARCH_ACCOUNT.search.windows.net
|
10
|
+
api_key AZURE_SEARCH_API_KEY
|
11
|
+
search_index messages
|
12
|
+
column_names id,user_name,message,tag,created_at
|
13
|
+
key_names postid,user,content,tag,posttime
|
14
|
+
]
|
15
|
+
# CONFIG = %[
|
16
|
+
# path #{TMP_DIR}/out_file_test
|
17
|
+
# compress gz
|
18
|
+
# utc
|
19
|
+
# ]
|
20
|
+
|
21
|
+
def create_driver(conf = CONFIG, tag='azuresearch.test')
|
22
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::AzureSearchOutput, tag).configure(conf)
|
23
|
+
end
|
24
|
+
|
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
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_format
|
37
|
+
d = create_driver
|
38
|
+
|
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]
|
45
|
+
|
46
|
+
# d.run
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_write
|
50
|
+
d = create_driver
|
51
|
+
|
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)
|
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
|
72
|
+
puts data
|
73
|
+
# ### FileOutput#write returns path
|
74
|
+
# path = d.run
|
75
|
+
# expect_path = "#{TMP_DIR}/out_file_test._0.log.gz"
|
76
|
+
# assert_equal expect_path, path
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-azuresearch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yoichi Kawasaki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fluentd
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Azure Search output plugin for Fluentd
|
84
|
+
email:
|
85
|
+
- yoichi.kawasaki@outlook.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- fluent-plugin-azuresearch.gemspec
|
96
|
+
- lib/fluent/plugin/azuresearch/client.rb
|
97
|
+
- lib/fluent/plugin/out_azuresearch.rb
|
98
|
+
- test/helper.rb
|
99
|
+
- test/plugin/test_azuresearch.rb
|
100
|
+
homepage: http://github.com/yokawasa/fluent-plugin-azuresearch
|
101
|
+
licenses:
|
102
|
+
- Apache-2.0
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.5.1
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Azure Search output plugin for Fluentd
|
124
|
+
test_files:
|
125
|
+
- test/helper.rb
|
126
|
+
- test/plugin/test_azuresearch.rb
|