Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent support of IPv6 literals #1076

Open
candlerb opened this issue Dec 15, 2023 · 0 comments
Open

Inconsistent support of IPv6 literals #1076

candlerb opened this issue Dec 15, 2023 · 0 comments

Comments

@candlerb
Copy link
Contributor

candlerb commented Dec 15, 2023

Host operating system: output of uname -a

Linux prometheus 5.4.0-162-generic #179-Ubuntu SMP Mon Aug 14 08:51:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

snmp_exporter version: output of snmp_exporter -version

snmp_exporter, version 0.25.0 (branch: HEAD, revision: 9c42d6c874d479314e612bca69558c81f8e26287)
  build user:       root@880115266f70
  build date:       20231210-10:05:18
  go version:       go1.21.5
  platform:         linux/amd64
  tags:             netgo

What did you do that produced an error?

Supplying a target IPv6 literal with square brackets but without a port.

  • Works: curl -gvsS 'localhost:9116/snmp?target=2001:db8::1&module=if_mib&auth=public_v2'
  • Works: curl -gvsS 'localhost:9116/snmp?target=[2001:db8::1]:161&module=if_mib&auth=public_v2'
  • FAILS: curl -gvsS 'localhost:9116/snmp?target=[2001:db8::1]&module=if_mib&auth=public_v2'

The output in the latter case:

*   Trying 127.0.0.1:9116...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9116 (#0)
> GET /snmp?target=[2001:db8::1]&module=if_mib&auth=public_v2 HTTP/1.1
> Host: localhost:9116
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Fri, 15 Dec 2023 10:36:48 GMT
< Content-Length: 325
<
An error has occurred while serving metrics:

error collecting metric Desc{fqName: "snmp_error", help: "Error scraping target", constLabels: {module="if_mib"}, variableLabels: {}}: error connecting to target [2001:db8::1]: error establishing connection to host: dial udp: address [[2001:db8::1]]:161: missing port in address
* Connection #0 to host localhost left intact

Note the address [[2001:db8::1]]:161 - it looks like something has gone wrong when appending the default port.

Additional info

Discussion: https://groups.google.com/g/prometheus-users/c/xdaiJZqm8G4

blackbox_exporter seems to have the same problem with the dns_prober (at least), so there may be some code in a common library that needs fixing.

The string "missing port in address" doesn't exist in the snmp_exporter repository. It most likely comes from the go stdlib src/net/ipsock.go. Prometheus itself has code which tests for it:

./web/api/v1/api.go:	if err != nil && strings.HasSuffix(err.Error(), "missing port in address") {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant