logstash-output-google_pubsub 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +9 -0
- data/CONTRIBUTORS +13 -0
- data/Gemfile +10 -0
- data/LICENSE +13 -0
- data/README.md +96 -0
- data/docs/index.asciidoc +231 -0
- data/lib/logstash-output-google_pubsub_jars.rb +41 -0
- data/lib/logstash/outputs/google_pubsub.rb +80 -0
- data/lib/logstash/outputs/pubsub/client.rb +107 -0
- data/lib/logstash/outputs/pubsub/message_future_callback.rb +23 -0
- data/logstash-output-google_pubsub.gemspec +35 -0
- data/spec/outputs/google_pubsub_spec.rb +67 -0
- data/spec/outputs/pubsub/client_spec.rb +106 -0
- data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.1.3/jackson-core-2.1.3.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/api-common/1.6.0/api-common-1.6.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/gax-grpc/1.29.0/gax-grpc-1.29.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/gax/1.29.0/gax-1.29.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/grpc/grpc-google-cloud-pubsub-v1/1.19.1/grpc-google-cloud-pubsub-v1-1.19.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.19.1/proto-google-cloud-pubsub-v1-1.19.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/grpc/proto-google-common-protos/1.12.0/proto-google-common-protos-1.12.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/api/grpc/proto-google-iam-v1/0.12.0/proto-google-iam-v1-0.12.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/auth/google-auth-library-credentials/0.9.1/google-auth-library-credentials-0.9.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/auth/google-auth-library-oauth2-http/0.9.1/google-auth-library-oauth2-http-0.9.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/auto/value/auto-value/1.4/auto-value-1.4.jar +0 -0
- data/vendor/jar-dependencies/com/google/cloud/google-cloud-core-grpc/1.37.1/google-cloud-core-grpc-1.37.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/cloud/google-cloud-core/1.37.1/google-cloud-core-1.37.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/cloud/google-cloud-pubsub/1.37.1/google-cloud-pubsub-1.37.1.jar +0 -0
- data/vendor/jar-dependencies/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar +0 -0
- data/vendor/jar-dependencies/com/google/code/gson/gson/2.7/gson-2.7.jar +0 -0
- data/vendor/jar-dependencies/com/google/errorprone/error_prone_annotations/2.2.0/error_prone_annotations-2.2.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/guava/guava/20.0/guava-20.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/http-client/google-http-client-jackson2/1.19.0/google-http-client-jackson2-1.19.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/http-client/google-http-client/1.23.0/google-http-client-1.23.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/protobuf/protobuf-java-util/3.6.0/protobuf-java-util-3.6.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/protobuf/protobuf-java/3.6.0/protobuf-java-3.6.0.jar +0 -0
- data/vendor/jar-dependencies/com/google/protobuf/protobuf-lite/3.0.1/protobuf-lite-3.0.1.jar +0 -0
- data/vendor/jar-dependencies/commons-codec/commons-codec/1.3/commons-codec-1.3.jar +0 -0
- data/vendor/jar-dependencies/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-auth/1.13.1/grpc-auth-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-context/1.13.1/grpc-context-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-core/1.13.1/grpc-core-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-netty-shaded/1.13.1/grpc-netty-shaded-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-protobuf-lite/1.13.1/grpc-protobuf-lite-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-protobuf/1.13.1/grpc-protobuf-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/grpc/grpc-stub/1.13.1/grpc-stub-1.13.1.jar +0 -0
- data/vendor/jar-dependencies/io/opencensus/opencensus-api/0.12.3/opencensus-api-0.12.3.jar +0 -0
- data/vendor/jar-dependencies/io/opencensus/opencensus-contrib-grpc-metrics/0.12.3/opencensus-contrib-grpc-metrics-0.12.3.jar +0 -0
- data/vendor/jar-dependencies/joda-time/joda-time/2.9.2/joda-time-2.9.2.jar +0 -0
- data/vendor/jar-dependencies/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar +0 -0
- data/vendor/jar-dependencies/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar +0 -0
- data/vendor/jar-dependencies/org/threeten/threetenbp/1.3.3/threetenbp-1.3.3.jar +0 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b690a5feb720aadd58e937e7f5dbe8637008b019cceb99422f395c23a2d9e878
|
4
|
+
data.tar.gz: dfd102d278a4519dd0ea69800dd90bd9aa8fb5a6b8bb3410f464d509376b0465
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6e973f797df417d33e95cfd3b42c746cfa252de38f777aaddb19096a1c63ffa47f9d84b47b10f20c441340f61afe414f39a927afdf312ae34c76f9fc2e78ad1
|
7
|
+
data.tar.gz: 4d87a5b5ac2ad897aaff09f3b1f9e9a61aeb9dcc50392853184e546d1a61f0ca794fdbba933dd8e0cbccbf2a262c278c11c1a7b84fcba2377ba9ac134e3b6a1c
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
4
|
+
|
5
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
6
|
+
|
7
|
+
It is more important to the community that you are able to contribute.
|
8
|
+
|
9
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
|
6
|
+
* Google LLC
|
7
|
+
* Eric Johnson - erjohnso@google.com
|
8
|
+
* Joseph Lewis III - jlewisiii@google.com
|
9
|
+
|
10
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
11
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
12
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
13
|
+
open source awesome.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
logstash_path = ENV['LOGSTASH_PATH'] || '../../logstash'
|
5
|
+
use_logstash_source = ENV['LOGSTASH_SOURCE'] && ENV['LOGSTASH_SOURCE'].to_s == '1'
|
6
|
+
|
7
|
+
if Dir.exist?(logstash_path) && use_logstash_source
|
8
|
+
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
9
|
+
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
10
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Logstash Output Google Pubsub
|
2
|
+
|
3
|
+
A Logstash plugin to upload log events to https://cloud.google.com/pubsub/[Google Cloud Pubsub].
|
4
|
+
Events are batched and uploaded in the background for the sake of efficiency.
|
5
|
+
Message payloads are serialized JSON representations of the events.
|
6
|
+
|
7
|
+
Example use-cases:
|
8
|
+
|
9
|
+
* Stream events to Dataproc via Pub/Sub for real-time analysis.
|
10
|
+
* Forward events from an on-prem datacenter to the Logstash in the cloud.
|
11
|
+
* Use Pub/Sub as an scalable buffer to even out event flow between processing steps.
|
12
|
+
|
13
|
+
Note: While this project is partially maintained by Google, this is not an official Google product.
|
14
|
+
|
15
|
+
## Documentation
|
16
|
+
|
17
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
18
|
+
|
19
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
20
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
21
|
+
|
22
|
+
## Need Help?
|
23
|
+
|
24
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
25
|
+
|
26
|
+
## Developing
|
27
|
+
|
28
|
+
### 1. Plugin Developement and Testing
|
29
|
+
|
30
|
+
#### Code
|
31
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
32
|
+
|
33
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
34
|
+
|
35
|
+
- Install dependencies
|
36
|
+
```sh
|
37
|
+
bundle install
|
38
|
+
bundle exec rake vendor
|
39
|
+
```
|
40
|
+
|
41
|
+
#### Test
|
42
|
+
|
43
|
+
- Update your dependencies
|
44
|
+
|
45
|
+
```sh
|
46
|
+
bundle install
|
47
|
+
bundle exec rake vendor
|
48
|
+
```
|
49
|
+
|
50
|
+
- Run tests
|
51
|
+
|
52
|
+
```sh
|
53
|
+
bundle exec rspec
|
54
|
+
```
|
55
|
+
|
56
|
+
### 2. Running your unpublished Plugin in Logstash
|
57
|
+
|
58
|
+
#### 2.1 Run in a local Logstash clone
|
59
|
+
|
60
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
61
|
+
```ruby
|
62
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
63
|
+
```
|
64
|
+
- Install plugin
|
65
|
+
```sh
|
66
|
+
bin/logstash-plugin install --no-verify
|
67
|
+
```
|
68
|
+
- Run Logstash with your plugin
|
69
|
+
```sh
|
70
|
+
bin/logstash -e 'filter {awesome {}}'
|
71
|
+
```
|
72
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
73
|
+
|
74
|
+
#### 2.2 Run in an installed Logstash
|
75
|
+
|
76
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
77
|
+
|
78
|
+
- Build your plugin gem
|
79
|
+
```sh
|
80
|
+
gem build logstash-filter-awesome.gemspec
|
81
|
+
```
|
82
|
+
- Install the plugin from the Logstash home
|
83
|
+
```sh
|
84
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
85
|
+
```
|
86
|
+
- Start Logstash and proceed to test the plugin
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
91
|
+
|
92
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
93
|
+
|
94
|
+
It is more important to the community that you are able to contribute.
|
95
|
+
|
96
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/docs/index.asciidoc
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
:plugin: google_pubsub
|
2
|
+
:type: output
|
3
|
+
:default_codec: json
|
4
|
+
|
5
|
+
///////////////////////////////////////////
|
6
|
+
START - GENERATED VARIABLES, DO NOT EDIT!
|
7
|
+
///////////////////////////////////////////
|
8
|
+
:version: %VERSION%
|
9
|
+
:release_date: %RELEASE_DATE%
|
10
|
+
:changelog_url: %CHANGELOG_URL%
|
11
|
+
:include_path: ../../../../logstash/docs/include
|
12
|
+
///////////////////////////////////////////
|
13
|
+
END - GENERATED VARIABLES, DO NOT EDIT!
|
14
|
+
///////////////////////////////////////////
|
15
|
+
|
16
|
+
[id="plugins-{type}s-{plugin}"]
|
17
|
+
|
18
|
+
=== Google Cloud Pub/Sub Output Plugin
|
19
|
+
|
20
|
+
include::{include_path}/plugin_header.asciidoc[]
|
21
|
+
|
22
|
+
==== Description
|
23
|
+
|
24
|
+
A Logstash plugin to upload log events to https://cloud.google.com/pubsub/[Google Cloud Pubsub].
|
25
|
+
Events are batched and uploaded in the background for the sake of efficiency.
|
26
|
+
Message payloads are serialized JSON representations of the events.
|
27
|
+
|
28
|
+
Example use-cases:
|
29
|
+
|
30
|
+
* Stream events to Dataproc via Pub/Sub for real-time analysis.
|
31
|
+
* Forward events from an on-prem datacenter to the Logstash in the cloud.
|
32
|
+
* Use Pub/Sub as an scalable buffer to even out event flow between processing steps.
|
33
|
+
|
34
|
+
Note: While this project is partially maintained by Google, this is not an official Google product.
|
35
|
+
|
36
|
+
==== Environment Configuration
|
37
|
+
|
38
|
+
To use this plugin, you must create a
|
39
|
+
https://developers.google.com/storage/docs/authentication#service_accounts[service account]
|
40
|
+
and grant it the publish permission on a topic.
|
41
|
+
You MAY also use the https://cloud.google.com/docs/authentication/production[Application Default Credentials]
|
42
|
+
assigned to a compute instance.
|
43
|
+
|
44
|
+
The Pub/Sub topic __must__ exist before you run the plugin.
|
45
|
+
|
46
|
+
|
47
|
+
==== Example Configurations
|
48
|
+
|
49
|
+
===== Basic
|
50
|
+
|
51
|
+
A basic configuration which only includes a project, topic, and JSON key file:
|
52
|
+
|
53
|
+
[source,ruby]
|
54
|
+
------------------------------------------------------------------------------
|
55
|
+
output {
|
56
|
+
google_pubsub {
|
57
|
+
# Required attributes
|
58
|
+
project_id => "my_project"
|
59
|
+
topic => "my_topic"
|
60
|
+
|
61
|
+
# Optional if you're using app default credentials
|
62
|
+
json_key_file => "service_account_key.json"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
------------------------------------------------------------------------------
|
66
|
+
|
67
|
+
|
68
|
+
===== High Volume
|
69
|
+
|
70
|
+
If you find that uploads are going too slowly, you can increase the message batching:
|
71
|
+
|
72
|
+
[source,ruby]
|
73
|
+
------------------------------------------------------------------------------
|
74
|
+
output {
|
75
|
+
google_pubsub {
|
76
|
+
project_id => "my_project"
|
77
|
+
topic => "my_topic"
|
78
|
+
json_key_file => "service_account_key.json"
|
79
|
+
|
80
|
+
# Options for configuring the upload
|
81
|
+
message_count_threshold => 10000
|
82
|
+
delay_threshold_secs => 10
|
83
|
+
request_byte_threshold => 5MB
|
84
|
+
}
|
85
|
+
}
|
86
|
+
------------------------------------------------------------------------------
|
87
|
+
|
88
|
+
|
89
|
+
===== Attributes
|
90
|
+
|
91
|
+
You can attach additional attributes to each request.
|
92
|
+
For example, you could attach a datacenter label to a log message to help with debugging:
|
93
|
+
|
94
|
+
[source,ruby]
|
95
|
+
------------------------------------------------------------------------------
|
96
|
+
output {
|
97
|
+
google_pubsub {
|
98
|
+
project_id => "my_project"
|
99
|
+
topic => "my_topic"
|
100
|
+
json_key_file => "service_account_key.json"
|
101
|
+
|
102
|
+
|
103
|
+
attributes => {"origin" => "pacific-datacenter"}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
------------------------------------------------------------------------------
|
107
|
+
|
108
|
+
|
109
|
+
===== Different Codecs
|
110
|
+
|
111
|
+
You can use codecs with this plugin to change the body of the events:
|
112
|
+
|
113
|
+
[source,ruby]
|
114
|
+
------------------------------------------------------------------------------
|
115
|
+
output {
|
116
|
+
google_pubsub {
|
117
|
+
project_id => "my_project"
|
118
|
+
topic => "my_topic"
|
119
|
+
json_key_file => "service_account_key.json"
|
120
|
+
|
121
|
+
|
122
|
+
codec => plain {format => "%{[time]}: %{[message]}"}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
------------------------------------------------------------------------------
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
==== Additional Resources
|
130
|
+
|
131
|
+
* https://cloud.google.com/pubsub/[Cloud Pub/Sub Homepage]
|
132
|
+
* https://cloud.google.com/pubsub/pricing-summary/[Cloud Pub/Sub Pricing]
|
133
|
+
* https://cloud.google.com/iam/docs/service-accounts[IAM Service Accounts]
|
134
|
+
* https://cloud.google.com/docs/authentication/production[Application Default Credentials]
|
135
|
+
|
136
|
+
|
137
|
+
[id="plugins-{type}s-{plugin}-options"]
|
138
|
+
==== Google Cloud Pub/Sub Output Configuration Options
|
139
|
+
|
140
|
+
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
|
141
|
+
|
142
|
+
[cols="<,<,<",options="header",]
|
143
|
+
|=======================================================================
|
144
|
+
|Setting |Input type|Required
|
145
|
+
| <<plugins-{type}s-{plugin}-project_id>> |<<string,string>>|Yes
|
146
|
+
| <<plugins-{type}s-{plugin}-topic>> |<<string,string>>|Yes
|
147
|
+
| <<plugins-{type}s-{plugin}-json_key_file>> |<<path,path>>|No
|
148
|
+
| <<plugins-{type}s-{plugin}-delay_threshold_secs>> |<<number,number>>|No
|
149
|
+
| <<plugins-{type}s-{plugin}-message_count_threshold>> |<<number,number>>|No
|
150
|
+
| <<plugins-{type}s-{plugin}-request_byte_threshold>> |<<bytes,bytes>>|No
|
151
|
+
| <<plugins-{type}s-{plugin}-attributes>> |<<hash,hash>>|No
|
152
|
+
|=======================================================================
|
153
|
+
|
154
|
+
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
155
|
+
input plugins.
|
156
|
+
|
157
|
+
[id="plugins-{type}s-{plugin}-project_id"]
|
158
|
+
===== `project_id`
|
159
|
+
|
160
|
+
* Value type is <<string,string>>
|
161
|
+
* There is no default value for this setting.
|
162
|
+
|
163
|
+
Google Cloud Project ID (name, not number).
|
164
|
+
|
165
|
+
[id="plugins-{type}s-{plugin}-topic"]
|
166
|
+
===== `topic`
|
167
|
+
|
168
|
+
* Value type is <<string,string>>
|
169
|
+
* There is no default value for this setting.
|
170
|
+
|
171
|
+
Google Cloud Pub/Sub Topic. You must create the topic manually before running this plugin.
|
172
|
+
|
173
|
+
[id="plugins-{type}s-{plugin}-json_key_file"]
|
174
|
+
===== `json_key_file`
|
175
|
+
|
176
|
+
* Value type is <<path,path>>
|
177
|
+
* There is no default value for this setting.
|
178
|
+
|
179
|
+
The path to the key to authenticate your user to the bucket.
|
180
|
+
This service user _must_ have the `pubsub.topics.publish` permission so it can publish to the topic.
|
181
|
+
|
182
|
+
|
183
|
+
If Logstash is running within Google Compute Engine and no `json_key_file` is defined,
|
184
|
+
the plugin will use GCE's Application Default Credentials.
|
185
|
+
Outside of GCE, you must to specify a Service Account JSON key file.
|
186
|
+
|
187
|
+
|
188
|
+
[id="plugins-{type}s-{plugin}-delay_threshold_secs"]
|
189
|
+
===== `delay_threshold_secs`
|
190
|
+
|
191
|
+
* Value type is <<number,number>>
|
192
|
+
* Default is: `5`
|
193
|
+
|
194
|
+
Send the batch once this delay has passed, from the time the first message is queued.
|
195
|
+
Must be greater than 0.
|
196
|
+
|
197
|
+
|
198
|
+
[id="plugins-{type}s-{plugin}-message_count_threshold"]
|
199
|
+
===== `message_count_threshold`
|
200
|
+
|
201
|
+
* Value type is <<number,number>>
|
202
|
+
* Default is: `100`
|
203
|
+
|
204
|
+
Once this many messages are queued, send all the messages in a single call, even if the delay threshold hasn't elapsed yet.
|
205
|
+
Must be < 1000.
|
206
|
+
A value of 0 will cause messages to instantly be sent but will reduce total throughput due to overhead.
|
207
|
+
|
208
|
+
[id="plugins-{type}s-{plugin}-request_byte_threshold"]
|
209
|
+
===== `request_byte_threshold`
|
210
|
+
|
211
|
+
* Value type is <<bytes,bytes>>
|
212
|
+
* Default is: `1_000_000`
|
213
|
+
|
214
|
+
Once the number of bytes in the batched request reaches this threshold, send all of the messages in
|
215
|
+
a single call, even if neither the delay or message count thresholds have been exceeded yet.
|
216
|
+
This includes full message payload size, including any attributes set.
|
217
|
+
|
218
|
+
|
219
|
+
[id="plugins-{type}s-{plugin}-attributes"]
|
220
|
+
===== `attributes`
|
221
|
+
|
222
|
+
* Value type is <<hash,hash>>
|
223
|
+
* Default is: `{}`
|
224
|
+
|
225
|
+
Attributes to add to the message in key: value formats.
|
226
|
+
Keys and values MUST be strings.
|
227
|
+
|
228
|
+
[id="plugins-{type}s-{plugin}-common-options"]
|
229
|
+
include::{include_path}/{type}.asciidoc[]
|
230
|
+
|
231
|
+
:default_codec!:
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
|
2
|
+
|
3
|
+
require 'jar_dependencies'
|
4
|
+
require_jar('com.google.cloud', 'google-cloud-pubsub', '1.37.1')
|
5
|
+
require_jar('com.fasterxml.jackson.core', 'jackson-core', '2.1.3')
|
6
|
+
require_jar('com.google.api', 'api-common', '1.6.0')
|
7
|
+
require_jar('com.google.api', 'gax', '1.29.0')
|
8
|
+
require_jar('com.google.api', 'gax-grpc', '1.29.0')
|
9
|
+
require_jar('com.google.api.grpc', 'grpc-google-cloud-pubsub-v1', '1.19.1')
|
10
|
+
require_jar('com.google.api.grpc', 'proto-google-cloud-pubsub-v1', '1.19.1')
|
11
|
+
require_jar('com.google.api.grpc', 'proto-google-common-protos', '1.12.0')
|
12
|
+
require_jar('com.google.api.grpc', 'proto-google-iam-v1', '0.12.0')
|
13
|
+
require_jar('com.google.auth', 'google-auth-library-credentials', '0.9.1')
|
14
|
+
require_jar('com.google.auth', 'google-auth-library-oauth2-http', '0.9.1')
|
15
|
+
require_jar('com.google.auto.value', 'auto-value', '1.4')
|
16
|
+
require_jar('com.google.cloud', 'google-cloud-core', '1.37.1')
|
17
|
+
require_jar('com.google.cloud', 'google-cloud-core-grpc', '1.37.1')
|
18
|
+
require_jar('com.google.code.findbugs', 'jsr305', '3.0.2')
|
19
|
+
require_jar('com.google.code.gson', 'gson', '2.7')
|
20
|
+
require_jar('com.google.errorprone', 'error_prone_annotations', '2.2.0')
|
21
|
+
require_jar('com.google.guava', 'guava', '20.0')
|
22
|
+
require_jar('com.google.http-client', 'google-http-client', '1.23.0')
|
23
|
+
require_jar('com.google.http-client', 'google-http-client-jackson2', '1.19.0')
|
24
|
+
require_jar('com.google.protobuf', 'protobuf-java', '3.6.0')
|
25
|
+
require_jar('com.google.protobuf', 'protobuf-java-util', '3.6.0')
|
26
|
+
require_jar('com.google.protobuf', 'protobuf-lite', '3.0.1')
|
27
|
+
require_jar('commons-codec', 'commons-codec', '1.3')
|
28
|
+
require_jar('commons-logging', 'commons-logging', '1.1.1')
|
29
|
+
require_jar('io.grpc', 'grpc-auth', '1.13.1')
|
30
|
+
require_jar('io.grpc', 'grpc-context', '1.13.1')
|
31
|
+
require_jar('io.grpc', 'grpc-core', '1.13.1')
|
32
|
+
require_jar('io.grpc', 'grpc-netty-shaded', '1.13.1')
|
33
|
+
require_jar('io.grpc', 'grpc-protobuf', '1.13.1')
|
34
|
+
require_jar('io.grpc', 'grpc-protobuf-lite', '1.13.1')
|
35
|
+
require_jar('io.grpc', 'grpc-stub', '1.13.1')
|
36
|
+
require_jar('io.opencensus', 'opencensus-api', '0.12.3')
|
37
|
+
require_jar('io.opencensus', 'opencensus-contrib-grpc-metrics', '0.12.3')
|
38
|
+
require_jar('joda-time', 'joda-time', '2.9.2')
|
39
|
+
require_jar('org.apache.httpcomponents', 'httpclient', '4.0.1')
|
40
|
+
require_jar('org.apache.httpcomponents', 'httpcore', '4.0.1')
|
41
|
+
require_jar('org.threeten', 'threetenbp', '1.3.3')
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'logstash/outputs/base'
|
2
|
+
require 'logstash/namespace'
|
3
|
+
require 'logstash/outputs/pubsub/client'
|
4
|
+
|
5
|
+
# A Logstash plugin to upload log events to https://cloud.google.com/pubsub/[Google Cloud Pubsub].
|
6
|
+
class LogStash::Outputs::GooglePubsub < LogStash::Outputs::Base
|
7
|
+
config_name 'google_pubsub'
|
8
|
+
|
9
|
+
concurrency :shared
|
10
|
+
|
11
|
+
# Google Cloud Project ID (name, not number)
|
12
|
+
config :project_id, validate: :string, required: true
|
13
|
+
|
14
|
+
# Google Cloud Pub/Sub Topic, expected to exist before the plugin starts
|
15
|
+
config :topic, validate: :string, required: true
|
16
|
+
|
17
|
+
# A full path to the JSON key file, if empty it's assumed Application Default Credentials
|
18
|
+
# will be used.
|
19
|
+
config :json_key_file, validate: :path, required: false
|
20
|
+
|
21
|
+
# Send the batch once this delay has passed, from the time the first message
|
22
|
+
# is queued. (> 0, default: 5)
|
23
|
+
config :delay_threshold_secs, validate: :number, default: 5
|
24
|
+
|
25
|
+
# Once this many messages are queued, send all the messages in a single call, < 1000
|
26
|
+
config :message_count_threshold, validate: :number, default: 100
|
27
|
+
|
28
|
+
# Once the number of bytes in the batched request reaches this threshold,
|
29
|
+
# send all of the messages in a single call, even if neither the delay or
|
30
|
+
# message count thresholds have been exceeded yet.
|
31
|
+
config :request_byte_threshold, validate: :bytes, default: 1_000_000
|
32
|
+
|
33
|
+
# Attributes to add to the message in key: value formats.
|
34
|
+
config :attributes, validate: :hash, default: {}
|
35
|
+
|
36
|
+
# By default, we serialize messages with JSON.
|
37
|
+
default :codec, 'json'
|
38
|
+
|
39
|
+
def register
|
40
|
+
@logger.info("Registering Google PubSub Output plugin: #{full_topic}")
|
41
|
+
|
42
|
+
batch_settings = LogStash::Outputs::Pubsub::Client.build_batch_settings(
|
43
|
+
@request_byte_threshold,
|
44
|
+
@delay_threshold_secs,
|
45
|
+
@message_count_threshold
|
46
|
+
)
|
47
|
+
|
48
|
+
@pubsub = LogStash::Outputs::Pubsub::Client.new(
|
49
|
+
@json_key_file,
|
50
|
+
full_topic,
|
51
|
+
batch_settings,
|
52
|
+
@logger
|
53
|
+
)
|
54
|
+
|
55
|
+
# Test that the attributes don't cause errors when they're set.
|
56
|
+
begin
|
57
|
+
@pubsub.build_message('', @attributes)
|
58
|
+
rescue TypeError => e
|
59
|
+
message = 'Make sure the attributes are string:string pairs'
|
60
|
+
@logger.error(message, error: e, attributes: @attributes)
|
61
|
+
raise message
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def multi_receive_encoded(events_and_encoded)
|
66
|
+
events_and_encoded.each do |event, encoded|
|
67
|
+
@logger.debug("Sending message #{encoded}")
|
68
|
+
|
69
|
+
@pubsub.publish_message(encoded, @attributes)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def stop
|
74
|
+
@pubsub.shutdown
|
75
|
+
end
|
76
|
+
|
77
|
+
def full_topic
|
78
|
+
"projects/#{@project_id}/topics/#{@topic}"
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'java'
|
2
|
+
require 'logstash-output-google_pubsub_jars.rb'
|
3
|
+
require 'logstash/outputs/pubsub/message_future_callback'
|
4
|
+
|
5
|
+
module LogStash
|
6
|
+
module Outputs
|
7
|
+
module Pubsub
|
8
|
+
|
9
|
+
# A wrapper around PubSub's Java API.
|
10
|
+
class Client
|
11
|
+
def initialize(json_key_file, topic_name, batch_settings, logger, client=nil)
|
12
|
+
@logger = logger
|
13
|
+
|
14
|
+
@pubsub = client || initialize_google_client(json_key_file, topic_name, batch_settings)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Creates a Java BatchSettings object given user-defined thresholds.
|
18
|
+
def self.build_batch_settings(byte_threshold, delay_threshold_secs, count_threshold)
|
19
|
+
com.google.api.gax.batching.BatchingSettings.newBuilder
|
20
|
+
.setElementCountThreshold(count_threshold)
|
21
|
+
.setRequestByteThreshold(byte_threshold)
|
22
|
+
.setDelayThreshold(org.threeten.bp.Duration.ofSeconds(delay_threshold_secs))
|
23
|
+
.build
|
24
|
+
end
|
25
|
+
|
26
|
+
# Creates a Java PubsubMessage given the message body as a string and a
|
27
|
+
# string:string hash of attributes
|
28
|
+
def build_message(message_string, attributes)
|
29
|
+
attributes ||= {}
|
30
|
+
|
31
|
+
data = com.google.protobuf.ByteString.copyFromUtf8(message_string)
|
32
|
+
builder = com.google.pubsub.v1.PubsubMessage.newBuilder
|
33
|
+
.setData(data)
|
34
|
+
|
35
|
+
attributes.each { |k, v| builder.putAttributes(k, v) }
|
36
|
+
|
37
|
+
builder.build
|
38
|
+
end
|
39
|
+
|
40
|
+
# Creates a PubsubMessage from the string and attributes
|
41
|
+
# then queues it up to be sent.
|
42
|
+
def publish_message(message_string, attributes)
|
43
|
+
message = build_message(message_string, attributes)
|
44
|
+
messageIdFuture = @pubsub.publish(message)
|
45
|
+
setup_callback(message_string, messageIdFuture)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Sets up the Google pubsub client.
|
49
|
+
# It's unlikely this is needed out of initialize, but it's left public
|
50
|
+
# for the purposes of mocking.
|
51
|
+
def initialize_google_client(json_key_file, topic_name, batch_settings)
|
52
|
+
@logger.info("Initializing Google API client on #{topic_name} key: #{json_key_file}")
|
53
|
+
|
54
|
+
if use_default_credential? json_key_file
|
55
|
+
credentials = com.google.cloud.pubsub.v1.TopicAdminSettings.defaultCredentialsProviderBuilder().build()
|
56
|
+
else
|
57
|
+
raise_key_file_error(json_key_file)
|
58
|
+
|
59
|
+
key_file = java.io.FileInputStream.new(json_key_file)
|
60
|
+
sac = com.google.auth.oauth2.ServiceAccountCredentials.fromStream(key_file)
|
61
|
+
credentials = com.google.api.gax.core.FixedCredentialsProvider.create(sac)
|
62
|
+
end
|
63
|
+
|
64
|
+
com.google.cloud.pubsub.v1.Publisher.newBuilder(topic_name)
|
65
|
+
.setCredentialsProvider(credentials)
|
66
|
+
.setHeaderProvider(construct_headers)
|
67
|
+
.setBatchingSettings(batch_settings)
|
68
|
+
.build
|
69
|
+
end
|
70
|
+
|
71
|
+
# Schedules immediate publishing of any outstanding messages and waits
|
72
|
+
# until all are processed.
|
73
|
+
def shutdown
|
74
|
+
@pubsub.shutdown
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def setup_callback(message_string, messageIdFuture)
|
80
|
+
callback = LogStash::Outputs::Pubsub::MessageFutureCallback.new message_string, @logger
|
81
|
+
|
82
|
+
com.google.api.core.ApiFutures.addCallback(messageIdFuture, callback)
|
83
|
+
end
|
84
|
+
|
85
|
+
def construct_headers
|
86
|
+
gem_name = 'logstash-output-google_pubsub'
|
87
|
+
user_agent = "Elastic/#{gem_name}"
|
88
|
+
|
89
|
+
com.google.api.gax.rpc.FixedHeaderProvider.create('User-Agent', user_agent)
|
90
|
+
end
|
91
|
+
|
92
|
+
def use_default_credential?(key_file)
|
93
|
+
key_file.nil? || key_file == ''
|
94
|
+
end
|
95
|
+
|
96
|
+
# raises an exception if the key file is invalid
|
97
|
+
def raise_key_file_error(key_file)
|
98
|
+
is_abs = ::File.absolute_path(key_file) == key_file
|
99
|
+
raise "json_key_file must be an absolute path: #{key_file}" unless is_abs
|
100
|
+
|
101
|
+
exists = ::File.exist? key_file
|
102
|
+
raise "json_key_file does not exist: #{key_file}" unless exists
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module LogStash
|
2
|
+
module Outputs
|
3
|
+
module Pubsub
|
4
|
+
# Implements ApiFutureCallback<String>
|
5
|
+
class MessageFutureCallback
|
6
|
+
def initialize(message_body, logger)
|
7
|
+
@message_body = message_body
|
8
|
+
@logger = logger
|
9
|
+
end
|
10
|
+
|
11
|
+
# Implements public void onSuccess(String messageId)
|
12
|
+
def on_success(message_id)
|
13
|
+
@logger.debug("Published #{@message_body} with id: #{message_id}")
|
14
|
+
end
|
15
|
+
|
16
|
+
# Implements public void onFailure(Throwable t)
|
17
|
+
def on_failure(throwable)
|
18
|
+
@logger.error("Failed to send message.", message: @message_body, error: throwable.getMessage)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-google_pubsub'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'Emit output messages to Google Pubsub topic.'
|
6
|
+
s.description = 'This gem is a Logstash output plugin to be installed on top of the Logstash'\
|
7
|
+
'core pipeline using $LS_HOME/bin/logstash-plugin install gemname.'\
|
8
|
+
'This gem is not a stand-alone program.'
|
9
|
+
s.homepage = 'https://cloud.google.com/pubsub/overview'
|
10
|
+
s.authors = ['Eric Johnson']
|
11
|
+
s.email = 'erjohnso@google.com'
|
12
|
+
s.require_paths = ['lib', 'vendor/jar-dependencies']
|
13
|
+
|
14
|
+
# Files
|
15
|
+
s.files = Dir['lib/**/*','spec/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE',
|
16
|
+
'NOTICE.TXT', 'vendor/jar-dependencies/**/*.jar', 'vendor/jar-dependencies/**/*.rb',
|
17
|
+
'VERSION', 'docs/**/*']
|
18
|
+
|
19
|
+
# Tests
|
20
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
21
|
+
|
22
|
+
# Special flag to let us know this is actually a logstash plugin
|
23
|
+
s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'output' }
|
24
|
+
|
25
|
+
# Gem dependencies
|
26
|
+
s.add_runtime_dependency 'logstash-codec-json', '~> 3.0'
|
27
|
+
s.add_runtime_dependency 'logstash-codec-plain', '~> 3.0'
|
28
|
+
s.add_runtime_dependency 'logstash-core-plugin-api', '>= 1.60', '<= 2.99'
|
29
|
+
s.add_development_dependency 'logstash-devutils', '~> 1.3'
|
30
|
+
|
31
|
+
# JARs
|
32
|
+
s.add_development_dependency 'jar-dependencies', '~> 0.3.4'
|
33
|
+
|
34
|
+
s.platform = 'java'
|
35
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'logstash/devutils/rspec/spec_helper'
|
2
|
+
require 'logstash/outputs/google_pubsub'
|
3
|
+
require 'logstash/outputs/pubsub/client'
|
4
|
+
require 'logstash/codecs/plain'
|
5
|
+
require 'logstash/event'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
describe LogStash::Outputs::GooglePubsub do
|
9
|
+
let(:config) { {
|
10
|
+
'project_id' => 'my-project',
|
11
|
+
'topic' => 'my-topic',
|
12
|
+
'delay_threshold_secs' => 1,
|
13
|
+
'message_count_threshold' => 2,
|
14
|
+
'request_byte_threshold' => 3,
|
15
|
+
'attributes' => {'foo' => 'bar'}
|
16
|
+
} }
|
17
|
+
let(:sample_event) { LogStash::Event.new({'key'=>'value'}) }
|
18
|
+
|
19
|
+
let(:pubsub_client) { double('pubsub-api-client') }
|
20
|
+
let(:batching_settings) { double('batching-settings') }
|
21
|
+
|
22
|
+
subject { LogStash::Outputs::GooglePubsub.new(config) }
|
23
|
+
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
delay = config['delay_threshold_secs']
|
27
|
+
count = config['message_count_threshold']
|
28
|
+
bytes = config['request_byte_threshold']
|
29
|
+
|
30
|
+
allow(LogStash::Outputs::Pubsub::Client).to receive(:build_batch_settings).and_return(batching_settings)
|
31
|
+
expect(LogStash::Outputs::Pubsub::Client).to receive(:build_batch_settings).with(bytes, delay, count)
|
32
|
+
|
33
|
+
allow(LogStash::Outputs::Pubsub::Client).to receive(:new).and_return(pubsub_client)
|
34
|
+
expect(LogStash::Outputs::Pubsub::Client).to receive(:new)
|
35
|
+
|
36
|
+
allow(pubsub_client).to receive(:build_message)
|
37
|
+
subject.register
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#multi_receive_encoded' do
|
41
|
+
it 'sends the message as JSON text by default' do
|
42
|
+
expect(pubsub_client).to receive(:publish_message).with(/"key":"value"/, anything)
|
43
|
+
|
44
|
+
subject.multi_receive([sample_event])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sends attributes' do
|
48
|
+
expect(pubsub_client).to receive(:publish_message).with(anything, config['attributes'])
|
49
|
+
|
50
|
+
subject.multi_receive([sample_event])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#stop' do
|
55
|
+
it 'calls shutdown on the pubsub client' do
|
56
|
+
expect(pubsub_client).to receive(:shutdown)
|
57
|
+
|
58
|
+
subject.stop
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#full_topic' do
|
63
|
+
it 'formats the topic correctly' do
|
64
|
+
expect(subject.full_topic).to eq('projects/my-project/topics/my-topic')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'logstash/devutils/rspec/spec_helper'
|
2
|
+
require 'logstash/outputs/pubsub/client'
|
3
|
+
require 'logstash/codecs/plain'
|
4
|
+
require 'logstash/event'
|
5
|
+
require 'java'
|
6
|
+
|
7
|
+
describe LogStash::Outputs::Pubsub::Client do
|
8
|
+
let(:config) { {
|
9
|
+
'project_id' => 'my-project',
|
10
|
+
'topic' => 'my-topic',
|
11
|
+
'delay_threshold_secs' => 1,
|
12
|
+
'message_count_threshold' => 2,
|
13
|
+
'request_byte_threshold' => 3,
|
14
|
+
'attributes' => {'foo' => 'bar'}
|
15
|
+
} }
|
16
|
+
let(:sample_event) { LogStash::Event.new({'key'=>'value'}) }
|
17
|
+
|
18
|
+
let(:logger) { double('logger') }
|
19
|
+
let(:api_client) { spy('api-client') }
|
20
|
+
let(:batch_settings) { double('api-client') }
|
21
|
+
|
22
|
+
subject { LogStash::Outputs::Pubsub::Client.new(nil, nil, batch_settings, logger, api_client) }
|
23
|
+
|
24
|
+
|
25
|
+
describe '#build_message' do
|
26
|
+
it 'creates a Java PubsubMessage' do
|
27
|
+
msg = subject.build_message('message-body', {})
|
28
|
+
expect(msg.getClass().getName()).to eq('com.google.pubsub.v1.PubsubMessage')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets the message body' do
|
32
|
+
msg = subject.build_message('message-body', {})
|
33
|
+
expect(msg.get_data.to_string_utf8).to eq('message-body')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'adds all attributes' do
|
37
|
+
msg = subject.build_message('message-body', {'a'=>'b','c'=>'d'})
|
38
|
+
expect(msg.get_attributes_count).to eq(2)
|
39
|
+
expect(msg.get_attributes_or_default('a', nil)).to eq('b')
|
40
|
+
expect(msg.get_attributes_or_default('c', nil)).to eq('d')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'does not fail with nil attributes' do
|
44
|
+
expect{subject.build_message('message-body', nil)}.to_not raise_error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#build_batch_settings' do
|
49
|
+
it 'creates a Java BatchingSettings object' do
|
50
|
+
b = LogStash::Outputs::Pubsub::Client.build_batch_settings(1,2,3)
|
51
|
+
|
52
|
+
expect(b.getClass().getName()).to eq('com.google.api.gax.batching.AutoValue_BatchingSettings')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'sets byte threshold correctly' do
|
56
|
+
b = LogStash::Outputs::Pubsub::Client.build_batch_settings(1,2,3)
|
57
|
+
|
58
|
+
expect(b.getRequestByteThreshold).to eq(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sets delay correctly' do
|
62
|
+
b = LogStash::Outputs::Pubsub::Client.build_batch_settings(1,2,3)
|
63
|
+
|
64
|
+
expect(b.getDelayThreshold().getSeconds()).to eq(2)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'sets count_threshold correctly' do
|
68
|
+
b = LogStash::Outputs::Pubsub::Client.build_batch_settings(1,2,3)
|
69
|
+
|
70
|
+
expect(b.getElementCountThreshold()).to eq(3)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#publish_message' do
|
75
|
+
before(:each) do
|
76
|
+
allow(com.google.api.core.ApiFutures).to receive(:addCallback)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'builds a message with passed in attributes' do
|
80
|
+
allow(subject).to receive(:build_message).and_return(double('message'))
|
81
|
+
expect(subject).to receive(:build_message).with('foo', {'a'=>'b'})
|
82
|
+
|
83
|
+
subject.publish_message 'foo', {'a' => 'b'}
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'publishes the message' do
|
87
|
+
expect(api_client).to receive(:publish)
|
88
|
+
|
89
|
+
subject.publish_message 'foo', {'a' => 'b'}
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'creates a callback' do
|
93
|
+
expect(com.google.api.core.ApiFutures).to receive(:addCallback)
|
94
|
+
|
95
|
+
subject.publish_message 'foo', {'a' => 'b'}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#shutdown' do
|
100
|
+
it 'calls shutdown on the client' do
|
101
|
+
expect(api_client).to receive(:shutdown)
|
102
|
+
|
103
|
+
subject.shutdown
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.1.3/jackson-core-2.1.3.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/jar-dependencies/com/google/cloud/google-cloud-core/1.37.1/google-cloud-core-1.37.1.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-google_pubsub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Eric Johnson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '3.0'
|
19
|
+
name: logstash-codec-json
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
name: logstash-codec-plain
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.60'
|
47
|
+
- - "<="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.99'
|
50
|
+
name: logstash-core-plugin-api
|
51
|
+
prerelease: false
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.60'
|
58
|
+
- - "<="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.99'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.3'
|
67
|
+
name: logstash-devutils
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.3'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.3.4
|
81
|
+
name: jar-dependencies
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.3.4
|
89
|
+
description: This gem is a Logstash output plugin to be installed on top of the Logstashcore
|
90
|
+
pipeline using $LS_HOME/bin/logstash-plugin install gemname.This gem is not a stand-alone
|
91
|
+
program.
|
92
|
+
email: erjohnso@google.com
|
93
|
+
executables: []
|
94
|
+
extensions: []
|
95
|
+
extra_rdoc_files: []
|
96
|
+
files:
|
97
|
+
- CHANGELOG.md
|
98
|
+
- CONTRIBUTING.md
|
99
|
+
- CONTRIBUTORS
|
100
|
+
- Gemfile
|
101
|
+
- LICENSE
|
102
|
+
- README.md
|
103
|
+
- docs/index.asciidoc
|
104
|
+
- lib/logstash-output-google_pubsub_jars.rb
|
105
|
+
- lib/logstash/outputs/google_pubsub.rb
|
106
|
+
- lib/logstash/outputs/pubsub/client.rb
|
107
|
+
- lib/logstash/outputs/pubsub/message_future_callback.rb
|
108
|
+
- logstash-output-google_pubsub.gemspec
|
109
|
+
- spec/outputs/google_pubsub_spec.rb
|
110
|
+
- spec/outputs/pubsub/client_spec.rb
|
111
|
+
- vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.1.3/jackson-core-2.1.3.jar
|
112
|
+
- vendor/jar-dependencies/com/google/api/api-common/1.6.0/api-common-1.6.0.jar
|
113
|
+
- vendor/jar-dependencies/com/google/api/gax-grpc/1.29.0/gax-grpc-1.29.0.jar
|
114
|
+
- vendor/jar-dependencies/com/google/api/gax/1.29.0/gax-1.29.0.jar
|
115
|
+
- vendor/jar-dependencies/com/google/api/grpc/grpc-google-cloud-pubsub-v1/1.19.1/grpc-google-cloud-pubsub-v1-1.19.1.jar
|
116
|
+
- vendor/jar-dependencies/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.19.1/proto-google-cloud-pubsub-v1-1.19.1.jar
|
117
|
+
- vendor/jar-dependencies/com/google/api/grpc/proto-google-common-protos/1.12.0/proto-google-common-protos-1.12.0.jar
|
118
|
+
- vendor/jar-dependencies/com/google/api/grpc/proto-google-iam-v1/0.12.0/proto-google-iam-v1-0.12.0.jar
|
119
|
+
- vendor/jar-dependencies/com/google/auth/google-auth-library-credentials/0.9.1/google-auth-library-credentials-0.9.1.jar
|
120
|
+
- vendor/jar-dependencies/com/google/auth/google-auth-library-oauth2-http/0.9.1/google-auth-library-oauth2-http-0.9.1.jar
|
121
|
+
- vendor/jar-dependencies/com/google/auto/value/auto-value/1.4/auto-value-1.4.jar
|
122
|
+
- vendor/jar-dependencies/com/google/cloud/google-cloud-core-grpc/1.37.1/google-cloud-core-grpc-1.37.1.jar
|
123
|
+
- vendor/jar-dependencies/com/google/cloud/google-cloud-core/1.37.1/google-cloud-core-1.37.1.jar
|
124
|
+
- vendor/jar-dependencies/com/google/cloud/google-cloud-pubsub/1.37.1/google-cloud-pubsub-1.37.1.jar
|
125
|
+
- vendor/jar-dependencies/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
|
126
|
+
- vendor/jar-dependencies/com/google/code/gson/gson/2.7/gson-2.7.jar
|
127
|
+
- vendor/jar-dependencies/com/google/errorprone/error_prone_annotations/2.2.0/error_prone_annotations-2.2.0.jar
|
128
|
+
- vendor/jar-dependencies/com/google/guava/guava/20.0/guava-20.0.jar
|
129
|
+
- vendor/jar-dependencies/com/google/http-client/google-http-client-jackson2/1.19.0/google-http-client-jackson2-1.19.0.jar
|
130
|
+
- vendor/jar-dependencies/com/google/http-client/google-http-client/1.23.0/google-http-client-1.23.0.jar
|
131
|
+
- vendor/jar-dependencies/com/google/protobuf/protobuf-java-util/3.6.0/protobuf-java-util-3.6.0.jar
|
132
|
+
- vendor/jar-dependencies/com/google/protobuf/protobuf-java/3.6.0/protobuf-java-3.6.0.jar
|
133
|
+
- vendor/jar-dependencies/com/google/protobuf/protobuf-lite/3.0.1/protobuf-lite-3.0.1.jar
|
134
|
+
- vendor/jar-dependencies/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
|
135
|
+
- vendor/jar-dependencies/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
|
136
|
+
- vendor/jar-dependencies/io/grpc/grpc-auth/1.13.1/grpc-auth-1.13.1.jar
|
137
|
+
- vendor/jar-dependencies/io/grpc/grpc-context/1.13.1/grpc-context-1.13.1.jar
|
138
|
+
- vendor/jar-dependencies/io/grpc/grpc-core/1.13.1/grpc-core-1.13.1.jar
|
139
|
+
- vendor/jar-dependencies/io/grpc/grpc-netty-shaded/1.13.1/grpc-netty-shaded-1.13.1.jar
|
140
|
+
- vendor/jar-dependencies/io/grpc/grpc-protobuf-lite/1.13.1/grpc-protobuf-lite-1.13.1.jar
|
141
|
+
- vendor/jar-dependencies/io/grpc/grpc-protobuf/1.13.1/grpc-protobuf-1.13.1.jar
|
142
|
+
- vendor/jar-dependencies/io/grpc/grpc-stub/1.13.1/grpc-stub-1.13.1.jar
|
143
|
+
- vendor/jar-dependencies/io/opencensus/opencensus-api/0.12.3/opencensus-api-0.12.3.jar
|
144
|
+
- vendor/jar-dependencies/io/opencensus/opencensus-contrib-grpc-metrics/0.12.3/opencensus-contrib-grpc-metrics-0.12.3.jar
|
145
|
+
- vendor/jar-dependencies/joda-time/joda-time/2.9.2/joda-time-2.9.2.jar
|
146
|
+
- vendor/jar-dependencies/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar
|
147
|
+
- vendor/jar-dependencies/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar
|
148
|
+
- vendor/jar-dependencies/org/threeten/threetenbp/1.3.3/threetenbp-1.3.3.jar
|
149
|
+
homepage: https://cloud.google.com/pubsub/overview
|
150
|
+
licenses:
|
151
|
+
- Apache-2.0
|
152
|
+
metadata:
|
153
|
+
logstash_plugin: 'true'
|
154
|
+
logstash_group: output
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
- vendor/jar-dependencies
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.6.13
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Emit output messages to Google Pubsub topic.
|
176
|
+
test_files:
|
177
|
+
- spec/outputs/google_pubsub_spec.rb
|
178
|
+
- spec/outputs/pubsub/client_spec.rb
|