EzzEddin Abdullah
12/01/2022, 12:57 PMsyslog
module in Python. I followed the documentation and then sent the logs through a Pyhon script. When I go into localhost:3301/logs
and search for the keyword I used in my log message, I see a couple of results but with a body that is different than my original message. Any idea what goes wrong here?Ashu
nitya-signoz
12/01/2022, 1:20 PMEzzEddin Abdullah
12/01/2022, 2:01 PMimport logging
from logging.handlers import SysLogHandler
def main():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = SysLogHandler(
facility=SysLogHandler.LOG_DAEMON,
address='/dev/log'
)
formatter = logging.Formatter(
fmt="%(asctime)s - %(filename)s:%(funcName)s:%(lineno)d %(levelname)s - '%(message)s'",
datefmt="%Y-%m-%d %H:%M:%S"
)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.debug('Sending syslog_message to SigNoz!')
if __name__ == '__main__':
main()
As you can see, this is the message Sending syslog_message to SigNoz!
I want to send to SigNoz.
After I run this script, I search for the keyword syslog_message
and I get nothing in return.
I've looked into the documentation of SysLogHandler and it looks like the protocol is RFC 5424: https://docs.python.org/3/library/logging.handlers.html#sysloghandler (not sure though)
If the protocol is correct for the logging module. How can I configure the one on SigNoz?nitya-signoz
12/02/2022, 4:08 AMnitya-signoz
12/02/2022, 11:12 AMDec 2 10:43:50 ip-172-31-27-188 systemd[631729]: Listening on D-Bus User Message Bus Socket.
Dec 2 10:43:50 ip-172-31-27-188 systemd[631729]: Reached target Sockets.
Dec 2 10:43:50 ip-172-31-27-188 systemd[631729]: Reached target Basic System.
Dec 2 10:43:50 ip-172-31-27-188 systemd[631729]: Reached target Main User Target.
Dec 2 10:43:50 ip-172-31-27-188 systemd[631729]: Startup finished in 45ms.
Dec 2 10:43:50 ip-172-31-27-188 systemd[1]: Started User Manager for UID 1000.
Dec 2 10:43:50 ip-172-31-27-188 systemd[1]: Started Session 81 of User ubuntu.
Dec 2 10:49:34 ip-172-31-27-188 2022-12-02 10:49:34 - main.py:main:20 DEBUG - 'Sending syslog_message to SigNoz!'
Dec 2 10:49:46 ip-172-31-27-188 systemd[1]: Started Session 83 of User ubuntu.
Dec 2 10:49:53 ip-172-31-27-188 2022-12-02 10:49:53 - main.py:main:20 DEBUG - 'Sending syslog_message to SigNoz!'
Now the Syslog parser is putting
`2022-12-02 10:49:53 - main.py:main:20 DEBUG - 'Sending syslog_message to SigNoz!'
in the value of the body. Which I think is your concern right?
If yes the reason here is in the syslog format eveything that you have published from the python script goes to the body as it writes its own timestamp. Incase you want to parse the above and only keep
`'Sending syslog_message to SigNoz!'
as your body you will have pipeline operators to parse your logs in the otel-collector-config.
ex:- https://github.com/SigNoz/nginx-logs-parsing/blob/c14a2178a050293a50549b79991ed3858e295c78/clickhouse-setup/otel-collector-config.yaml#L30EzzEddin Abdullah
12/12/2022, 11:53 AMnitya-signoz
12/13/2022, 3:22 AMEzzEddin Abdullah
12/26/2022, 12:29 PMnitya-signoz
12/27/2022, 8:25 AMEzzEddin Abdullah
12/27/2022, 9:59 AM