How to get rid of extra url characters at the end of prometheus targets url

20 views
Skip to first unread message

Hamed

unread,
Apr 9, 2020, 5:01:13 PM4/9/20
to Prometheus Users
I have configured snmp exporter in prometheus. In prometheus targets page, when the target url for one of my snmp metrics pages is clicked, it loads the url for each target with an extra %3A9116 at the end: http://10.230.x.x:9116/snmp?module=if_mib&target=10.146.x.x%3A9116. Not sure how to get rid of it so it loads the proper metrics page. Is there an issue with my relabel configs in prometheus.yml:

  - job_name: 'snmp_exporter'
    scrape_interval: 30s
    file_sd_configs:
    - files:
      - 'snmp_targets.json'
    metrics_path: /snmp
    params:
      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.230.x.x:9116  # The SNMP exporter's real hostname:port.

Brian Candler

unread,
Apr 10, 2020, 3:23:18 AM4/10/20
to Prometheus Users
%3A is the URL-encoding for a colon (ASCII code hex 3A = decimal 58)

So your URL includes "target=10.146.x.x:9116", encoded because colon is a character with special significance in URLs.

And in turn, I would guess that your snmp_targets.json includes entries of the form "10.146.x.x:9116".  So to get rid of them, simply edit that file and remove all the :9116 suffixes, which shouldn't be there.

Reply all
Reply to author
Forward
0 new messages