Created
August 11, 2014 20:54
-
-
Save ptrlv/448cd19285d86267cb54 to your computer and use it in GitHub Desktop.
logstash zmq
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
# What does logstash do with the topic string? | |
# How can I filter messages zmq.SUBSCRIBE? | |
# Is logstash missing this: http://zguide.zeromq.org/page%3aall#Pub-Sub-Message-Envelopes | |
# logstash config | |
input { | |
generator { | |
lines => [ | |
"line 1", | |
"line 2", | |
"line 3" | |
] | |
} | |
} | |
filter { | |
} | |
output { | |
zeromq { | |
address => "tcp://localhost:5555" | |
topic => "foo" | |
topology => "pubsub" | |
} | |
} | |
$ cat submonitor.py | |
import sys | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.bind("tcp://*:5555") | |
socket.setsockopt(zmq.SUBSCRIBE, '') | |
while True: | |
msg = socket.recv_json() | |
print msg | |
# output of 'python submonitor.py' | |
{'host': 'localhost', 'message': 'line 1', '@version': '1', '@timestamp': '2014-08-11T20:46:26.820Z', 'sequence': 1} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment