elastic / apm

Elastic Application Performance Monitoring - resources and general issue tracking for Elastic APM.
https://www.elastic.co/apm
Apache License 2.0
384 stars 114 forks source link

Change default APM server_url to 'http://127.0.0.1:8200' to avoid IPv6 ambiguity #727

Closed trentm closed 1 year ago

trentm commented 1 year ago

The current default APM server URL -- 'http://localhost:8200' -- is ambiguous. "localhost" can resolve to a '127.0.0.1' (IPv4) or '[::1]' (IPv6).

At least in Node v17 the default dns.lookup() ordering of results was changed to no longer explicitly sort IPv4 addresses first. That means that on systems where the default resolver returns '[::1]' first for "localhost" will result in a broken attempt to talk to a default-configured local APM server: https://github.com/elastic/apm-agent-nodejs/issues/3045 This is because APM server only binds to the IPv4 port: https://github.com/elastic/apm-server/issues/1405

Checklist

/schedule 2022-12-13

apmmachine commented 1 year ago

:green_heart: Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

#### Build stats * Start Time: 2022-12-12T04:33:00.395+0000 * Duration: 3 min 16 sec

SergeyKleyman commented 1 year ago

Is it possible for the system to be IPv6 only or less drastic case when list of addresses to which localhost resolves does not include 127.0.0.1?

trentm commented 1 year ago

(Sorry for not having opened this as draft to start.)

trentm commented 1 year ago

Is it possible for the system to be IPv6 only or less drastic case when list of addresses to which localhost resolves does not include 127.0.0.1?

IPv6-only is likely possible yes. I’ve no encountered it. I think it would be rare, but am not sure.

I can try to look at the Go lang docs to see if we think APM server would even listen on the IPv6 localhost by default in that case.

Re: ‘localhost’ not resolving to 127.0.0.1. Oof, I would think that would be very unlikely but possible. I am not sure if some RFC has a “MUST” statement about “localhost” resolving so. If some user had this case, I am not sure we would feel the need to have the default agent and server configs successfully reach each other. I may be missing a legitimate use case though?

z1c0 commented 1 year ago

The change makes sense 👍 .

(On a side note, I'm just wondering though:

trentm commented 1 year ago
  • how many applications will be impacted by this change of behavior in Node v17?

@z1c0 Possibly a lot. Here is the core node issue, which shows a number of incoming links from impacted projects. Also the links in that issue's description point to a number of back issues related to this.

  • why APM Server binds only to IPv4?

There is some discussion in https://github.com/elastic/apm-server/issues/1405 I suspect it is mainly just because that's what Go lang's native net library works and just binding to IPv4 has always mostly been fine.

Interestingly https://pkg.go.dev/net#Listen says:

The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses.

So it might be worth asking APM Server devs. I'll ask separately.

trentm commented 1 year ago

APM server will be making the same change in https://github.com/elastic/apm-server/issues/9749