fluent-plugin-google-cloud-storage 0.3.3 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b3a5589fde0af5eb5aeab523383f157893002a
4
- data.tar.gz: 8eeb8cb19a978ada03adb491ffc8b6241cf23027
3
+ metadata.gz: bf9c112b4b4d08e0773ae2ae0793e2b8d7b765a1
4
+ data.tar.gz: 36e41506714e22dbdae2f01554503787c6506efe
5
5
  SHA512:
6
- metadata.gz: bdd755f5d5d6c8ee767c4530f3ff1db3a3f75a5cd779557a536e54782c639edda7eaf3aee00459026634580326ed97e8743dfe3e1e3c596fe8b1d184bc85ceec
7
- data.tar.gz: 697f1f5cc9f03cae9e77b084bf00bcc6dcfb92f47113b1376197b989fcd57fdaceda3ebfa8734c48a16248e4eef06cc81399dad8bd50ef799baef430c653cd6f
6
+ metadata.gz: a5115e5522a4bad1399cc0188e47967f20c9f48d59ed2f8fd5b4bbc03544a0e94fac6166229e7b61d7008bb5b55b4dbe782a8ae19cab74e0077b1a20aab2e7be
7
+ data.tar.gz: 710eff5033c5f9e3c14f8a574c4d04ecf618c90ba7de800e164c956c2a9febf38052499ce7d75a73c0bee7cac71a9d6b3768c35160bae1593476e28bbbc9b032
data/README.md CHANGED
@@ -17,9 +17,39 @@ And you can specify output file path as 'path path/to/dir/access.%Y%m%d.log', th
17
17
 
18
18
  ## Configuration
19
19
 
20
- ### GoogleCloudStorageOutput
20
+ ### Examples
21
21
 
22
- To store data by time,tag,json (same with 'type file') over WebHDFS:
22
+ #### Complete Example
23
+
24
+ # tail
25
+ <source>
26
+ type tail
27
+ format none
28
+ path /tmp/test.log
29
+ pos_file /var/log/td-agent/test.pos
30
+ tag tail.test
31
+ </source>
32
+
33
+ # post to GCS
34
+ <match tail.test>
35
+ type google_cloud_storage
36
+ service_email xxx.xxx.com
37
+ service_pkcs12_path /etc/td-agent/My_First_Project-xxx.p12
38
+ project_id handy-compass-xxx
39
+ bucket_id test_bucket
40
+ path tail.test/%Y/%m/%d/%H/${hostname}/${chunk_id}.log.gz
41
+ output_include_time false
42
+ output_include_tag false
43
+ buffer_path /var/log/td-agent/buffer/tail.test
44
+ # flush_interval 600s
45
+ buffer_chunk_limit 128m
46
+ time_slice_wait 300s
47
+ compress gzip
48
+ </match>
49
+
50
+ #### More Examples
51
+
52
+ To store data by `time,tag,json` (same with 'type file') with GCS:
23
53
 
24
54
  <match access.**>
25
55
  type google_cloud_storage
@@ -27,7 +57,7 @@ To store data by time,tag,json (same with 'type file') over WebHDFS:
27
57
  service_pkcs12_path /path/to/key.p12
28
58
  project_id name-of-project
29
59
  bucket_id name-of-bucket
30
- path path/to/access.%Y%m%d_%H.log
60
+ path path/to/access.%Y%m%d_%H.${chunk_id}.log
31
61
  </match>
32
62
 
33
63
  To specify the pkcs12 file's password, use `service_pkcs12_password`:
@@ -39,7 +69,7 @@ To specify the pkcs12 file's password, use `service_pkcs12_password`:
39
69
  service_pkcs12_password SECRET_PASSWORD
40
70
  project_id name-of-project
41
71
  bucket_id name-of-bucket
42
- path path/to/access.%Y%m%d_%H.log
72
+ path path/to/access.%Y%m%d_%H.${chunk_id}.log
43
73
  </match>
44
74
 
45
75
  If you want JSON object only (without time or tag or both on header of lines), specify it by `output_include_time` or `output_include_tag` (default true):
@@ -50,7 +80,7 @@ If you want JSON object only (without time or tag or both on header of lines), s
50
80
  service_pkcs12_path /path/to/key.p12
51
81
  project_id name-of-project
52
82
  bucket_id name-of-bucket
53
- path path/to/access.%Y%m%d_%H.log
83
+ path path/to/access.%Y%m%d_%H.${chunk_id}.log
54
84
  output_include_time false
55
85
  output_include_tag false
56
86
  </match>
@@ -88,18 +118,22 @@ To store data compressed (gzip only now):
88
118
  compress gzip
89
119
  </match>
90
120
 
91
- ### Performance notifications
121
+ ### Major Caveat
92
122
 
93
123
  As GCS does not support appending to files, if you have multiple fluentd nodes,
94
- you most likely want to log to multiple files. You can use '${hostname}' or
124
+ you most likely each to log to separate files. You can use '${hostname}' or
95
125
  '${uuid:random}' placeholders in configuration for this purpose.
96
126
 
127
+ Note the `${chunk_id}` placeholder in the following paths. The plugin requires the presence
128
+ of the placeholder to guarantee that each flush will not overwrite an existing
129
+ file.
130
+
97
131
  For hostname:
98
132
 
99
133
  <match access.**>
100
134
  type google_cloud_storage
101
135
  # ...
102
- path log/access/%Y%m%d/${hostname}.log
136
+ path log/access/%Y%m%d/${hostname}.${chunk_id}.log
103
137
  </match>
104
138
 
105
139
  Or with random filename (to avoid duplicated file name only):
@@ -107,10 +141,11 @@ Or with random filename (to avoid duplicated file name only):
107
141
  <match access.**>
108
142
  type google_cloud_storage
109
143
  # ...
110
- path log/access/%Y%m%d/${uuid:random}.log
144
+ path log/access/%Y%m%d/${uuid:random}.${chunk_id}.log
111
145
  </match>
112
146
 
113
- With configurations above, you can handle all of files of '/log/access/20120820/*' as specified timeslice access logs.
147
+ With the configurations above, you can handle all of files of
148
+ '/log/access/20120820/*' as specified timeslice access logs.
114
149
 
115
150
  ## TODO
116
151
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-google-cloud-storage"
5
- gem.version = "0.3.3"
5
+ gem.version = "1.0.0"
6
6
  gem.authors = ["Hsiu-Fan Wang"]
7
7
  gem.email = ["hfwang@porkbuns.net"]
8
8
  gem.summary = %q{Fluentd plugin to write data to Google Cloud Storage}
@@ -19,5 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.add_runtime_dependency "fluentd", '>= 0.10.53'
20
20
  gem.add_runtime_dependency "fluent-mixin-plaintextformatter", '>= 0.2.1'
21
21
  gem.add_runtime_dependency "fluent-mixin-config-placeholders", ">= 0.3.0"
22
- gem.add_runtime_dependency "google-api-client", '~> 0.7'
22
+ gem.add_runtime_dependency "google-api-client", '0.8.6'
23
+ gem.add_runtime_dependency "mime-types", '>= 3.0'
23
24
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'fluent/mixin/config_placeholders'
4
4
  require 'fluent/mixin/plaintextformatter'
5
+ require 'fluent/log'
5
6
 
6
7
  class Fluent::GoogleCloudStorageOutput < Fluent::TimeSlicedOutput
7
8
  Fluent::Plugin.register_output('google_cloud_storage', self)
@@ -45,6 +46,7 @@ class Fluent::GoogleCloudStorageOutput < Fluent::TimeSlicedOutput
45
46
  require 'time'
46
47
  require 'google/api_client'
47
48
  require 'signet/oauth_2/client'
49
+ require 'mime-types'
48
50
  end
49
51
 
50
52
  # Define `log` method for v0.10.42 or earlier
@@ -110,7 +112,9 @@ class Fluent::GoogleCloudStorageOutput < Fluent::TimeSlicedOutput
110
112
  end
111
113
 
112
114
  def path_format(chunk_key)
113
- Time.strptime(chunk_key, @time_slice_format).strftime(@path)
115
+ path = Time.strptime(chunk_key, @time_slice_format).strftime(@path)
116
+ log.debug "GCS Path: #{path}"
117
+ path
114
118
  end
115
119
 
116
120
  def chunk_unique_id_to_str(unique_id)
@@ -118,7 +122,7 @@ class Fluent::GoogleCloudStorageOutput < Fluent::TimeSlicedOutput
118
122
  end
119
123
 
120
124
  def send_data(path, data)
121
- content_type = "application/json"
125
+ mimetype = MIME::Types.type_for(path).first
122
126
 
123
127
  io = nil
124
128
  if ["gz", "gzip"].include?(@compress)
@@ -131,7 +135,7 @@ class Fluent::GoogleCloudStorageOutput < Fluent::TimeSlicedOutput
131
135
  io = StringIO.new(data)
132
136
  end
133
137
 
134
- media = Google::APIClient::UploadIO.new(io, content_type, File.basename(path))
138
+ media = Google::APIClient::UploadIO.new(io, mimetype.content_type, File.basename(path))
135
139
 
136
140
  call_google_api(api_method: @storage_api.objects.insert,
137
141
  parameters: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hsiu-Fan Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -70,16 +70,30 @@ dependencies:
70
70
  name: google-api-client
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0.7'
75
+ version: 0.8.6
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0.7'
82
+ version: 0.8.6
83
+ - !ruby/object:Gem::Dependency
84
+ name: mime-types
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
83
97
  description: Google Cloud Storage fluentd output
84
98
  email:
85
99
  - hfwang@porkbuns.net
@@ -117,10 +131,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  version: '0'
118
132
  requirements: []
119
133
  rubyforge_project:
120
- rubygems_version: 2.2.2
134
+ rubygems_version: 2.4.8
121
135
  signing_key:
122
136
  specification_version: 4
123
137
  summary: Fluentd plugin to write data to Google Cloud Storage
124
138
  test_files:
125
139
  - test/helper.rb
126
140
  - test/plugin/test_out_google_cloud_storage.rb
141
+ has_rdoc: