@@ -102,6 +102,13 @@ func handler(w http.ResponseWriter, r *http.Request, logger log.Logger, exporter
102
102
authName = "public_v2"
103
103
}
104
104
105
+ snmpContext := query .Get ("snmp_context" )
106
+ if len (query ["snmp_context" ]) > 1 {
107
+ http .Error (w , "'snmp_context' parameter must only be specified once" , http .StatusBadRequest )
108
+ snmpRequestErrors .Inc ()
109
+ return
110
+ }
111
+
105
112
queryModule := query ["module" ]
106
113
if len (queryModule ) == 0 {
107
114
queryModule = append (queryModule , "if_mib" )
@@ -141,7 +148,7 @@ func handler(w http.ResponseWriter, r *http.Request, logger log.Logger, exporter
141
148
sc .RUnlock ()
142
149
logger = log .With (logger , "auth" , authName , "target" , target )
143
150
registry := prometheus .NewRegistry ()
144
- c := collector .New (r .Context (), target , authName , auth , nmodules , logger , exporterMetrics , * concurrency )
151
+ c := collector .New (r .Context (), target , authName , snmpContext , auth , nmodules , logger , exporterMetrics , * concurrency )
145
152
registry .MustRegister (c )
146
153
// Delegate http serving to Prometheus client library, which will call collector.Collect.
147
154
h := promhttp .HandlerFor (registry , promhttp.HandlerOpts {})
0 commit comments