-
-
Save bk-khaled/4f47a26258cfb9be8b5909639fa6e375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/sensu/embedded/bin/ruby | |
require 'sensu-handler' | |
require 'kafka' | |
class Show < Sensu::Handler | |
def handle | |
kafka = Kafka.new( | |
# At least one of these nodes must be available: | |
seed_brokers: ["x.x.x.x:9092"], | |
# Set an optional client id in order to identify the client to Kafka: | |
client_id: "my-test", | |
) | |
# Instantiate a new producer. | |
producer = kafka.producer | |
# Add a message to the producer buffer. | |
producer.produce(@event.inspect, topic: "test") | |
# Deliver the messages to Kafka. | |
producer.deliver_messages | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment