telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

syslog measurement not appearing in influxdb

Open adihat opened this issue 8 years ago • 16 comments

TL;DR Not able to see syslog logs in influxdb

Environment:

OS: mac os mojave
telegraf version: 1.8
influxdb version: 1.6.4

So I wanted to view logs in chronograf and figured out from the set of input plugins offered in telegraf to use the syslog plugin.

I have followed the instructions here, but have added the steps here too for easy read.

I installed rsyslog via homebrew as follows:

$ brew install rsyslog

Added the following in /usr/local/etc/rsyslog.conf:

$WorkDirectory /tmp/rsyslog # temporary directory for storing data 
$ActionQueueType LinkedList # use asynchronous processing 
$ActionQueueFileName srvrfwd # set file name, also enables disk mode 
$ActionResumeRetryCount -1 # infinite retries on insert failure 
$ActionQueueSaveOnShutdown on # save in-memory data if rsyslog shuts down 
$ModLoad imudp #loads the udp module 
#listen for messages on udp localhost:514 
$UDPServerAddress localhost 
$UDPServerRun 514 
*.* @@(o)127.0.0.1:6514;RSYSLOG_SyslogProtocol23Format

restarted rsyslog:

$ sudo brew services restart rsyslog

I configured telegraf as follows:

# # Accepts syslog messages per RFC5425
 [[inputs.syslog]]
#   ## Specify an ip or hostname with port - eg., tcp://localhost:6514, tcp://10.0.0.1:6514
#   ## Protocol, address and port to host the syslog receiver.
#   ## If no host is specified, then localhost is used.
#   ## If no port is specified, 6514 is used (RFC5425#section-4.1).
 server = "tcp://localhost:6514"

and restarted telegraf as follows:

$ brew services restart telegraf

But my expectation was to see syslog measurement inside of telegraf database

I wrote the following python script to log to syslog hoping that it would appear in the database:

import logging
import logging.handlers

my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)

handler = logging.handlers.SysLogHandler(address='/var/run/syslog')

my_logger.addHandler(handler)

my_logger.debug('this is debug')
my_logger.critical('this is critical')

but to no avail.

What could be wrong here? If so is there a log file I could check in?

So I troubleshooted rsyslog using the rsyslogd -N1 command and found some issues:

  • The configuration file must be in /etc/rsyslog.conf.
  • The configuration file working directory i.e; /tmp/rsyslog wasn't found so created one.
  • There were some errors in rsyslog.conf file

After doing all the above I restarted rsyslog and also influxdb and telegraf and checked again if there were any errors by running the rsyslogd -N1 command and the following is the output:

rsyslogd: version 8.37.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.

Still the same issue persists.

related post: syslog-plugin-from-remote-server

-Adarsh

adihat avatar Oct 24 '18 19:10 adihat

@russorat Can you compare against your Mac syslog notes?

cc @davidgs

danielnelson avatar Oct 24 '18 20:10 danielnelson

@adihat Can you try sending a syslog message directly to Telegraf using TCP as described here: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/syslog#troubleshooting

danielnelson avatar Nov 03 '18 01:11 danielnelson

I'm having this same issue, any additional tips? Though in my case, i'm not using rsyslog. From what I've read, shouldn't have to. Thanks!

dyanca avatar Mar 14 '19 19:03 dyanca

adihat Can you try sending a syslog message directly to Telegraf using TCP as described here: /plugins/inputs/syslog@master#troubleshooting

@dyanca, did you have any luck when you tried the troubleshooting tip from above? What are you using in place of rsyslog to feed logs to telegraf?

glinton avatar Mar 14 '19 21:03 glinton

That did not work unfortunately. I had thought the syslog plugin in telegraf would be able to accept incoming syslog traffic, alter the incoming event into an entry into the telegraf db on influxdb but I must have read it wrong. After reading this article, it's clear I'll need to find another way to process the logs without having a syslog solution on the same box as telegraf

dyanca avatar Mar 14 '19 23:03 dyanca

What was the error telegraf gave? What did the data you try sending look like? The syslog plugin does accept incoming syslog traffic and can store it in influxdb.

Without specific error messages, sample data you are trying to send, or seeing your config, debugging your specific issue is near impossible. My guess is that the syslog format you are trying to send to telegraf is not currently supported.

glinton avatar Mar 14 '19 23:03 glinton

Your comment regarding the syslog plugin being able to accept incoming traffic; is that with or without rsyslog involved? And I didn't see any telegraf errors rather, kept an eye on the database for the new measurement

dyanca avatar Mar 14 '19 23:03 dyanca

rsyslog doesn't need to be involved, but provides a translation for different protocols into the one that telegraf currently understands. If I were to be able to reproduce and debug this, I would start telegraf with a single output to stdout using data_format=json (json output is less strict wrt fields/tags/names).

Can you paste the log you were manually feeding into telegraf, honestly I'd love to reproduce this myself.

glinton avatar Mar 15 '19 16:03 glinton

I did end up getting this working. I did find there was a fight between rsyslog and telegraf for port 6514 in which seems to be fine as long as telegraf was started before rsyslog.

dyanca avatar Mar 20 '19 13:03 dyanca

Fantastic. You can also change the port telegraf (or rsyslog) listens on if you want to run both of them. If not, I'd suggest disabling the rsyslog service so it doesn't fail to start and end up in a restart loop.

glinton avatar Mar 20 '19 15:03 glinton

I am having a similar issue of syslog messages not showing up in influx.

I tested the method using netcat and it DID reach the DB. I do not see any error messages in telegraf. I have tried a few different python libraries to send messages but none have made it. Any ideas?

I am running telegraf as kubernetes daemonset

hakan458 avatar Mar 21 '19 22:03 hakan458

@hakan458 If netcat works I'd guess that the python libraries you are using are sending in the older BSD style format. Check the Telegraf logfile for errors, if that's not helpful can you open a new issue?

danielnelson avatar Mar 23 '19 01:03 danielnelson

@danielnelson I resolved the issue, it was indeed the way the python library was sending the logs.

hakan458 avatar Apr 01 '19 16:04 hakan458

@hakan458 Can you please tell what is the problem you faced with python

yasinmoha avatar May 21 '20 06:05 yasinmoha

@yasinmoha I dont remember the exact issue, but I was using a certain library and it was not sending the logs in the exact format that was expected. Try to send logs with something else outside of python, then replicate it in python. I believe I ended up using this library in the end: https://github.com/jobec/rfc5424-logging-handler

hakan458 avatar May 21 '20 18:05 hakan458

@yasinmoha I dont remember the exact issue, but I was using a certain library and it was not sending the logs in the exact format that was expected. Try to send logs with something else outside of python, then replicate it in python. I believe I ended up using this library in the end: https://github.com/jobec/rfc5424-logging-handler

Thanks I will check it

yasinmoha avatar May 22 '20 03:05 yasinmoha