Skip to content

SNMP input can produce metrics with empty metric name #8840

@reimda

Description

@reimda

Steps to reproduce:

The snmp input can have a table with no oid or name but with fields. (see the plugin readme https://github.com/influxdata/telegraf/blob/ea4feb1a07edfea3243cc328f1994f63852e9f96/plugins/inputs/snmp/README.md#table) If the table name and the table oid are not set, the plugin produces metrics with no name.

Relevant telegraf.conf:

Here's an example snmp input that exhibits the problem.

[[inputs.snmp]]
  agents = ["udp://127.0.0.1:161"]
  community = "public"
  version = 2
  [[inputs.snmp.table]]
    #oid = "IF-MIB::ifXTable"
    #name = "ifXTable"
    index_as_tag = true
    [[inputs.snmp.table.field]]
      oid = "IF-MIB::ifHCInOctets"
      is_tag = false
    [[inputs.snmp.table.field]]
      oid = "IF-MIB::ifHCOutOctets"
      is_tag = false
[[outputs.file]]
  files = ["stdout"]
  data_format = "influx"

For this example you need a snmp agent running on localhost that allows access to IF-MIB::ifXTable with the public community string. I used net-snmp.

If you uncomment either the name or the oid settings, the metric is named so metrics are output.

System info:

I tested with telegraf master on linux but this is not platform specific.

Expected behavior:

I didn't expect telegraf to try to produce a metric with no name. Once I understood this was happening I would have expected an error from the snmp input or the agent itself or the file output.

The snmp input should provide a specific error, like "error: SNMP table at telegraf.conf line 234 is not named. One or both of the oid and name settings must be set".

Actual behavior:

Telegraf doesn't produce any metrics

Metadata

Metadata

Assignees

Labels

area/snmpbugunexpected problem or unintended behaviorerror handlingIssues related to error handling

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions