fluent-plugin-azurefunctions 0.1.1 → 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: 3110c479872af4941bd94a6cc65507068811b37b
4
- data.tar.gz: 2c14ca72f3d95508f90828c2cf1a3c44c0e4e88e
3
+ metadata.gz: 83eccba4bb49d6569a791d111c80e6a74d61e565
4
+ data.tar.gz: 5c1d87ecc87033efbc85f4e57d30636a6e540fd5
5
5
  SHA512:
6
- metadata.gz: bc157e69274bd27a395cacffc9a3f219926eab95dd774b5229f3db171cfddc28120f32861d999d1f1d773ff424d34dce22fef6377c4b7599f822aa8df6431035
7
- data.tar.gz: 08540d4ccfcc4e694d81da6337ea4a5d9799e646b51a4a6b5c2c85623a1da44ad9f0e69a2d13df983cb0677f6428509a3aa56330ec2809ad9dbfe7e0b68466ca
6
+ metadata.gz: ca82ecfd1960a970ad8a6a7e96c2474035bf66abfc75b36d85e281299905d354f2d486607e28c3aaad77a04b04885836c22170b6dc8525a51d39249bead89848
7
+ data.tar.gz: 73886b67f142ab5aa8bb47ffa84259d3fd23c930c71d6abf9b8e6a20da1222c54eecf4220364177ad74bad765622c229c935186bd441cf04404622b0cc86eea7
@@ -1,3 +1,8 @@
1
+ ## 0.2.0
2
+
3
+ * Migrate to use fluentd v0.14 API - [PR#2](https://github.com/yokawasa/fluent-plugin-azurefunctions/pull/2)
4
+ * Support plugin specific log level - [PR#1](https://github.com/yokawasa/fluent-plugin-azurefunctions/pull/1)
5
+
1
6
  ## 0.1.1
2
7
 
3
8
  * Changed Azure functions API key authorization from simply adding it to query string as code param to including it to x-functions-key HTTP header
data/README.md CHANGED
@@ -4,6 +4,13 @@
4
4
  ![fluent-plugin-azurefunctions overview](https://github.com/yokawasa/fluent-plugin-azurefunctions/raw/master/img/Azure-Functions-Fluentd.png)
5
5
 
6
6
 
7
+ ## Requirements
8
+
9
+ | fluent-plugin-documentdb | fluentd | ruby |
10
+ |------------------------|---------|------|
11
+ | >= 0.2.0 | >= v0.14.15 | >= 2.1 |
12
+ | < 0.2.0 | >= v0.12.0 | >= 1.9 |
13
+
7
14
  ## Installation
8
15
  ```
9
16
  $ gem install fluent-plugin-azurefunctions
@@ -30,6 +37,7 @@ examples/function-csharp
30
37
  ```
31
38
  <match azurefunctions.**>
32
39
  @type azurefunctions
40
+ @log_level info
33
41
  endpoint AZURE_FUNCTION_ENDPOINT # ex. https://<accountname>.azurewebsites.net/api/<functionname>
34
42
  function_key AZURE_FUNCTION_KEY # ex. aRVQ7Lj0vzDhY0JBYF8gpxYyEBxLwhO51JSC7X5dZFbTvROs7uNg==
35
43
  key_names key1,key2,key3
@@ -52,6 +60,7 @@ examples/function-csharp
52
60
  * **add\_tag\_field (optional)** - Default:false. This option allows to insert a tag field to record
53
61
  * **tag\_field\_name (optional)** - Default:tag. This is required only when add_time_field is true
54
62
 
63
+ [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))
55
64
 
56
65
  ## Configuration examples
57
66
 
@@ -81,10 +90,6 @@ echo ' { "key1":"value1", "key2":"value2", "key3":"value3"}' | fluent-cat azuref
81
90
  {
82
91
  "payload": '{"key1":"value1", "key2":"value2", "key3":"value3", "time":"1479741633"}'
83
92
  }
84
-
85
- mytime=1479741633
86
-
87
-
88
93
  ```
89
94
 
90
95
 
@@ -151,6 +156,7 @@ $ echo ' { "key1":"value1", "key2":"value2", "key3":"value3"}' | fluent-cat azur
151
156
 
152
157
  ## Links
153
158
 
159
+ * https://yokawasa.github.io/fluent-plugin-azurefunctions
154
160
  * https://rubygems.org/gems/fluent-plugin-azurefunctions
155
161
  * http://unofficialism.info/posts/fluent-plugin-azurefunctions/
156
162
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -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,15 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- module Fluent
4
- class AzureFunctionsOutput < BufferedOutput
5
- Plugin.register_output('azurefunctions', self)
3
+ require 'fluent/plugin/output'
4
+ require 'msgpack'
5
+ require 'time'
6
+ require 'fluent/plugin/azurefunctions/client'
6
7
 
7
- def initialize
8
- super
9
- require 'msgpack'
10
- require 'time'
11
- require 'fluent/plugin/azurefunctions/client'
12
- end
8
+ module Fluent::Plugin
9
+ class AzureFunctionsOutput < Output
10
+ Fluent::Plugin.register_output('azurefunctions', self)
11
+
12
+ helpers :compat_parameters
13
+
14
+ DEFAULT_BUFFER_TYPE = "memory"
13
15
 
14
16
  config_param :endpoint, :string,
15
17
  :desc => "Azure Functions Endpoint URL"
@@ -30,20 +32,25 @@ module Fluent
30
32
  config_param :tag_field_name, :string, :default => "tag",
31
33
  :desc => "This is required only when add_time_field is true"
32
34
 
35
+ config_section :buffer do
36
+ config_set_default :@type, DEFAULT_BUFFER_TYPE
37
+ end
38
+
33
39
  def configure(conf)
40
+ compat_parameters_convert(conf, :buffer)
34
41
  super
35
- raise ConfigError, 'no endpoint' if @endpoint.empty?
36
- raise ConfigError, 'no function_key' if @function_key.empty?
42
+ raise Fluent::ConfigError, 'no endpoint' if @endpoint.empty?
43
+ raise Fluent::ConfigError, 'no function_key' if @function_key.empty?
37
44
  if not @key_names.nil?
38
45
  @key_names = @key_names.split(',')
39
46
  end
40
47
  if @add_time_field and @time_field_name.empty?
41
- raise ConfigError, 'time_field_name must be set if add_time_field is true'
48
+ raise Fluent::ConfigError, 'time_field_name must be set if add_time_field is true'
42
49
  end
43
50
  if @add_tag_field and @tag_field_name.empty?
44
- raise ConfigError, 'tag_field_name must be set if add_tag_field is true'
51
+ raise Fluent::ConfigError, 'tag_field_name must be set if add_tag_field is true'
45
52
  end
46
- @timef = TimeFormatter.new(@time_format, @localtime)
53
+ @timef = Fluent::TimeFormatter.new(@time_format, @localtime)
47
54
  end
48
55
 
49
56
  def start
@@ -86,6 +93,14 @@ module Fluent
86
93
  record.to_msgpack
87
94
  end
88
95
 
96
+ def formatted_to_msgpack_binary?
97
+ true
98
+ end
99
+
100
+ def multi_workers_ready?
101
+ true
102
+ end
103
+
89
104
  def write(chunk)
90
105
  chunk.msgpack_each { |record|
91
106
  payload = JSON.dump(record)
@@ -95,7 +110,7 @@ module Fluent
95
110
  begin
96
111
  @client.post(payload)
97
112
  rescue Exception => ex
98
- $log.fatal "Error occured in posting to Azure Functions HTTP trigger function: "
113
+ log.fatal "Error occured in posting to Azure Functions HTTP trigger function: "
99
114
  + "'#{ex}', .rid=>#{unique_identifier}, payload=>" + payload
100
115
  end
101
116
  }
@@ -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_azurefunctions'
27
29
 
28
30
  class Test::Unit::TestCase
31
+ include Fluent::Test::Helpers
29
32
  end
@@ -20,69 +20,77 @@ class AzureFunctionsOutputTest < Test::Unit::TestCase
20
20
  # utc
21
21
  # ]
22
22
 
23
- def create_driver(conf = CONFIG, tag='azurefunctions.test')
24
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::AzureFunctionsOutput, tag).configure(conf)
23
+ def create_driver(conf = CONFIG)
24
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::AzureFunctionsOutput).configure(conf)
25
25
  end
26
26
 
27
27
  def test_configure
28
- #### set configurations
29
- # d = create_driver %[
30
- # path test_path
31
- # compress gz
32
- # ]
33
- #### check configurations
34
- # assert_equal 'test_path', d.instance.path
35
- # assert_equal :gz, d.instance.compress
28
+ d = create_driver
29
+
30
+ assert_equal 'https://yoichikademo1.azurewebsites.net/api/HttpTriggerFunction',
31
+ d.instance.endpoint
32
+ assert_equal 'aRVQ7Lj0vzDhY0JBYF8gpDzDCyEBxLwhO51JSC7X5dZFbTvROs7uNg==',
33
+ d.instance.function_key
34
+ assert_equal ["postid", "user", "content", "tag"], d.instance.key_names
35
+ assert_true d.instance.localtime
36
+ assert_true d.instance.add_time_field
37
+ assert_equal 'time', d.instance.time_field_name
38
+ assert_true d.instance.add_tag_field
39
+ assert_equal 'tag', d.instance.tag_field_name
36
40
  end
37
41
 
38
42
  def test_format
39
43
  d = create_driver
40
44
 
41
- # time = Time.parse("2011-01-02 13:14:15 UTC").to_i
42
- # d.emit({"a"=>1}, time)
43
- # d.emit({"a"=>2}, time)
44
-
45
- # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
46
- # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
45
+ time = event_time("2011-01-02 13:14:15 UTC")
46
+ d.run(default_tag: 'documentdb.test') do
47
+ d.feed(time, {"a"=>1})
48
+ d.feed(time, {"a"=>2})
49
+ end
47
50
 
48
- # d.run
51
+ # assert_equal EXPECTED1, d.formatted[0]
52
+ # assert_equal EXPECTED2, d.formatted[1]
49
53
  end
50
54
 
51
55
  def test_write
52
56
  d = create_driver
53
57
 
54
- time = Time.parse("2016-01-28 13:14:15 UTC").to_i
55
- d.emit(
56
- {
57
- "postid" => "10001",
58
- "user"=> "ladygaga",
59
- "content" => "post by ladygaga",
60
- "tag" => "azurefunctions.debug",
61
- "posttime" =>"2016-11-31T00:00:00Z"
62
- }, time)
58
+ time = event_time("2016-01-28 13:14:15 UTC")
59
+ data = d.run(default_tag: 'azurefunctions.test') do
60
+ d.feed(
61
+ time,
62
+ {
63
+ "postid" => "10001",
64
+ "user"=> "ladygaga",
65
+ "content" => "post by ladygaga",
66
+ "tag" => "azurefunctions.debug",
67
+ "posttime" =>"2016-11-31T00:00:00Z"
68
+ })
63
69
 
64
- d.emit(
65
- {
66
- "postid" => "10002",
67
- "user"=> "katyperry",
68
- "content" => "post by katyperry",
69
- "tag" => "azurefunctions.debug",
70
- "posttime" =>"2016-11-31T00:00:00Z"
71
- }, time)
70
+ d.feed(
71
+ time,
72
+ {
73
+ "postid" => "10002",
74
+ "user"=> "katyperry",
75
+ "content" => "post by katyperry",
76
+ "tag" => "azurefunctions.debug",
77
+ "posttime" =>"2016-11-31T00:00:00Z"
78
+ })
72
79
 
73
- d.emit(
74
- {
75
- "postid" => "10003",
76
- "tag" => "azurefunctions.debug",
77
- "time" =>"2016-11-31T00:00:00Z"
78
- }, time)
80
+ d.feed(
81
+ time,
82
+ {
83
+ "postid" => "10003",
84
+ "tag" => "azurefunctions.debug",
85
+ "time" =>"2016-11-31T00:00:00Z"
86
+ })
79
87
 
80
- d.emit(
81
- {
82
- "posttime" => "2016-11-31T00:00:00Z"
83
- }, time)
84
-
85
- data = d.run
88
+ d.feed(
89
+ time,
90
+ {
91
+ "posttime" => "2016-11-31T00:00:00Z"
92
+ })
93
+ end
86
94
  puts data
87
95
  # ### FileOutput#write returns path
88
96
  # path = d.run
@@ -90,4 +98,3 @@ class AzureFunctionsOutputTest < Test::Unit::TestCase
90
98
  # assert_equal expect_path, path
91
99
  end
92
100
  end
93
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-azurefunctions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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-11-26 00:00:00.000000000 Z
11
+ date: 2017-06-21 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'