Class: LogStash::Outputs::GooglePubsub
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::GooglePubsub
- Defined in:
- lib/logstash/outputs/google_pubsub.rb
Overview
A Logstash plugin to upload log events to cloud.google.com/pubsub/[Google Cloud Pubsub].
Instance Method Summary collapse
- #full_topic ⇒ Object
- #multi_receive_encoded(events_and_encoded) ⇒ Object
- #register ⇒ Object
- #stop ⇒ Object
Instance Method Details
#full_topic ⇒ Object
77 78 79 |
# File 'lib/logstash/outputs/google_pubsub.rb', line 77 def full_topic "projects/#{@project_id}/topics/#{@topic}" end |
#multi_receive_encoded(events_and_encoded) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/logstash/outputs/google_pubsub.rb', line 65 def multi_receive_encoded(events_and_encoded) events_and_encoded.each do |event, encoded| @logger.debug("Sending message #{encoded}") @pubsub.(encoded, @attributes) end end |
#register ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/logstash/outputs/google_pubsub.rb', line 39 def register @logger.info("Registering Google PubSub Output plugin: #{full_topic}") batch_settings = LogStash::Outputs::Pubsub::Client.build_batch_settings( @request_byte_threshold, @delay_threshold_secs, ) @pubsub = LogStash::Outputs::Pubsub::Client.new( @json_key_file, full_topic, batch_settings, @logger ) # Test that the attributes don't cause errors when they're set. begin @pubsub.('', @attributes) rescue TypeError => e = 'Make sure the attributes are string:string pairs' @logger.error(, error: e, attributes: @attributes) raise end end |
#stop ⇒ Object
73 74 75 |
# File 'lib/logstash/outputs/google_pubsub.rb', line 73 def stop @pubsub.shutdown end |