Slackbot
12/01/2022, 12:57 PMAshu
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 PMEzzEddin Abdullah
12/26/2022, 12:38 PMdeploy/docker/clickhouse-setup/docker-compose.yaml
file as described
• Added the syslog receivers in deploy/docker/clickhouse-setup/otel-collector-config.yaml
file and then appended the syslog
in the receivers list
• Modified the /etc/rsyslog.conf
to add this line: *.* action(type="omfwd" target="0.0.0.0" port="54527" protocol="tcp")
• sudo systemctl restart rsyslog.service
• sudo systemctl status rsyslog.service
so it's activated now
• Ran the SigNoz cluster using: docker-compose -f docker/clickhouse-setup/docker-compose.yaml up -d
• Ran the python script that contains the syslog script
• Check the tail /var/log/syslog
and saw the log inside
Finally, signed up to SigNoz dashboard to see the logs. But when I searched for the syslog statement, I found some logs that do not match the specific syslog keywords.
Any idea what's wrong I'm doing here?nitya-signoz
12/27/2022, 8:25 AMEzzEddin Abdullah
12/27/2022, 9:59 AMSigNoz is an open-source APM. It helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc.
Powered by