severb / graypy

Python logging handler for Graylog that sends messages in GELF (Graylog Extended Log Format).
https://www.graylog.org/
BSD 3-Clause "New" or "Revised" License
258 stars 90 forks source link

Not working with IP address hosts #72

Closed rahmonov closed 7 years ago

rahmonov commented 7 years ago

This is working from the command line:

echo -e '{"version": "1.1","host":"example.org","short_message":"WOOORRRKIIING","full_message":"Backtrace here\n\nmore stuff","level":1,"_user_id":9001,"_some_info":"foo","_some_env_var":"bar"}\0' | nc -w 1 -u 104.197.106.62 12201

However, when I try the examples given in graypy documentation, it is not working. No errors, but I cannot see the logs on Graylog.

import logging
logger = logging.getLogger('projectname')
logger.debug('Please, work! :) ')

This is my setup:

'gelf': {
    'class': 'graypy.GELFHandler',
    'host': '104.197.106.62',
    'port': 12201,
}

and

'projectname': {
     'handlers': ['gelf'],
     'level': 'DEBUG',
 }

Please, note that when I do 'host': 'localhost' it is working on the local Graylog server. That's why I think that the problem may be in 'host': '104.197.106.62'. Is DNS name required? or am I doing something wrong?

Thank you!

rahmonov commented 7 years ago

Sorry, nevermind! This is my bad

Tayum commented 6 years ago

@rahmonov Hey! Please, explain me what have you done here to solve the issue. My problem is that when messages are sent from local machine (via 'host': 'localhost') they are delivered successfully, but with 'host': '<public_ip_of_my_graylog_server>' from external machine the logs are not delivered. 12201 UDP port is opened for external access in my VPC security group as well as in iptables.

rahmonov commented 6 years ago

@Tayum unfortunately I don't remember. I wish I explained how I fixed it. Was too young I guess :) But I looked at my configuration and saw that I changed the IP to a DNS name. Maybe this is what helped. Apologize again.

Tayum commented 6 years ago

@rahmonov Thank you anyways for taking the time to reply :)