Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"}'
like image 768
Ohad Perry Avatar asked May 03 '26 03:05

Ohad Perry


2 Answers

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

like image 54
Alexander Schäfer Avatar answered May 04 '26 17:05

Alexander Schäfer


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!

like image 45
Justin Fortier Avatar answered May 04 '26 15:05

Justin Fortier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!