telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

SNMP trap collection Telegraf

Open ErantD opened this issue 8 years ago • 42 comments

Feature Request

Opening a feature request kicks off a discussion.

Proposal:

Have telegraf receive passive snmp traps and send them to influxdb.

Current behavior:

Currently telegraf can get active snmp, via queries to a host, but host send snmp are not collectable with telegraf. Example would be an snmp trap sent because of a failed power supply, telegraf does not collect the trap and therefore is not able to forward it to influxdb.

Desired behavior:

Telegraf to receive and forward snmp traps from hosts to influxdb. ie. 1.) host send traps to telegraf because of a power supply failure. 2.) telegraf receives trap, translates it to influxdb line language using vendor MIB 3.) sends proper influxdb input to influxdb. 4.) to make it perfect, Kapacitor shows alert.

Use case: [Why is this important (helps with prioritizing requests)]

We are monitoring lots of systems, and we want to centralize all monitoring to one monitoring system. To make this complete with influxdb, grafana and kapacitor, we are missing the snmp trap from hosts, like PSU failover, disk failure, node reboot, etc..

ErantD avatar Jul 04 '18 11:07 ErantD

Now i set by follow scheme: Logstash -> logfile -> Telegraf Logparcer And also wait for native realization.

dmitrysdm avatar Jul 11 '18 08:07 dmitrysdm

the gosnmp that's used by telegraf already has a trap listening implementation.

see: https://github.com/soniah/gosnmp/blob/master/trap.go

maybe it's the way to go

since i don't know Golang, I was thinking on recurring to snmptrapd and snmptt sending logs to telegraf syslog input plugin, but that's a lot of moving parts

endersonmaia avatar Aug 19 '18 15:08 endersonmaia

+1

skipper00 avatar Aug 22 '18 10:08 skipper00

This would nicely complement the syslog receiver which Telegraf 1.7 gained, especially if it could be used with Chronograf's integrated log viewer.

An issue here is how to break up the information contained within SNMP trap records. Maybe these should be dealt with the same as syslog structured data fields, creating dynamic timeseries (columns) as required.

For example, a linkDown trap might arrive like this in tcpdump:

    127.0.0.1.57932 > 127.0.0.1.162:  { SNMPv2c { V2Trap(108) R=97760785  .1.3.6.1.2.1.1.3.0=20587570 .1.3.6.1.6.3.1.1.4.1.0=.1.3.6.1.6.3.1.1.5.3 .1.3.6.1.2.1.2.2.1.2="eth0" .1.3.6.1.2.1.2.2.1.7=1 .1.3.6.1.2.1.2.2.1.8=1 } }

which could be decoded to the following JSON:

{
  "sysUpTimeInstance": 20587570,
  "snmpTrapOID.0": "linkDown",
  "ifDescr": "eth0",
  "ifAdminStatus": "up",
  "ifOperStatus": "up"
}

Not all of this information is necessarily important; but if it contains ifIndex or ifDescr, you'll need it to identify the interface this event relates to.

candlerb avatar Oct 30 '18 17:10 candlerb

yes this would be nice , like now one has to go prtg datasource and grafana instead of just native into influx

discoduck2x avatar Nov 01 '18 16:11 discoduck2x

+1

URZ-HD avatar Nov 22 '18 08:11 URZ-HD

Hi...this is so easy request ..you can develop it?? Its so usefull and will help a lot!!!

iiidddaaannn102 avatar Jan 02 '19 12:01 iiidddaaannn102

Getting our enterprise acceptance of using Telegraf/Influx to replace a 'legacy' solution has this as a pre-requisite. Is there anything that we can do to help this along?

camden76 avatar Mar 07 '19 09:03 camden76

I think I'll try snmptrapd to syslog. Syslog already has a rich input plugin, and in this way, I will get the full power of snmptrapd to manage what the record will look like before I drop it into the db. At first, I was thinking of using snmptrapd to dump into an influx data formatted file, however, I'm worried about escape characters breaking this, or having unintended consequences. It would be nice to have a direct trap input, but I understand why this has not been implemented.

bruceschaller avatar May 24 '19 02:05 bruceschaller

Question for everyone: are you interested only in TRAP support or would INFORM also be useful? If you are interested in INFORM support is it a need or a want?

@bruceschaller Would love to hear more about your setup once you have it working, it sounds like a pretty good idea to me.

danielnelson avatar May 24 '19 03:05 danielnelson

For what it’s worth trap support the need inform would be useful, but if we could get trap working without the use of syslog and parsing I’d be super interested!

VMan228 avatar May 24 '19 03:05 VMan228

I personally would love inform support. Right now we have traps that are being sent to a docker container that is running syslog-ng and snmptrapd - but not able to get it to work with V3. Biggest issue has been the engine ID and configuring it to be apart of our automation system.

After doing a lot of research, we have been able to figure out how to get our traps formatted for Slack and Wavefront but would be nice to have it integrated with our Telegraf SNMP monitoring solution as well.

If there are questions or details I can provide to make this happen please let me know.

On Thu, May 23, 2019, 8:13 PM Daniel Nelson [email protected] wrote:

Question for everyone: are you interested only in TRAP support or would INFORM also be useful? If you are interested in INFORM support is it a need or a want?

@bruceschaller https://github.com/bruceschaller Would love to hear more about your setup once you have it working, it sounds like a pretty good idea to me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/influxdata/telegraf/issues/4377?email_source=notifications&email_token=AHEEGKHVISY7CGCUKTLHUB3PW5MNFA5CNFSM4FIJRVUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWEBGUY#issuecomment-495457107, or mute the thread https://github.com/notifications/unsubscribe-auth/AHEEGKEXGE3NJVUQOZGCHMLPW5MNFANCNFSM4FIJRVUA .

js-mode avatar May 24 '19 03:05 js-mode

@danielnelson TRAP and INFORM are a need

endersonmaia avatar May 24 '19 12:05 endersonmaia

This link ( https://www.influxdata.com/what-is-snmp/ ) indicates that the "Telegraf SNMP Input Plugin" supports receiving traps:

Telegraf can be deployed with SNMP Input Plugin configured to fetch or listen to specific OIDs. The plugin contains a SNMP traps receiver, which fetches traps from the managed device. Then, Telegraf batches the resulting data and streams it to InfluxDB.

Is that because the feature got developed already? Or is it a different component than being discussed here?

Is there any update on this? We also are being asked to get rid of COTS and this feature is the only large gap for a TICK stack versus our current stuff.

Thanks!

arkhitekton avatar Jul 17 '19 21:07 arkhitekton

Thanks for pointing out this page, unfortunately it is not accurate and currently there is no TRAP support in Telegraf. However, it is something we are working on.

I'll have someone correct that link to avoid confusion.

danielnelson avatar Jul 17 '19 21:07 danielnelson

Glad to see this is active! I was actually just looking to see if it had already been done. I'm a professional Go developer who's interested in helping; is there anything public available I could contribute to/collaborate on?

superdave avatar Jul 26 '19 01:07 superdave

@superdave Do you think you could investigate adding support for INFORM to gosnmp? From a cursory look at the library I don't think it is supported currently. If we can receive them and acknowledge in a similar way to TRAP, it would be very helpful.

danielnelson avatar Jul 26 '19 22:07 danielnelson

I could look! I don't know if I have any current devices that use it, but I imagine I can get one of the various SNMP daemons out there to throw one out.

superdave avatar Jul 27 '19 01:07 superdave

Sorry for the delay on this, but I'm starting to look into this tonight. Looks like net-snmp has INFORM functionality, so it should be easy enough to test from there, and someone's contacted me in re: running tests with real devices that have it (all my SNMP devices are old-ish and I haven't seen much in the way of INFORM functionality in their docs, so).

superdave avatar Aug 08 '19 01:08 superdave

VERY preliminary, definitely not ready for merge yet, but it looks like INFORM is actually pretty simple; it's just a TRAP that expects a pretty-much identical response. This works so far with snmptrap -v 2c -c public -Ci <host> 23 coldStart.0: https://github.com/soniah/gosnmp/pull/202

superdave avatar Aug 08 '19 03:08 superdave