Closed thenodon closed 1 year ago
In the general case, I'm not hugely convinced of the need for this. You can achieve the same by exposing some data via the node-exporter files plugin that can then be joined with the data scraped from the snmp_exporter at query time. A certain amount may also be achievable prom side via metric relabel rules.
On the specifics of the PR, I'm not overly keen on the syntax used. extended_labels
feels like it appears in too many places, and having the config in a separate file seems like overkill (if your automation can generate that file, it can generate the expexp config).
If I'm missing something, and this can't be achieved by providing info style metrics, then I'd suggest it is more suitable to being it's own tool.
Hi @tcolgate and thanks for your answer. I have looked into the solutions you mention but I do not see it as an option. This is environment with approx 5000 network devices. Using some method to create relabeling rules for a specific device and its interface indexes would create a prometheus monster config. Using a proxy solution, I think, is the best option since it operates on the data in transit, but I full respect that you think its not in scope for exporter_exporter.
You are right that the extended_labels
is used twice - that is an easy fix of course, like generate it into a single expexp.yml config file. I just wanted to keep it separated since I did not know your preferences. The info styling might be possible but joining over log time intervals makes the queries vary slow, compared to enrich metrics directly. This also enable that interfaces, in our use cases, can easily be dropped with metric relabeling, since approx 20 % of all interfaces are of interest from a monitoring perspective.
I'm totally fine with forking, I just wanted to check first.
Inserting labels on metrics based on label name and label value
This PR is maybe out of scope for what you think exporter_exporter is targeted for, but I have a use case where I need to insert additional labels based on existing labels, matching by the label name and label value. This use case is specific to the snmp_exporter, but should be applicable for any exporter that is configured as a proxy.
In this use case we need, for a specific target and interface(s), add additional labels. The source of this information would be a type of discovery, for example a source like a network management system. Just using Prometheus discovery will not be enough since we can only create discovery based labels on the target and not for specific "individuals" that are defined by a label name and label value, like an interface index.
I have called the the additional logic to the exporter_exporter "extended labels". In the expexp.yaml the following 3 additional parameters needs to be configured to achieve this.
label_extend
set to true just enable the feature for the module. The second ,label_extend_target_url_identity
, define what target the extended labels should be match against. For the snmp-exporter the url parametertarget
define the host that snmp should be executed against. The third,label_extend_path
, define the path to the extended labels configuration, typical created by some automation.The configuration, defined by
label_extend_path
has the following format, using an example that is applicable, but not limited, to the snmp-exporter use case:So
extended_labels
include a map of targets, in the above example a host name. The entry is matched against the value of the url query parameter defined bylabel_extend_target_url_identity
. So if a metrics has a label namedifIndex
, defined bylabel_key_name
, the logic will evaluate against what is configured in theextended_labels
. First it will validate if this is only applicable to specific named metrics, for exampleifOperStatus
. Themetric_match
value is a regular expression and default to.*
if not defined. Thematch_label_key_values
define what label value to match against. In the first entry the match is done against all values,*
ofifIndex
and a label calledtype
with valuel2switch
is added. In the second entry, both the metrics namedifOperStatus
andifAdminStatus
is matched, but labels,trunk
andendpoint
, are only added for metrics whereifIndex
has the value of370
or371
.Most of the logic is in the function
getLabelExtendReverseProxyModifyResponseFunc
in the http.go file. This function is used instead ofgetReverseProxyModifyResponseFunc
iflabel_extend
is set to true.I also added watcher.go that manage dynamic reload of the file defined by
label_extend_path
.I have not updated README.md, but will if you think this PR is applicable for exporter_exporter.
I can fully understand if this functionality is something you find out of scope for the exporter_exporter. If this is the case I hope it would be okay if I create a separate repo for this with the credits to exporter_exporter and the additional code using the same license as exporter_exporter.