lliknart / logstash-input-nats Goto Github PK
View Code? Open in Web Editor NEWNATS input plugin for Logstash
License: Other
NATS input plugin for Logstash
License: Other
It looks like NATS#start
will yield the started client to the given block, so we can use it directly with NATS::Client#subscribe
instead of the global NATS::subscribe
, which would enable multiple instances of this plugin to be able to run in the same Logstash process:
NATS.start(@nats_config) do |nats_client|
nats_client.on_error do |error|
logger.error(error)
end
@subjects.each do |subject|
logger.debug("Listening on [#{subject}]")
nats_client.subscribe(subject, :queue => @queue_group ) do |msg, _, sub|
@codec.decode(msg) do |event|
decorate(event)
event.set("nats_subject", sub)
queue << event
end
end
end
end
Note: I also used the logger
that is available on all Logstash plugins instead of Kernel#puts
๐
trapping TERM
and INT
in a Logstash plugin is considered bad-form, because these signals are used by Logstash for graceful shutdown. Binding them to a proc that calls Kernel#exit!
is especially troublesome because that means inclusion of this plugin in one pipeline causes all pipelines to immediately and unsafely abort when receiving a signal that ordinarily would initiate a safe shutdown.
Hi,
Can this plugin be used with multiple servers? Like the nats-ruby client:
NATS.start(:servers => ['nats://127.0.0.1:4222', 'nats://127.0.0.1:4223']) do |nc|
puts "NATS is connected to #{nc.connected_server}"
nc.on_reconnect do
puts "Reconnected to server at #{nc.connected_server}"
end
nc.on_disconnect do |reason|
puts "Disconnected: #{reason}"
end
nc.on_close do
puts "Connection to NATS closed"
end
end
Hope to hear from you
changing the global error-handling of NATS
to send Kernel#exit!
means that any time NATS encounters an error, the entire Logstash process dies in an unsafe manner.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.