Search code examples
pythonudpudpclientgraylog2

python graypy simply not sending


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"}'

Solution

  • 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