Class: LogStash::Inputs::Mqtt
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Mqtt
- Defined in:
- lib/logstash/inputs/mqtt.rb
Overview
Receive events from a MQTT topic
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
Instance Method Details
#register ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/logstash/inputs/mqtt.rb', line 45 def register @host = Socket.gethostname @client = MQTT::Client.connect( :host => @mqttHost, :port => @port, :ssl => @ssl, :username => @username, :password => @password, :client_id => @client_id, :clean_session => @clean_session ) end |
#run(queue) ⇒ Object
def register
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/logstash/inputs/mqtt.rb', line 58 def run(queue) @client.subscribe(@topic => @qos) @client.get do |topic,| @codec.decode() do |event| event.set("host", @host) event.set("topic", topic) decorate(event) queue << event end end end |