3
import logging
import graypy

my_logger = logging.getLogger('test_logger')
my_logger.setLevel(logging.DEBUG)

handler = graypy.GELFHandler('my_graylog_server', 12201)
my_logger.addHandler(handler)

my_adapter = logging.LoggerAdapter(logging.getLogger('test_logger'),
                                   { 'username': 'John' })

my_adapter.debug('Hello Graylog2 from John.')

is not working

I think the issue is the url that should send to /gelf because when I curl from the terminal to my graylog server , it works

 curl -XPOST http://my_graylog_server:12201/gelf -p0 -d '{"short_message":"Hello there", "host":"example1111.org", "facility":"test", "_foo":"bar"}'
Ohad Perry
  • 1,315
  • 2
  • 15
  • 26

2 Answers2

7

Open your Graylog Webapp, click 'System'. You will see a list of links on the right. On of them is 'Input', click this one. Now you have an overview of all running inputs, listening on different ports. On top of the page you can create a new one. There should be a drop box containing certain modes for the input listener (I think 'GELF AMQP' is standard). Change this one to GELF UDP and click 'Launch new input' in the next dialogue you can specify a port for the service. You also have to set a node where the messages have to be stored. This node as (or should have) the same IP as your whole graylog2 system.

Now you should be able to receive messages

1

I think you've setup your input stream For Gelf TCP instead of UDP. I set up a TCP Stream and it got the curl message. However my python application wouldn't send to the stream. I then created a Gelf UDP stream and voila! I ran into this same issue configuring my Graylog EC2 Appliance just a few moments ago.

Also make sure firewall/security groups aren't blocking UDP protocol on port 12201 as well.

Good luck, and I hope this is your issue!

Justin Fortier
  • 451
  • 5
  • 6
  • hi @justin , my udp was blocked, I unblocked it http://cl.ly/image/0F0C0i1w0b0R. but still, no go. where exactly should I setup my Gelf Stream to UDP? – Ohad Perry Mar 22 '15 at 07:21