Begginer question - SNMP Plugin join tables with index

Hi!
I’m new to telegraf.
I’ve found the configuration for joining to snmp tables with different index field, but I couldn’t find how to join them when both tables have index:
These are the imputs.snmp of both tables:

[[inputs.snmp.table]]
# “A list of interface entries. The number of entries is\n given by the value of ifNumber.”
oid = “.1.3.6.1.2.1.2.2”
name = “IF-MIB::ifTable”

[[inputs.snmp.table]]
# “A list of interface entries. The number of entries is\n given by the value of ifNumber. This table contains\n additional objects for the interface table.”
oid = “.1.3.6.1.2.1.31.1.1”
name = “IF-MIB::ifXTable”
index_as_tag = true

The first snmp.table creates one tag called ifIndex and the second creates one called index due to the index_as_tag parameter.

Both index fields tags have the same values.

I want one measurement with all fields form both tables.

Probably is very simple but I couldn’t find the solution.

Thanks in advance.
Pablo

Hey @PabloFraire

There’s good example of use in this GitHub.

If your problem is only to have all the data in the same measurement with your configuration it could look like:

[[inputs.snmp]]
  agents = ["udp://@IP:161"]
  version = 2
  community = "public"

  [[inputs.snmp.table]]
    name = "interface_information"
    index_as_tag = true

    [[inputs.snmp.table.field]]
        # "A list of interface entries. The number of entries is given by the value of ifNumber."
        oid = ".1.3.6.1.2.1.2.2"
        name = "IF-MIB::ifTable"

    [[inputs.snmp.table.field]]
        # "A list of interface entries. The number of entries is given by the value of ifNumber. This table contains additional objects for the interface table."
        oid = ".1.3.6.1.2.1.31.1.1"
        name = "IF-MIB::ifXTable"

I think for your use you don’t really need to play with the secondary_indexe_table and secondary_indexe_use option. You can give it a try anyway!

Let me know how it goes.

Hi @codi640!
Thanks for your answer!

It didn’t work.
I couldn’t I find the example in the link so I copy your code.

If the table OID is set inside the table as table.field it only creates a field with the name and no data.

I tried setting the same measurement name for both tables, and got one measurement with all the fields but, as the reading is sequential each table has its timestamp so they are not in the same record.

      [[inputs.snmp.table]]
        # "A list of interface entries. The number of entries is\n given by the value of ifNumber."
        oid = ".1.3.6.1.2.1.2.2"
        name = "Interfaces"
    #    name = "IF-MIB::ifTable"

      [[inputs.snmp.table]]
        # "A list of interface entries. The number of entries is\n given by the value of ifNumber. This table contains\n additional objects for the interface table."
        oid = ".1.3.6.1.2.1.31.1.1"
        name = "Interfaces"
    #    name = "IF-MIB::ifXTable"
        index_as_tag = true

Any thoughts?
Tahnks in advance!

Hi @PabloFraire

I had a similar issue only a couple of weeks ago. When you reference the snmp.table or snmp.field for telegraf you can cross reference the gathered data. One is created with label is_tag = true and the other gets the label inherit_tags as shown in following example:

[[inputs.snmp.field]]
  oid = "SNMPv2-MIB::sysName.0"
  name = "hostname"
  is_tag = true

[[inputs.snmp.field]]
  oid = "SNMPv2-MIB::sysUpTime.0"
  name = "UpTime"
  conversion = "float(2)"

[[inputs.snmp.table]]
  oid = "IF-MIB::ifTable"
  name = "InterfaceTable"
  inherit_tags = ["hostname"]

I never tried to create my indices on my own bc influxdb does a good job already clustering the data with identical timestamps. Therefore tagging itself could suffice in your case.

I hope this helps
mateo

1 Like

@mateo gave good things.

I want to add, try to put an textual OID instead of numeric. I had some issues using numeric instead of textual (and the reverse is true)…

Hi!

Sorry, probably I was not clear. Or I don’t get what you are explaining me.

I can get all the info in two measurements, one for ifTable and other for ifXTable.
No problem there.
Each table has its own index tag.

In standard sql

SELECT * FROM ifTable, ifXtable WHERE ifTable.index = ifXTable.index

would be a workaround but I couldn’t make it work in influx.

So the goal is to get all fields in the same measurement in order to avoid the join.

Hey I just find your other question:

If you are okay with that, could you explain what are you gonna do with the data? Display them using Grafana? Something else? Maybe we can find a workaround.

I’m sorry I could not help you further more with the SNMP plugin problem, I remember now that I had the exact same problem.

I’m also providing you a part of my telegraf.conf file which collect data and put it all in the same measurement named snmp:

[[inputs.snmp]]
  agents = ["some IP address"]
  version = 2
  community = "supervision"
  tags = {network = "backbone"}

  ###################
  #      basic      #
  ###################
  [[inputs.snmp.field]]
    name = "hostname"
    oid = "RFC1213-MIB::sysName.0"
    is_tag = true

  [[inputs.snmp.field]]
    name = "sysUpTime"
    oid = "RFC1213-MIB::sysUpTime.0"
    conversion = "float(2)"

  [[inputs.snmp.field]]
    name = "board_temp"
    oid = "1.3.6.1.4.1.14988.1.1.3.10.0"
    is_tag = false

# And all others field are "is_tag = false"

Hi @codi640 !

Thanks!

I asked that in order to solve it via influxdb, but there is no way there.

At this moment these are all “intellectual” questions only to understand possibilities.

As there is a way to “join” snmp tables for indexes that are not simple, I guessed that there should be an easy way to join simple ones, but apparently is harder!

Here states:

Current behaviour:

Two tables can only be merged when the share the same index.

I’ll try to contact somebody in that thread to ask.

Regards!

1 Like

It seems that in ancient times there was a processors.join that is no longer available, and another processors.merge also deprecated.

Couldn’t find what replaced it!

Unfortunately, also it isn´t possible to use the secondary_index option.

One of the tables has implicit index so to see it it is necessary to set the index_as_tag = true and therefore is not possible to set neither secondary_index_table = true nor secondary_index_use = true to that index.

Close to giving up. :pleading_face:

1 Like

@PabloFraire What version of InfluxDB are you using? I think this problem is pretty solvable with Flux, which is available in InfluxDB 1.x, just a very old version of Flux. If you’re using InfluxDB Cloud Serverless, you can query with SQL, that does support joins and would make what you’re trying to do possible.

Thanks @scott!
Yes, I think it should be possible using flux joins.
I am using:
InfluxDB shell version: 1.8.9

Although, I rather have the solution using the snmp plugin as it should be a simpler thing than the issue with secondary indexes, I would give a try with flux joins.

Regards!

Hi!

Good news!

As I thought the solution was trivial. The problem was my unproficiency in SNMP structure

I had to go back to the MIB and further back to the RFC, but I solved it.

The issue was that the “ifXTable” is defined as an “AUGMENT” from the “ifTable”.
In these cases both tables uses the same index value so what we only have to do is to declare “ifXTable” fields as [[inputs.snmp.table.field]] belonging to “IfTable”[[inputs.snmp.table]]

For example:

[[inputs.snmp.table]]
        name = "IF-MIB::ifTable"
  [[inputs.snmp.table.field]]
    oid = ".1.3.6.1.2.1.2.2.1.1"
    name = "IF-MIB::ifIndex"
  [[inputs.snmp.table.field]]
    oid = ".1.3.6.1.2.1.31.1.1.1.18"
    name = "IF-MIB::ifAlias"

The first field belongs to “ifTable” and the second to “ifXTable”
You must declare explicitly all the tags and fields form each table that you need and not set the OID at table level.

1 Like