prometheus / prometheus

The Prometheus monitoring system and time series database.
https://prometheus.io/
Apache License 2.0
54.76k stars 9.02k forks source link

Cosmetic bug when scraping IPv6 addresses containing double colons :: #8623

Open aned opened 3 years ago

aned commented 3 years ago

In v2.23.0 when I have a scraping endpoint IPv6 address such as 2a03:f347:40:1::4f, I see an error on the web UI

Error: Failed to construct 'URL': Invalid URL

: address 2a03:f347:40:1::6d:9100: too many colons in address

The scrape does happen and the "State" is showing as up.

roidelapluie commented 3 years ago

I think this was fixed in 2.25 (#8359).

Can you please upgrade to 2.25.2 and verify the fix?

Thanks!

aned commented 3 years ago

Just checked, 2.25.2 still has this issue.

image

Zheaoli commented 3 years ago

I think I have figured out the reason

In IPV6, the host:port syntax has been changed. Here's the detail in rfc3986

A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax. In anticipation of future, as-yet-undefined IP literal address formats, an implementation may use an optional version flag to indicate such a format explicitly rather than rely on heuristic determination.

So "xxx:xx:xx:xx:port" is not right, it will cause error here https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go#L795

I'll try to make a PR for this.

roidelapluie commented 3 years ago

I am surprised that Prometheus can scrape 2a03:f347:40:1::6d:9100 in the first place. It should scrape [2a03:f347:40:1::6d]:9100.

Zheaoli commented 3 years ago

@roidelapluie yes, I'm surprised there's not error when Go access the 2a03:f347:40:1::6d:9100 too.

Anyway, I'm working on a PR for this issue

Zheaoli commented 3 years ago

@aned Hello, Would you mind introducing what's kind of discovery method you use?

I think it will help to find out the root cause?

aned commented 3 years ago

@Zheaoli we query internal DB and generate yaml files for prometheus.

roidelapluie commented 3 years ago

It seems like the yaml generated by the DB is not correct. However, we should still fix this in the UI if Prometheus can actually scrape it.

giladneiger commented 2 years ago

Also facing problems with scraping most of IPv6 (pods on Kubernetes) addresses.

AlbanBedel commented 2 years ago

With the right syntax scrapping is working for me on version 2.31.1, but the web interface still shows an error in the targets list:

Error: URL constructor: http://[fe80::1c33:5ff:fe06:92fc%25enx8c04ba675c4c]:9100/metrics is not a valid URL.
beorn7 commented 3 months ago

Hello from the bug scrub.

We believe that this is still not fixed. Should be an easy contribution.