Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP input can produce metrics with empty metric name #8840

Closed
reimda opened this issue Feb 9, 2021 · 0 comments · Fixed by #9366 or #9519
Closed

SNMP input can produce metrics with empty metric name #8840

reimda opened this issue Feb 9, 2021 · 0 comments · Fixed by #9366 or #9519
Assignees
Labels
area/snmp bug unexpected problem or unintended behavior error handling Issues related to error handling

Comments

@reimda
Copy link
Contributor

reimda commented Feb 9, 2021

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

@reimda reimda added the bug unexpected problem or unintended behavior label Feb 9, 2021
@Hipska Hipska added the error handling Issues related to error handling label Mar 2, 2021
@MyaLongmire MyaLongmire self-assigned this Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/snmp bug unexpected problem or unintended behavior error handling Issues related to error handling
Projects
None yet
3 participants