fluent-plugin-gcloud-pubsub-custom-compress-batches 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +46 -0
- data/.rubocop_todo.yml +98 -0
- data/.travis.yml +26 -0
- data/CHANGELOG.md +143 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +250 -0
- data/Rakefile +14 -0
- data/fluent-plugin-gcloud-pubsub-custom.gemspec +32 -0
- data/lib/fluent/plugin/gcloud_pubsub/client.rb +173 -0
- data/lib/fluent/plugin/gcloud_pubsub/metrics.rb +24 -0
- data/lib/fluent/plugin/in_gcloud_pubsub.rb +303 -0
- data/lib/fluent/plugin/out_gcloud_pubsub.rb +167 -0
- data/test/plugin/test_in_gcloud_pubsub.rb +455 -0
- data/test/plugin/test_out_gcloud_pubsub.rb +308 -0
- data/test/test_helper.rb +33 -0
- metadata +208 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1b9c7b3dc34f8091993d291f47ab10b9cd20aec0a903bab3d1a3b749871d16b7
|
4
|
+
data.tar.gz: e4e208aa00f236e3c579a281848ed937e482b6240a357defd926affb85ab822c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b87a13aa2d02eaae3aa1d27dcaeba521a477c0ce3bb1b2890b4d27b678eeb51647df25c6f3bf536681ad6ba331404c06f1c560ae1427990806215ed40adc72ad
|
7
|
+
data.tar.gz: af0a44c4bcaf565c23fed7970d79e3f25428d34e0764a4481a62f03e58c67c9f462d8e1bb50fe3bc5ab64e8e610db4305e4f7927dc15d945166d6a5c6cbc3c47
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
inherit_from: .rubocop_todo.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
# Matches the minimum version in .travis.yml
|
6
|
+
TargetRubyVersion: 2.4
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
EnforcedStyle: "double_quotes"
|
10
|
+
|
11
|
+
# New cops: https://docs.rubocop.org/en/latest/versioning/
|
12
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Layout/SpaceAroundMethodCallOperator:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Lint/RaiseException:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
Lint/StructNewOverride:
|
22
|
+
Enabled: true
|
23
|
+
|
24
|
+
Style/ExponentialNotation:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Style/HashEachMethods:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Style/HashTransformKeys:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Style/HashTransformValues:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Style/SlicingWithRange:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Style/TrailingCommaInHashLiteral:
|
40
|
+
EnforcedStyleForMultiline: comma
|
41
|
+
|
42
|
+
Style/TrailingCommaInArrayLiteral:
|
43
|
+
EnforcedStyleForMultiline: comma
|
44
|
+
|
45
|
+
Style/TrailingCommaInArguments:
|
46
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
---
|
2
|
+
# This configuration was generated by
|
3
|
+
# `rubocop --auto-gen-config`
|
4
|
+
# on 2020-05-12 17:34:19 +0100 using RuboCop version 0.83.0.
|
5
|
+
# The point is for the user to remove these configuration records
|
6
|
+
# one by one as the offenses are removed from the code base.
|
7
|
+
# Note that changes in the inspected code, or installation of new
|
8
|
+
# versions of RuboCop, may require this file to be generated again.
|
9
|
+
|
10
|
+
# Offense count: 3
|
11
|
+
# Configuration parameters: IgnoredMethods.
|
12
|
+
Metrics/AbcSize:
|
13
|
+
Max: 50
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/ClassLength:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/MethodLength:
|
22
|
+
Max: 30
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# Configuration parameters: IgnoredPatterns.
|
26
|
+
# SupportedStyles: snake_case, camelCase
|
27
|
+
Naming/MethodName:
|
28
|
+
EnforcedStyle: snake_case
|
29
|
+
|
30
|
+
# Offense count: 3
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
33
|
+
# SupportedStyles: nested, compact
|
34
|
+
Style/ClassAndModuleChildren:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/fluent/plugin/in_gcloud_pubsub.rb'
|
37
|
+
- 'lib/fluent/plugin/out_gcloud_pubsub.rb'
|
38
|
+
- 'test/test_helper.rb'
|
39
|
+
|
40
|
+
# Offense count: 6
|
41
|
+
Style/Documentation:
|
42
|
+
Exclude:
|
43
|
+
- 'spec/**/*'
|
44
|
+
- 'test/**/*'
|
45
|
+
- 'lib/fluent/plugin/gcloud_pubsub/client.rb'
|
46
|
+
- 'lib/fluent/plugin/in_gcloud_pubsub.rb'
|
47
|
+
- 'lib/fluent/plugin/out_gcloud_pubsub.rb'
|
48
|
+
|
49
|
+
# Offense count: 1
|
50
|
+
# Configuration parameters: AllowedVariables.
|
51
|
+
Style/GlobalVars:
|
52
|
+
Exclude:
|
53
|
+
- 'test/test_helper.rb'
|
54
|
+
|
55
|
+
# Offense count: 1
|
56
|
+
# Configuration parameters: MinBodyLength.
|
57
|
+
Style/GuardClause:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/fluent/plugin/gcloud_pubsub/client.rb'
|
60
|
+
|
61
|
+
# Offense count: 2
|
62
|
+
# Cop supports --auto-correct.
|
63
|
+
Style/IfUnlessModifier:
|
64
|
+
Exclude:
|
65
|
+
- 'lib/fluent/plugin/gcloud_pubsub/client.rb'
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
Style/MethodMissingSuper:
|
69
|
+
Exclude:
|
70
|
+
- 'test/test_helper.rb'
|
71
|
+
|
72
|
+
# Offense count: 1
|
73
|
+
Style/MissingRespondToMissing:
|
74
|
+
Exclude:
|
75
|
+
- 'test/test_helper.rb'
|
76
|
+
|
77
|
+
# Offense count: 260
|
78
|
+
# Cop supports --auto-correct.
|
79
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
80
|
+
# SupportedStyles: single_quotes, double_quotes
|
81
|
+
Style/StringLiterals:
|
82
|
+
Exclude:
|
83
|
+
- 'Gemfile'
|
84
|
+
- 'Rakefile'
|
85
|
+
- 'fluent-plugin-gcloud-pubsub-custom.gemspec'
|
86
|
+
- 'lib/fluent/plugin/gcloud_pubsub/client.rb'
|
87
|
+
- 'lib/fluent/plugin/in_gcloud_pubsub.rb'
|
88
|
+
- 'lib/fluent/plugin/out_gcloud_pubsub.rb'
|
89
|
+
- 'test/plugin/test_in_gcloud_pubsub.rb'
|
90
|
+
- 'test/plugin/test_out_gcloud_pubsub.rb'
|
91
|
+
- 'test/test_helper.rb'
|
92
|
+
|
93
|
+
# Offense count: 36
|
94
|
+
# Cop supports --auto-correct.
|
95
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
96
|
+
# URISchemes: http, https
|
97
|
+
Layout/LineLength:
|
98
|
+
Max: 120
|
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.5
|
5
|
+
- 2.6
|
6
|
+
- 2.7
|
7
|
+
- ruby-head
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- Gemfile
|
11
|
+
|
12
|
+
branches:
|
13
|
+
only:
|
14
|
+
- master
|
15
|
+
- gocardless
|
16
|
+
|
17
|
+
before_install: gem update bundler
|
18
|
+
script:
|
19
|
+
- bundle exec rake test
|
20
|
+
- bundle exec rubocop
|
21
|
+
|
22
|
+
sudo: false
|
23
|
+
|
24
|
+
matrix:
|
25
|
+
allow_failures:
|
26
|
+
- rvm: ruby-head
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
## ChangeLog
|
2
|
+
|
3
|
+
### Release 1.3.3 - 2021/01/05
|
4
|
+
|
5
|
+
- Add support for payload compression with `compress_batches`
|
6
|
+
|
7
|
+
### Release 1.3.2 - 2019/08/16
|
8
|
+
|
9
|
+
- Input plugin
|
10
|
+
- Make `topic` parameter optional
|
11
|
+
|
12
|
+
### Release 1.3.1 - 2018/06/08
|
13
|
+
|
14
|
+
- Input plugin
|
15
|
+
- Dumps raw string to logs for parsing errors
|
16
|
+
|
17
|
+
### Release 1.3.0 - 2018/05/18
|
18
|
+
|
19
|
+
- Make attributes available
|
20
|
+
|
21
|
+
### Release 1.2.0 - 2018/04/24
|
22
|
+
|
23
|
+
- Output plugin
|
24
|
+
- Support inject section
|
25
|
+
|
26
|
+
### Release 1.1.0 - 2018/03/30
|
27
|
+
|
28
|
+
- Output plugin
|
29
|
+
- The placeholder is now available in topic param
|
30
|
+
|
31
|
+
### Release 1.0.3 - 2018/03/29
|
32
|
+
|
33
|
+
- Bump up google-cloud-pubsub to v0.30.x
|
34
|
+
- Make config file Fluentd v1 compatible
|
35
|
+
|
36
|
+
### Release 1.0.2 - 2017/09/11
|
37
|
+
|
38
|
+
- Bump up google-cloud-pubsub to v0.27.x
|
39
|
+
|
40
|
+
### Release 1.0.1 - 2017/09/05
|
41
|
+
|
42
|
+
- Bump up google-cloud-pubsub to v0.26.x
|
43
|
+
|
44
|
+
### Release 1.0.0 - 2017/06/23
|
45
|
+
|
46
|
+
- Fluentd v0.14 ready
|
47
|
+
- Fluentd v0.12 is not supported in the later version
|
48
|
+
|
49
|
+
### Release 0.4.6 - 2017/05/14
|
50
|
+
|
51
|
+
- Output plugin
|
52
|
+
- Make messages exceeding configured size not be published because Pub/Sub clients cannot receive it
|
53
|
+
|
54
|
+
### Release 0.4.5 - 2017/04/02
|
55
|
+
|
56
|
+
- Bump up google-cloud-pubsub to v0.24.x
|
57
|
+
|
58
|
+
### Release 0.4.4 - 2017/03/07
|
59
|
+
|
60
|
+
- Bump up google-cloud-pubsub to v0.23.x
|
61
|
+
|
62
|
+
### Release 0.4.3 - 2017/02/16
|
63
|
+
|
64
|
+
- Input plugin
|
65
|
+
- Add "status" method to the http rpc api
|
66
|
+
|
67
|
+
### Release 0.4.2 - 2017/02/03
|
68
|
+
|
69
|
+
- Make retry to get topic/subscription when Pub/Sub API returns 50x code
|
70
|
+
|
71
|
+
### Release 0.4.1 - 2017/02/02
|
72
|
+
|
73
|
+
- Bump up google-cloud-pubsub to v0.22.x
|
74
|
+
- Input plugin
|
75
|
+
- Rescue 50x errors on acknowledge api
|
76
|
+
|
77
|
+
### Release 0.4.0 - 2017/01/21
|
78
|
+
|
79
|
+
- Input plugin
|
80
|
+
- Add feature to use record key as tag
|
81
|
+
|
82
|
+
### Release 0.3.4 - 2017/01/03
|
83
|
+
|
84
|
+
- Output plugin
|
85
|
+
- Rescue 50x errors
|
86
|
+
- Input plugin
|
87
|
+
- Guard emit to be called with multi-threading
|
88
|
+
- Rescue 50x errors
|
89
|
+
- Enabled to select whether to raise an exception if message processing failed
|
90
|
+
|
91
|
+
### Release 0.3.3 - 2016/12/03
|
92
|
+
|
93
|
+
- Input plugin
|
94
|
+
- Fix undefined variable error
|
95
|
+
|
96
|
+
### Release 0.3.2 - 2016/11/13
|
97
|
+
|
98
|
+
- Add plugin param desc
|
99
|
+
- Input plugin
|
100
|
+
- Improve handling to acknowledge messages
|
101
|
+
|
102
|
+
### Release 0.3.1 - 2016/11/03
|
103
|
+
|
104
|
+
- Output plugin
|
105
|
+
- Improve error handling
|
106
|
+
|
107
|
+
### Release 0.3.0 - 2016/10/30
|
108
|
+
|
109
|
+
- Bump up google-cloud-pubsub to v0.21
|
110
|
+
- Input plugin
|
111
|
+
- Add multithreaded pulling feature
|
112
|
+
|
113
|
+
### Release 0.2.0 - 2016/10/15
|
114
|
+
|
115
|
+
- Input plugin
|
116
|
+
- Add HTTP RPC feature
|
117
|
+
|
118
|
+
### Release 0.1.4 - 2016/09/19
|
119
|
+
|
120
|
+
- Input plugin
|
121
|
+
- `pull_interval` can be specified float value
|
122
|
+
- `topic` must be specified
|
123
|
+
|
124
|
+
### Release 0.1.3 - 2016/09/17
|
125
|
+
|
126
|
+
- Input plugin
|
127
|
+
- Fix error handling and add debug logging
|
128
|
+
|
129
|
+
### Release 0.1.2 - 2016/09/11
|
130
|
+
|
131
|
+
- Output plugin
|
132
|
+
- Change default max message size and add debug message
|
133
|
+
|
134
|
+
### Release 0.1.1 - 2016/08/27
|
135
|
+
|
136
|
+
- Bump up google-cloud-pubsub (gcloud-ruby) to 0.20
|
137
|
+
|
138
|
+
### Release 0.1.0 - 2016/08/22
|
139
|
+
|
140
|
+
- Use formatter / parser plugin and add format configuration
|
141
|
+
- Bump up gcloud-ruby to 0.12
|
142
|
+
- Remove dependency on lightening buffer
|
143
|
+
- Fix error caused by Pub/Sub quotas
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 mdoi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
# fluent-plugin-gcloud-pubsub-custom
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/mia-0032/fluent-plugin-gcloud-pubsub-custom.svg?branch=master)](https://travis-ci.org/mia-0032/fluent-plugin-gcloud-pubsub-custom)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-gcloud-pubsub-custom.svg)](http://badge.fury.io/rb/fluent-plugin-gcloud-pubsub-custom)
|
5
|
+
|
6
|
+
This plugin is forked from https://github.com/mdoi/fluent-plugin-gcloud-pubsub
|
7
|
+
|
8
|
+
## Overview
|
9
|
+
|
10
|
+
[Google Cloud Pub/Sub](https://cloud.google.com/pubsub/) Input/Output(BufferedOutput) plugin for [Fluentd](http://www.fluentd.org/) with [google-cloud](https://googlecloudplatform.github.io/google-cloud-ruby/) gem
|
11
|
+
|
12
|
+
- Publish messages to Google Cloud Pub/Sub
|
13
|
+
- Pull messages from Google Cloud Pub/Sub
|
14
|
+
|
15
|
+
## Preparation
|
16
|
+
|
17
|
+
- Create a project on Google Developer Console
|
18
|
+
- Add a topic of Cloud Pub/Sub to the project
|
19
|
+
- Add a pull style subscription to the topic
|
20
|
+
- Download your credential (json) or [set scope on GCE instance](https://cloud.google.com/compute/docs/api/how-tos/authorization)
|
21
|
+
|
22
|
+
When using output plugin, you need to grant Pub/Sub Publisher and Pub/Sub Viewer role to IAM.
|
23
|
+
|
24
|
+
Also, when using input plugin, you need to grant Pub/Sub Subscriber and Pub/Sub Viewer role to IAM.
|
25
|
+
|
26
|
+
## Requirements
|
27
|
+
|
28
|
+
| fluent-plugin-gcloud-pubsub-custom | fluentd | ruby |
|
29
|
+
|------------------------|---------|------|
|
30
|
+
| >= 1.0.0 | >= v0.14.0 | >= 2.1 |
|
31
|
+
| < 1.0.0 | >= v0.12.0 | >= 1.9 |
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
Install by gem:
|
36
|
+
|
37
|
+
```shell
|
38
|
+
$ gem install fluent-plugin-gcloud-pubsub-custom
|
39
|
+
```
|
40
|
+
|
41
|
+
**Caution**
|
42
|
+
|
43
|
+
This plugin doesn't work in [td-agent](http://docs.fluentd.org/articles/install-by-rpm).
|
44
|
+
|
45
|
+
Please use in [Fluentd installed by gem](http://docs.fluentd.org/articles/install-by-gem).
|
46
|
+
|
47
|
+
## Configuration
|
48
|
+
|
49
|
+
### Publish messages
|
50
|
+
|
51
|
+
Use `gcloud_pubsub` output plugin.
|
52
|
+
|
53
|
+
```
|
54
|
+
<match example.publish>
|
55
|
+
@type gcloud_pubsub
|
56
|
+
project <YOUR PROJECT>
|
57
|
+
key <YOUR KEY>
|
58
|
+
topic <YOUR TOPIC>
|
59
|
+
autocreate_topic false
|
60
|
+
max_messages 1000
|
61
|
+
max_total_size 9800000
|
62
|
+
max_message_size 4000000
|
63
|
+
compress_batches false
|
64
|
+
<buffer>
|
65
|
+
@type memory
|
66
|
+
flush_interval 1s
|
67
|
+
</buffer>
|
68
|
+
<format>
|
69
|
+
@type json
|
70
|
+
</format>
|
71
|
+
</match>
|
72
|
+
```
|
73
|
+
|
74
|
+
- `project` (optional)
|
75
|
+
- Set your GCP project.
|
76
|
+
- Running fluentd on GCP, you don't have to specify.
|
77
|
+
- You can also use environment variable such as `GCLOUD_PROJECT`.
|
78
|
+
- `key` (optional)
|
79
|
+
- Set your credential file path.
|
80
|
+
- Running fluentd on GCP, you can use scope instead of specifying this.
|
81
|
+
- You can also use environment variable such as `GCLOUD_KEYFILE`.
|
82
|
+
- `topic` (required)
|
83
|
+
- Set topic name to publish.
|
84
|
+
- You can use placeholder in this param. See: https://docs.fluentd.org/v1.0/articles/buffer-section
|
85
|
+
- `autocreate_topic` (optional, default: `false`)
|
86
|
+
- If set to `true`, specified topic will be created when it doesn't exist.
|
87
|
+
- `max_messages` (optional, default: `1000`)
|
88
|
+
- Publishing messages count per request to Cloud Pub/Sub.
|
89
|
+
- See https://cloud.google.com/pubsub/quotas#other_limits
|
90
|
+
- `max_total_size` (optional, default: `9800000` = `9.8MB`)
|
91
|
+
- Publishing messages bytesize per request to Cloud Pub/Sub. This parameter affects only message size. You should specify a little smaller value than quota.
|
92
|
+
- See https://cloud.google.com/pubsub/quotas#other_limits
|
93
|
+
- `max_message_size` (optional, default: `4000000` = `4MB`)
|
94
|
+
- Messages exceeding `max_message_size` are not published because Pub/Sub clients cannot receive it.
|
95
|
+
- `attribute_keys` (optional, default: `[]`)
|
96
|
+
- Extract these fields from the record and send them as attributes on the Pub/Sub message. Cannot be set if compress_batches is enabled.
|
97
|
+
- `metric_prefix` (optional, default: `fluentd_output_gcloud_pubsub`)
|
98
|
+
- The prefix for Prometheus metric names
|
99
|
+
- `compress_batches` (optional, default: `false`)
|
100
|
+
- If set to `true`, messages will be batched and compressed before publication. See [message compression](#message-compression) for details.
|
101
|
+
|
102
|
+
### Pull messages
|
103
|
+
|
104
|
+
Use `gcloud_pubsub` input plugin.
|
105
|
+
|
106
|
+
```
|
107
|
+
<source>
|
108
|
+
@type gcloud_pubsub
|
109
|
+
tag example.pull
|
110
|
+
project <YOUR PROJECT>
|
111
|
+
key <YOUR KEY>
|
112
|
+
topic <YOUR TOPIC>
|
113
|
+
subscription <YOUR SUBSCRIPTION>
|
114
|
+
max_messages 1000
|
115
|
+
return_immediately true
|
116
|
+
pull_interval 0.5
|
117
|
+
pull_threads 2
|
118
|
+
parse_error_action exception
|
119
|
+
enable_rpc true
|
120
|
+
rpc_bind 0.0.0.0
|
121
|
+
rpc_port 24680
|
122
|
+
<parse>
|
123
|
+
@type json
|
124
|
+
</parse>
|
125
|
+
</source>
|
126
|
+
```
|
127
|
+
|
128
|
+
- `tag` (required)
|
129
|
+
- Set tag of messages.
|
130
|
+
- If `tag_key` is specified, `tag` is used as tag when record don't have specified key.
|
131
|
+
- `tag_key` (optional)
|
132
|
+
- Set key to be used as tag.
|
133
|
+
- `project` (optional)
|
134
|
+
- Set your GCP project
|
135
|
+
- Running fluentd on GCP, you don't have to specify.
|
136
|
+
- You can also use environment variable such as `GCLOUD_PROJECT`.
|
137
|
+
- `key` (optional)
|
138
|
+
- Set your credential file path.
|
139
|
+
- Running fluentd on GCP, you can use scope instead of specifying this.
|
140
|
+
- You can also use environment variable such as `GCLOUD_KEYFILE`.
|
141
|
+
- `topic` (optional)
|
142
|
+
- Set topic name that the subscription belongs to.
|
143
|
+
- `subscription` (required)
|
144
|
+
- Set subscription name to pull.
|
145
|
+
- `max_messages` (optional, default: `100`)
|
146
|
+
- See maxMessages on https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull
|
147
|
+
- `return_immediately` (optional, default: `true`)
|
148
|
+
- See returnImmediately on https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull
|
149
|
+
- If `return_immediately` is `true` or pulling message is stopped by HTTP RPC, this plugin wait `pull_interval` each pull.
|
150
|
+
- `pull_interval` (optional, default: `5.0`)
|
151
|
+
- Pulling messages by intervals of specified seconds.
|
152
|
+
- `pull_threads` (optional, default: `1`)
|
153
|
+
- Set number of threads to pull messages.
|
154
|
+
- `attribute_keys` (optional, default: `[]`)
|
155
|
+
- Acquire these fields from attributes on the Pub/Sub message and merge them into the record.
|
156
|
+
- `parse_error_action` (optional, default: `exception`)
|
157
|
+
- Set error type when parsing messages fails.
|
158
|
+
- `exception`: Raise exception. Messages are not acknowledged.
|
159
|
+
- `warning`: Only logging as warning.
|
160
|
+
- `metric_prefix` (optional, default: `fluentd_input_gcloud_pubsub`)
|
161
|
+
- The prefix for Prometheus metric names
|
162
|
+
- `enable_rpc` (optional, default: `false`)
|
163
|
+
- If `true` is specified, HTTP RPC to stop or start pulling message is enabled.
|
164
|
+
- `rpc_bind` (optional, default: `0.0.0.0`)
|
165
|
+
- Bind IP address for HTTP RPC.
|
166
|
+
- `rpc_port` (optional, default: `24680`)
|
167
|
+
- Port for HTTP RPC.
|
168
|
+
|
169
|
+
## Message compression
|
170
|
+
|
171
|
+
The `compress_batches` option can be used to enable the compression of messages
|
172
|
+
_before_ publication to Pub/Sub.
|
173
|
+
|
174
|
+
This works by collecting the buffered messages, taking up to `max_total_size` or
|
175
|
+
`max_message_size` input records, then compressing them with Zlib (i.e.
|
176
|
+
gzip/Deflate) before publishing them as a single message to the Pub/Sub topic.
|
177
|
+
|
178
|
+
When transporting large volumes of records via Pub/Sub, e.g. multiple Terabytes
|
179
|
+
per month, this can lead to significant cost savings, as typically the CPU time
|
180
|
+
required to compress the messages will be minimal in comparison to the Pub/Sub
|
181
|
+
costs.
|
182
|
+
|
183
|
+
The compression ratio achievable will vary largely depending on the homogeneity
|
184
|
+
of the input records, but typically will be 50% at the very minimum and often
|
185
|
+
around 80-90%.
|
186
|
+
|
187
|
+
In order to achieve good compression, consider the following:
|
188
|
+
- Ensure that the buffer is being filled with a reasonable batch of messages: do
|
189
|
+
not use `flush_mode immediate`, and keep the `flush_interval` value
|
190
|
+
sufficiently high. Use the Prometheus metrics to determine how many records
|
191
|
+
are being published per message.
|
192
|
+
- Keep the `max_messages` and `max_message_size` values high (the defaults are
|
193
|
+
optimal).
|
194
|
+
- If there are many different sources of messages being mixed and routed to a
|
195
|
+
single `gcloud_pubsub` output, use multiple outputs (which will each have
|
196
|
+
their own buffer) through tagging or [labelling][fluentd-labels].
|
197
|
+
|
198
|
+
[fluentd-labels]: https://docs.fluentd.org/quickstart/life-of-a-fluentd-event#labels
|
199
|
+
|
200
|
+
The receiving end must be able to decode these compressed batches of messages,
|
201
|
+
which it can determine via an attribute set on the Pub/Sub message. The
|
202
|
+
`gcloud_pubsub` input plugin will do this transparently, decompressing any
|
203
|
+
messages which contain a batch of records and normally processing any messages
|
204
|
+
which represent just a single record.
|
205
|
+
Therefore, as long as all of the receivers are updated with support for
|
206
|
+
compressed batches first, it's then possible to gradually roll out this feature.
|
207
|
+
|
208
|
+
## Prometheus metrics
|
209
|
+
|
210
|
+
The input and output plugins expose several metrics in order to monitor
|
211
|
+
performance:
|
212
|
+
|
213
|
+
- `fluentd_output_gcloud_pubsub_compression_enabled`
|
214
|
+
- Gauge: Whether compression/batching is enabled
|
215
|
+
- `fluentd_output_gcloud_pubsub_messages_published_per_batch`
|
216
|
+
- Histogram: Number of records published to Pub/Sub per buffer flush
|
217
|
+
- `fluentd_output_gcloud_pubsub_messages_published_bytes`
|
218
|
+
- Histogram: Total size in bytes of the records published to Pub/Sub,
|
219
|
+
**before** compression.
|
220
|
+
- `fluentd_output_gcloud_pubsub_messages_compression_duration_seconds`
|
221
|
+
- Histogram: Time taken to compress a batch of messages
|
222
|
+
- `fluentd_output_gcloud_pubsub_messages_compressed_size_per_original_size_ratio`
|
223
|
+
- Histogram: Compression ratio achieved on a batch of messages, expressed in
|
224
|
+
terms of space saved.
|
225
|
+
|
226
|
+
- `fluentd_input_gcloud_pubsub_pull_errors_total`
|
227
|
+
- Counter: Errors encountered while pulling or processing messages (split by a
|
228
|
+
`retryable` label)
|
229
|
+
- `fluentd_input_gcloud_pubsub_messages_pulled`
|
230
|
+
- Histogram: Number of Pub/Sub messages pulled by the subscriber on each invocation
|
231
|
+
- `fluentd_input_gcloud_pubsub_messages_pulled_bytes`
|
232
|
+
- Histogram: Total size in bytes of the Pub/Sub messages pulled by the subscriber on each invocation
|
233
|
+
|
234
|
+
## Contributing
|
235
|
+
|
236
|
+
1. Fork it
|
237
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
238
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
239
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
240
|
+
5. Create a new Pull Request
|
241
|
+
|
242
|
+
## TODO
|
243
|
+
|
244
|
+
- Add `tag` attribute in output plugin and use `tag` attribute as tag in input plugin.
|
245
|
+
- Send ack after other output plugin committed (if possible).
|
246
|
+
|
247
|
+
## Authors
|
248
|
+
|
249
|
+
- [@mdoi](https://github.com/mdoi) : First author
|
250
|
+
- [@mia-0032](https://github.com/mia-0032) : This version author
|