Skip to content

Instantly share code, notes, and snippets.

@curzona
Created April 21, 2014 04:13
Show Gist options
  • Select an option

  • Save curzona/11132036 to your computer and use it in GitHub Desktop.

Select an option

Save curzona/11132036 to your computer and use it in GitHub Desktop.
Send a message to logstash in python
input {
udp {
port => 5959
format => 'json'
}
}
output {
stdout { }
elasticsearch {
embedded => true
}
}
import socket
import json
addr = ('127.0.0.1', 5959)
msg = json.dumps({'title':"Bugs Bunny's Bustin' Out All Over",
'who':"Elmer Fudd",
'message':"It's wabbit season, and I'm hunting wabbits, so be vewy, vewy quiet!"})
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(msg, addr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment