logstash-input-google_pubsub 1.0.6 → 1.1.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
  SHA256:
3
- metadata.gz: 59322ce3c386faf1e2ec7b3805bbce3f07b2b9439bc7086a503269178541fb08
4
- data.tar.gz: 4407b4ed498ef6b5a8289978377c69f9ce0af6c10fec5f7fde04a43580e52c85
3
+ metadata.gz: 3f39efa6b21fafa252ad3e27a1a1a301681145c88498ac242e7b85a77a64382f
4
+ data.tar.gz: b92fe3cebc49c21702868a61a06a90c88b0f0372b5a7f57272add4a911359c1c
5
5
  SHA512:
6
- metadata.gz: 2b90a0f77e11d12d9733591a69acf2c3842f4dc68f5ff7a9dca951f43fc7cbd337e1bf54e4d0e27d3198a434797e2fc9ea075a80badf74dad4ec83f45b49a99a
7
- data.tar.gz: cce6661d8c84a268f3bb251cf953774cd6aae6db90efe37ed468ef22b5c12b9b2f6e76ca7e5e1a1a4d0c38efeadd16f5aee0ad4072674bb2ffd752b1bbb9f430
6
+ metadata.gz: a844cf0059e14822f1323a146b4f03b0745ab0f3c5a7c961626f35523059a632ef0169c96cf212612520b1a6ad5c6e428a08c30a82f8a8ffaab15d9c35d6b86b
7
+ data.tar.gz: 1ca3f6026de8645af0ea71ab648bb52fc76ac4513373d21ad6bd6e39352576b403c56e738905f0f1372182f40e08485fed375b21c7dedd117df866010783d02b
@@ -1,3 +1,6 @@
1
+ ## 1.1.0
2
+ - Add additional attributes in the `[@metadata][pubsub_message]` field. Fixes [#7](https://github.com/logstash-plugins/logstash-input-google_pubsub/issues/7)
3
+
1
4
  ## 1.0.6
2
5
  - Ignore acknowledge requests with an empty array of IDs. Fixes [#14](https://github.com/logstash-plugins/logstash-input-google_pubsub/issues/14)
3
6
 
@@ -138,6 +138,38 @@ input {
138
138
  output { stdout { codec => rubydebug } }
139
139
  ----------------------------------
140
140
 
141
+ ==== Metadata and Attributes
142
+
143
+ The original Pub/Sub message is preserved in the special Logstash
144
+ `[@metadata][pubsub_message]` field so you can fetch:
145
+
146
+ * Message attributes
147
+ * The origiginal base64 data
148
+ * Pub/Sub message ID for de-duplication
149
+ * Publish time
150
+
151
+ You MUST extract any fields you want in a filter prior to the data being sent
152
+ to an output because Logstash deletes `@metadata` fields otherwise.
153
+
154
+ See the PubsubMessage
155
+ https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage[documentation]
156
+ for a full description of the fields.
157
+
158
+ Example to get the message ID:
159
+
160
+ [source,ruby]
161
+ ----------------------------------
162
+ input {google_pubsub {...}}
163
+
164
+ filter {
165
+ mutate {
166
+ add_field => { "messageId" => "%{[@metadata][pubsub_message][messageId]}" }
167
+ }
168
+ }
169
+
170
+ output {...}
171
+ ----------------------------------
172
+
141
173
 
142
174
  [id="plugins-{type}s-{plugin}-options"]
143
175
  ==== Google_pubsub Input Configuration Options
@@ -152,6 +184,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
152
184
  | <<plugins-{type}s-{plugin}-project_id>> |<<string,string>>|Yes
153
185
  | <<plugins-{type}s-{plugin}-subscription>> |<<string,string>>|Yes
154
186
  | <<plugins-{type}s-{plugin}-topic>> |<<string,string>>|Yes
187
+ | <<plugins-{type}s-{plugin}-include_metadata>> |<<boolean,boolean>>|No
155
188
  |=======================================================================
156
189
 
157
190
  Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
@@ -209,9 +242,15 @@ Note that the topic must be created manually with Cloud Logging
209
242
  pre-configured export to PubSub configured to use the defined topic.
210
243
  The subscription will be created automatically by the plugin.
211
244
 
245
+ [id="plugins-{type}s-{plugin}-include_metadata"]
246
+ ===== `include_metadata`
247
+
248
+ * Value type is <<boolean,boolean>>
249
+ * Default value is `false`.
212
250
 
251
+ If set true, will include the full message data in the `[@metadata][pubsub_message]` field.
213
252
 
214
253
  [id="plugins-{type}s-{plugin}-common-options"]
215
254
  include::{include_path}/{type}.asciidoc[]
216
255
 
217
- :default_codec!:
256
+ :default_codec!:
@@ -122,6 +122,38 @@ require "google/api_client"
122
122
  # output { stdout { codec => rubydebug } }
123
123
  # ----------------------------------
124
124
  #
125
+ # ==== Metadata and Attributes
126
+ #
127
+ # The original Pub/Sub message is preserved in the special Logstash
128
+ # `[@metadata][pubsub_message]` field so you can fetch:
129
+ #
130
+ # * Message attributes
131
+ # * The origiginal base64 data
132
+ # * Pub/Sub message ID for de-duplication
133
+ # * Publish time
134
+ #
135
+ # You MUST extract any fields you want in a filter prior to the data being sent
136
+ # to an output because Logstash deletes `@metadata` fields otherwise.
137
+ #
138
+ # See the PubsubMessage
139
+ # https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage[documentation]
140
+ # for a full description of the fields.
141
+ #
142
+ # Example to get the message ID:
143
+ #
144
+ # [source,ruby]
145
+ # ----------------------------------
146
+ # input {google_pubsub {...}}
147
+ #
148
+ # filter {
149
+ # mutate {
150
+ # add_field => { "messageId" => "%{[@metadata][pubsub_message][messageId]}" }
151
+ # }
152
+ # }
153
+ #
154
+ # output {...}
155
+ # ----------------------------------
156
+ #
125
157
  class LogStash::Inputs::GooglePubSub < LogStash::Inputs::Base
126
158
  config_name "google_pubsub"
127
159
 
@@ -141,6 +173,9 @@ class LogStash::Inputs::GooglePubSub < LogStash::Inputs::Base
141
173
  # specify a Service Account JSON key file.
142
174
  config :json_key_file, :validate => :path, :required => false
143
175
 
176
+ # If set true, will include the full message data in the `[@metadata][pubsub_message]` field.
177
+ config :include_metadata, :validate => :boolean, :required => false, :default => false
178
+
144
179
  # If undefined, Logstash will complain, even if codec is unused.
145
180
  default :codec, "plain"
146
181
 
@@ -254,6 +289,7 @@ class LogStash::Inputs::GooglePubSub < LogStash::Inputs::Base
254
289
  if msg.key?("message") and msg["message"].key?("data")
255
290
  decoded_msg = Base64.decode64(msg["message"]["data"])
256
291
  @codec.decode(decoded_msg) do |event|
292
+ event.set("[@metadata][pubsub_message]", msg["message"]) if @include_metadata
257
293
  decorate(event)
258
294
  queue << event
259
295
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-google_pubsub'
3
- s.version = '1.0.6'
3
+ s.version = '1.1.0'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = "Consume events from a Google Cloud PubSub service"
6
6
  s.description = "This gem is a Logstash input plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-google_pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement