Repository: prometheus/snmp_exporter
Pull request #915 (2023-07-13 00:45:33)

Add Mikrotik indexes
This PR adds several Mikrotik indexes, causing the following changes:

* `mtxrGaugeIndex`

```diff
-mtxrGaugeValue{mtxrGaugeIndex="17"} 54
-mtxrGaugeValue{mtxrGaugeIndex="7101"} 45
-mtxrGaugeValue{mtxrGaugeIndex="7201"} 501
+mtxrGaugeValue{mtxrGaugeName="board-temperature1"} 45
+mtxrGaugeValue{mtxrGaugeName="cpu-temperature"} 54
+mtxrGaugeValue{mtxrGaugeName="jack-voltage"} 501
```

* `mtxrNeighborIndex`

```diff
-mtxrNeighborMacAddress{mtxrNeighborIndex="1",mtxrNeighborMacAddress="48:8F:5A:17:D6:14"} 1
-mtxrNeighborMacAddress{mtxrNeighborIndex="2",mtxrNeighborMacAddress="AC:CC:8E:F7:DE:6B"} 1
+mtxrNeighborMacAddress{mtxrNeighborIpAddress="172.16.4.10",mtxrNeighborMacAddress="48:8F:5A:17:D6:14"} 1
+mtxrNeighborMacAddress{mtxrNeighborIpAddress="172.16.4.30",mtxrNeighborMacAddress="AC:CC:8E:F7:DE:6B"} 1
```

* `mtxrOpticalIndex`

```diff
-mtxrOpticalSupplyVoltage{mtxrOpticalIndex="9"} 3289
-mtxrOpticalTxPower{mtxrOpticalIndex="9"} -6343
-mtxrOpticalWavelength{mtxrOpticalIndex="9"} 131000
+mtxrOpticalSupplyVoltage{mtxrOpticalIndex="9",mtxrOpticalName="sfpplus1"} 3289
+mtxrOpticalTxPower{mtxrOpticalIndex="9",mtxrOpticalName="sfpplus1"} -6305
+mtxrOpticalWavelength{mtxrOpticalIndex="9",mtxrOpticalName="sfpplus1"} 131000
```

* `mtxrPOEInterfaceIndex`

```diff
-mtxrPOEStatus{mtxrPOEInterfaceIndex="1"} 2
-mtxrPOEStatus{mtxrPOEInterfaceIndex="2"} 2
-mtxrPOEStatus{mtxrPOEInterfaceIndex="3"} 5
+mtxrPOEStatus{mtxrPOEInterfaceIndex="1",mtxrPOEName="ether1"} 2
+mtxrPOEStatus{mtxrPOEInterfaceIndex="2",mtxrPOEName="ether2"} 2
+mtxrPOEStatus{mtxrPOEInterfaceIndex="3",mtxrPOEName="ether3"} 5
```

* `mtxrPartitionIndex`

```diff
-mtxrPartitionSize{mtxrPartitionIndex="1"} 1024
+mtxrPartitionSize{mtxrPartitionIndex="1",mtxrPartitionName="part0"} 1024
```

I opted to drop the index where it appears likely to change across reboots and leave the index otherwise.

SuperQ: This needs a DCO sign-off. You can use `git commit -s --amend` to add it.

Dropping source indexes is more about uniqueness. If there could be duplicates of a metric value in the new index, you want to keep the source indexes.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf3c36e..0326768 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 0.23.0-rc.0 / 2023-07-04
+## 0.23.0-rc.1 / 2023-07-20
 
 BREAKING CHANGES:
 
@@ -10,6 +10,7 @@ auth params without having to duplicate the full walk and metric mapping.
 See auth-split-migration.md for more details.
 
 * [CHANGE] Split config of auth and modules #859
+* [FEATURE] Add support for parsing SNMP transport from target #914
 * [ENHANCEMENT] Improved Lookup process for label information #908
 * [BUGFIX] Fix metrics path not using command-line argument value #904
 
diff --git a/README.md b/README.md
index 9abd0e7..e15d0f2 100644
--- a/README.md
+++ b/README.md
@@ -72,12 +72,22 @@ Start `snmp_exporter` as a daemon or from CLI:
 ./snmp_exporter
 ```
 
-Visit [http://localhost:9116/snmp?target=192.0.0.8] where `192.0.0.8` is the IP or
-FQDN of the SNMP device to get metrics from. Note that this will use the default auth (`public_v2`) and
-default module (`if_mib`). The auth and module must be defined in the `snmp.yml`.
+Visit <http://localhost:9116/snmp?target=192.0.0.8> where `192.0.0.8` is the IP or
+FQDN of the SNMP device to get metrics from. Note that this will use the default transport (`udp`),
+default port (`161`), default auth (`public_v2`) and default module (`if_mib`). The auth and module
+must be defined in the `snmp.yml` file.
 
 For example, if you have an auth named `my_secure_v3` for walking `ddwrt`, the URL would look like
-[http://localhost:9116/snmp?auth=my_secure_v3&module=ddwrt&target=192.0.0.8].
+<http://localhost:9116/snmp?auth=my_secure_v3&module=ddwrt&target=192.0.0.8>.
+
+To configure a different transport and/or port, use the syntax `[transport://]host[:port]`.
+
+For example, to scrape a device using `tcp` on port `1161`, the URL would look like
+<http://localhost:9116/snmp?auth=my_secure_v3&module=ddwrt&target=tcp%3A%2F%2F192.0.0.8%3A1161>.
+
+Note that [URL encoding](https://en.wikipedia.org/wiki/URL_encoding) should be used for `target` due
+to the `:` and `/` characters. Prometheus encodes query parameters automatically and manual encoding
+is not necessary within the Prometheus configuration file.
 
 ## Configuration
 
@@ -85,7 +95,7 @@ The default configuration file name is `snmp.yml` and should not be edited
 by hand. If you need to change it, see
 [Generating configuration](#generating-configuration).
 
-The default `snmp.yml` covers a variety of common hardware walking them
+The default `snmp.yml` file covers a variety of common hardware walking them
 using SNMP v2 GETBULK.
 
 ## Prometheus Configuration
@@ -100,6 +110,7 @@ scrape_configs:
       - targets:
         - 192.168.1.2  # SNMP device.
         - switch.local # SNMP device.
+        - tcp://192.168.1.3:1161  # SNMP device using TCP transport and custom port.
     metrics_path: /snmp
     params:
       auth: [public_v2]
@@ -156,4 +167,4 @@ easier for others, please consider contributing back your configurations to
 us.
 `snmp.yml` config should be accompanied by generator config.
 For your dashboard, alerts, and recording rules, please consider
-contributing them to https://github.com/prometheus/snmp_exporter/tree/main/snmp-mixin
+contributing them to <https://github.com/prometheus/snmp_exporter/tree/main/snmp-mixin>.
diff --git a/VERSION b/VERSION
index 4687a66..20711d5 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-0.23.0-rc.0
+0.23.0-rc.1
diff --git a/collector/collector.go b/collector/collector.go
index 1879bf3..1b62288 100644
--- a/collector/collector.go
+++ b/collector/collector.go
@@ -117,15 +117,9 @@ func ScrapeTarget(ctx context.Context, target string, auth *config.Auth, module
 		results.retries++
 	}
 
-	snmp.Target = target
-	snmp.Port = 161
-	if host, port, err := net.SplitHostPort(target); err == nil {
-		snmp.Target = host
-		p, err := strconv.Atoi(port)
-		if err != nil {
-			return results, fmt.Errorf("error converting port number to int for target %s: %s", target, err)
-		}
-		snmp.Port = uint16(p)
+	// Configure target.
+	if err := configureTarget(&snmp, target); err != nil {
+		return results, err
 	}
 
 	// Configure auth.
@@ -242,6 +236,24 @@ func ScrapeTarget(ctx context.Context, target string, auth *config.Auth, module
 	return results, nil
 }
 
+func configureTarget(g *gosnmp.GoSNMP, target string) error {
+	if s := strings.SplitN(target, "://", 2); len(s) == 2 {
+		g.Transport = s[0]
+		target = s[1]
+	}
+	g.Target = target
+	g.Port = 161
+	if host, port, err := net.SplitHostPort(target); err == nil {
+		g.Target = host
+		p, err := strconv.Atoi(port)
+		if err != nil {
+			return fmt.Errorf("error converting port number to int for target %q: %w", target, err)
+		}
+		g.Port = uint16(p)
+	}
+	return nil
+}
+
 func filterAllowedIndices(logger log.Logger, filter config.DynamicFilter, pdus []gosnmp.SnmpPDU, allowedList []string, metrics internalMetrics) []string {
 	level.Debug(logger).Log("msg", "Evaluating rule for oid", "oid", filter.Oid)
 	for _, pdu := range pdus {
diff --git a/config/config.go b/config/config.go
index 0c15c41..3f3ce5a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -14,7 +14,6 @@
 package config
 
 import (
-	"errors"
 	"fmt"
 	"os"
 	"regexp"
@@ -34,9 +33,6 @@ func LoadFile(filename string) (*Config, error) {
 	if err != nil {
 		return nil, err
 	}
-	if cfg.Version != 2 {
-		return cfg, ErrUnsupportedVersion
-	}
 	return cfg, nil
 }
 
@@ -63,15 +59,13 @@ var (
 	DefaultRegexpExtract = RegexpExtract{
 		Value: "$1",
 	}
-
-	ErrUnsupportedVersion = errors.New("unsupported config version")
 )
 
 // Config for the snmp_exporter.
 type Config struct {
 	Auths   map[string]*Auth   `yaml:"auths,omitempty"`
 	Modules map[string]*Module `yaml:"modules,omitempty"`
-	Version int                `yaml:"version"`
+	Version int                `yaml:"version,omitempty"`
 }
 
 type WalkParams struct {
diff --git a/generator/FORMAT.md b/generator/FORMAT.md
index 2793937..80f4db0 100644
--- a/generator/FORMAT.md
+++ b/generator/FORMAT.md
@@ -4,7 +4,6 @@ This is generated by the generator, so only those doing development should
 have to care about how this works.
 
 ```
-version: 2
 auths:
   public_v2:
     version: 2
diff --git a/generator/README.md b/generator/README.md
index ad2329c..edc5749 100644
--- a/generator/README.md
+++ b/generator/README.md
@@ -70,7 +70,6 @@ make docker-generate
 The simplest module is just a name and a set of OIDs to walk.
 
 ```yaml
-version: 2
 auths:
   auth_name:
     version: 2  # SNMP version to use. Defaults to 2.
diff --git a/generator/config.go b/generator/config.go
index 1576287..46578c8 100644
--- a/generator/config.go
+++ b/generator/config.go
@@ -23,7 +23,7 @@ import (
 type Config struct {
 	Auths   map[string]*config.Auth  `yaml:"auths"`
 	Modules map[string]*ModuleConfig `yaml:"modules"`
-	Version int                      `yaml:"version"`
+	Version int                      `yaml:"version,omitempty"`
 }
 
 type MetricOverrides struct {
diff --git a/generator/generator.yml b/generator/generator.yml
index f182722..4f8806c 100644
--- a/generator/generator.yml
+++ b/generator/generator.yml
@@ -1,7 +1,4 @@
 ---
-# The generator config format version.
-version: 2
-
 auths:
   public_v1:
     version: 1
@@ -589,6 +586,18 @@ modules:
       - source_indexes: [laIndex]
         lookup: laNames
         drop_source_indexes: true
+      - source_indexes: [mtxrGaugeIndex]
+        lookup: mtxrGaugeName
+        drop_source_indexes: true
+      - source_indexes: [mtxrNeighborIndex]
+        lookup: mtxrNeighborIpAddress
+        drop_source_indexes: true
+      - source_indexes: [mtxrOpticalIndex]
+        lookup: mtxrOpticalName
+      - source_indexes: [mtxrPOEInterfaceIndex]
+        lookup: mtxrPOEName
+      - source_indexes: [mtxrPartitionIndex]
+        lookup: mtxrPartitionName
     overrides:
       ifName:
         ignore: true # Lookup metric
diff --git a/generator/main.go b/generator/main.go
index 28efbf6..168760b 100644
--- a/generator/main.go
+++ b/generator/main.go
@@ -45,12 +45,8 @@ func generateConfig(nodes *Node, nameToNode map[string]*Node, logger log.Logger)
 	if err != nil {
 		return fmt.Errorf("error parsing yml config: %s", err)
 	}
-	if cfg.Version != 2 {
-		return config.ErrUnsupportedVersion
-	}
 
 	outputConfig := config.Config{}
-	outputConfig.Version = cfg.Version
 	outputConfig.Auths = cfg.Auths
 	outputConfig.Modules = make(map[string]*config.Module, len(cfg.Modules))
 	for name, m := range cfg.Modules {
diff --git a/snmp.yml b/snmp.yml
index 254680c..b111de9 100644
--- a/snmp.yml
+++ b/snmp.yml
@@ -14409,6 +14409,14 @@ modules:
       indexes:
       - labelname: mtxrGaugeIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrGaugeIndex
+        labelname: mtxrGaugeName
+        oid: 1.3.6.1.4.1.14988.1.1.3.100.1.2
+        type: DisplayString
+      - labels: []
+        labelname: mtxrGaugeIndex
     - name: mtxrGaugeName
       oid: 1.3.6.1.4.1.14988.1.1.3.100.1.2
       type: DisplayString
@@ -14416,6 +14424,14 @@ modules:
       indexes:
       - labelname: mtxrGaugeIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrGaugeIndex
+        labelname: mtxrGaugeName
+        oid: 1.3.6.1.4.1.14988.1.1.3.100.1.2
+        type: DisplayString
+      - labels: []
+        labelname: mtxrGaugeIndex
     - name: mtxrGaugeValue
       oid: 1.3.6.1.4.1.14988.1.1.3.100.1.3
       type: gauge
@@ -14423,6 +14439,14 @@ modules:
       indexes:
       - labelname: mtxrGaugeIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrGaugeIndex
+        labelname: mtxrGaugeName
+        oid: 1.3.6.1.4.1.14988.1.1.3.100.1.2
+        type: DisplayString
+      - labels: []
+        labelname: mtxrGaugeIndex
     - name: mtxrGaugeUnit
       oid: 1.3.6.1.4.1.14988.1.1.3.100.1.4
       type: gauge
@@ -14430,6 +14454,14 @@ modules:
       indexes:
       - labelname: mtxrGaugeIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrGaugeIndex
+        labelname: mtxrGaugeName
+        oid: 1.3.6.1.4.1.14988.1.1.3.100.1.2
+        type: DisplayString
+      - labels: []
+        labelname: mtxrGaugeIndex
       enum_values:
         1: celsius
         2: rpm
@@ -14703,6 +14735,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborIpAddress
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
       type: InetAddressIPv4
@@ -14710,6 +14750,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborMacAddress
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.3
       type: PhysAddress48
@@ -14717,6 +14765,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborVersion
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.4
       type: DisplayString
@@ -14724,6 +14780,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborPlatform
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.5
       type: DisplayString
@@ -14731,6 +14795,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborIdentity
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.6
       type: DisplayString
@@ -14738,6 +14810,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborSoftwareID
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.7
       type: DisplayString
@@ -14745,6 +14825,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrNeighborInterfaceID
       oid: 1.3.6.1.4.1.14988.1.1.11.1.1.8
       type: gauge
@@ -14752,6 +14840,14 @@ modules:
       indexes:
       - labelname: mtxrNeighborIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrNeighborIndex
+        labelname: mtxrNeighborIpAddress
+        oid: 1.3.6.1.4.1.14988.1.1.11.1.1.2
+        type: InetAddressIPv4
+      - labels: []
+        labelname: mtxrNeighborIndex
     - name: mtxrDate
       oid: 1.3.6.1.4.1.14988.1.1.12.1
       type: gauge
@@ -15679,6 +15775,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
     - name: mtxrPOEName
       oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
       type: DisplayString
@@ -15686,6 +15788,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
     - name: mtxrPOEStatus
       oid: 1.3.6.1.4.1.14988.1.1.15.1.1.3
       type: gauge
@@ -15693,6 +15801,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
       enum_values:
         1: disabled
         2: waitingForLoad
@@ -15705,6 +15819,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
     - name: mtxrPOECurrent
       oid: 1.3.6.1.4.1.14988.1.1.15.1.1.5
       type: gauge
@@ -15712,6 +15832,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
     - name: mtxrPOEPower
       oid: 1.3.6.1.4.1.14988.1.1.15.1.1.6
       type: gauge
@@ -15719,6 +15845,12 @@ modules:
       indexes:
       - labelname: mtxrPOEInterfaceIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPOEInterfaceIndex
+        labelname: mtxrPOEName
+        oid: 1.3.6.1.4.1.14988.1.1.15.1.1.2
+        type: DisplayString
     - name: mtxrLTEModemInterfaceIndex
       oid: 1.3.6.1.4.1.14988.1.1.16.1.1.1
       type: gauge
@@ -15834,6 +15966,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
     - name: mtxrPartitionName
       oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
       type: DisplayString
@@ -15841,6 +15979,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
     - name: mtxrPartitionSize
       oid: 1.3.6.1.4.1.14988.1.1.17.1.1.3
       type: gauge
@@ -15848,6 +15992,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
     - name: mtxrPartitionVersion
       oid: 1.3.6.1.4.1.14988.1.1.17.1.1.4
       type: DisplayString
@@ -15855,6 +16005,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
     - name: mtxrPartitionActive
       oid: 1.3.6.1.4.1.14988.1.1.17.1.1.5
       type: gauge
@@ -15862,6 +16018,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
       enum_values:
         0: "false"
         1: "true"
@@ -15872,6 +16034,12 @@ modules:
       indexes:
       - labelname: mtxrPartitionIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrPartitionIndex
+        labelname: mtxrPartitionName
+        oid: 1.3.6.1.4.1.14988.1.1.17.1.1.2
+        type: DisplayString
       enum_values:
         0: "false"
         1: "true"
@@ -15896,6 +16064,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalName
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
       type: DisplayString
@@ -15903,6 +16077,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalRxLoss
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.3
       type: gauge
@@ -15910,6 +16090,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
       enum_values:
         0: "false"
         1: "true"
@@ -15920,6 +16106,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
       enum_values:
         0: "false"
         1: "true"
@@ -15930,6 +16122,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalTemperature
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.6
       type: gauge
@@ -15937,6 +16135,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalSupplyVoltage
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.7
       type: gauge
@@ -15944,6 +16148,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalTxBiasCurrent
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.8
       type: gauge
@@ -15951,6 +16161,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalTxPower
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.9
       type: gauge
@@ -15958,6 +16174,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrOpticalRxPower
       oid: 1.3.6.1.4.1.14988.1.1.19.1.1.10
       type: gauge
@@ -15965,6 +16187,12 @@ modules:
       indexes:
       - labelname: mtxrOpticalIndex
         type: gauge
+      lookups:
+      - labels:
+        - mtxrOpticalIndex
+        labelname: mtxrOpticalName
+        oid: 1.3.6.1.4.1.14988.1.1.19.1.1.2
+        type: DisplayString
     - name: mtxrIkeSACount
       oid: 1.3.6.1.4.1.14988.1.1.20.1
       type: gauge
@@ -49214,4 +49442,3 @@ modules:
       indexes:
       - labelname: fanNumber
         type: gauge
-version: 2


Test patch:
diff --git a/collector/collector_test.go b/collector/collector_test.go
index a1a009d..818a870 100644
--- a/collector/collector_test.go
+++ b/collector/collector_test.go
@@ -1033,6 +1033,173 @@ func TestIndexesToLabels(t *testing.T) {
 	}
 }
 
+func TestConfigureTarget(t *testing.T) {
+	cases := []struct {
+		target     string
+		gTransport string
+		gTarget    string
+		gPort      uint16
+		shouldErr  bool
+	}{
+		{
+			target:     "localhost",
+			gTransport: "",
+			gTarget:    "localhost",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "localhost:1161",
+			gTransport: "",
+			gTarget:    "localhost",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{
+			target:     "udp://localhost",
+			gTransport: "udp",
+			gTarget:    "localhost",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "udp://localhost:1161",
+			gTransport: "udp",
+			gTarget:    "localhost",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{
+			target:     "tcp://localhost",
+			gTransport: "tcp",
+			gTarget:    "localhost",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "tcp://localhost:1161",
+			gTransport: "tcp",
+			gTarget:    "localhost",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{
+			target:     "[::1]",
+			gTransport: "",
+			gTarget:    "[::1]",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "[::1]:1161",
+			gTransport: "",
+			gTarget:    "::1",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{
+			target:     "udp://[::1]",
+			gTransport: "udp",
+			gTarget:    "[::1]",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "udp://[::1]:1161",
+			gTransport: "udp",
+			gTarget:    "::1",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{
+			target:     "tcp://[::1]",
+			gTransport: "tcp",
+			gTarget:    "[::1]",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "tcp://[::1]:1161",
+			gTransport: "tcp",
+			gTarget:    "::1",
+			gPort:      1161,
+			shouldErr:  false,
+		},
+		{ // this case is valid during parse but invalid during connect
+			target:     "tcp://udp://localhost:1161",
+			gTransport: "tcp",
+			gTarget:    "udp://localhost:1161",
+			gPort:      161,
+			shouldErr:  false,
+		},
+		{
+			target:     "localhost:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+		{
+			target:     "udp://localhost:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+		{
+			target:     "tcp://localhost:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+		{
+			target:     "[::1]:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+		{
+			target:     "udp://[::1]:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+		{
+			target:     "tcp://[::1]:badport",
+			gTransport: "",
+			gTarget:    "",
+			gPort:      0,
+			shouldErr:  true,
+		},
+	}
+
+	for _, c := range cases {
+		var g gosnmp.GoSNMP
+		err := configureTarget(&g, c.target)
+		if c.shouldErr {
+			if err == nil {
+				t.Fatalf("Was expecting error, but none returned for %q", c.target)
+			}
+			continue
+		}
+		if err != nil {
+			t.Fatalf("Error configuring target %q: %v", c.target, err)
+		}
+		if g.Transport != c.gTransport {
+			t.Fatalf("Bad SNMP transport for %q, got=%q, expected=%q", c.target, g.Transport, c.gTransport)
+		}
+		if g.Target != c.gTarget {
+			t.Fatalf("Bad SNMP target for %q, got=%q, expected=%q", c.target, g.Target, c.gTarget)
+		}
+		if g.Port != c.gPort {
+			t.Fatalf("Bad SNMP port for %q, got=%d, expected=%d", c.target, g.Port, c.gPort)
+		}
+	}
+}
+
 func TestFilterAllowedIndices(t *testing.T) {
 
 	pdus := []gosnmp.SnmpPDU{
diff --git a/testdata/snmp-auth.yml b/testdata/snmp-auth.yml
index d0b504e..78257dc 100644
--- a/testdata/snmp-auth.yml
+++ b/testdata/snmp-auth.yml
@@ -7,4 +7,3 @@ auths:
     auth_protocol: SHA256
     priv_protocol: AES
     priv_password: mysecret
-version: 2
diff --git a/testdata/snmp-with-overrides.yml b/testdata/snmp-with-overrides.yml
index bf11fda..160ba6c 100644
--- a/testdata/snmp-with-overrides.yml
+++ b/testdata/snmp-with-overrides.yml
@@ -9,4 +9,3 @@ modules:
       regex_extracts:
         Temp:
         - regex:
-version: 2