Skip to content

instance: only look the FQDN up in beat receivers when features.fqdn is enabled - #53727

Merged
shahzad31 merged 2 commits into
elastic:mainfrom
shahzad31:shahzad/receiver-fqdn-startup
Nov 2, 2026
Merged

shahzad31 merged 2 commits into
elastic:mainfrom
shahzad31:shahzad/receiver-fqdn-startup

Conversation

@shahzad31

@shahzad31 shahzad31 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Proposed commit message

instance: only look the FQDN up in beat receivers when features.fqdn is enabled

NewBeatForReceiver looks the host FQDN up once per process with a one minute
timeout, whether or not features.fqdn is enabled. When the DNS server does not
answer for the host name, the lookup always waits for the whole minute, and
every receiver waits for it because they share the result.

Info.FQDN is only read through FQDNAwareHostname, when features.fqdn is
enabled. Receivers only get the feature flags from their own config, which is
read before the lookup, so skip the lookup when the feature is disabled and
set Info.FQDN to the hostname. Keep the one minute timeout when the feature is
enabled, the same as add_host_metadata, so the two keep agreeing on the FQDN.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. With features.fqdn disabled the FQDN was never read. With it enabled the lookup and its timeout are unchanged.

Standalone beats are not changed. Under Elastic Agent they can switch features.fqdn at runtime through the V2 manager without running init again, so they still need the FQDN looked up up front.

How to test this PR locally

go test -count=1 -race -run TestReceiverFQDNLookupFollowsFeatureFlag ./x-pack/libbeat/cmd/instance/

End to end: on a host whose DNS server does not answer for the host name, start a beat receiver (for example the Heartbeat receiver under Elastic Agent) with features.fqdn disabled. The receiver starts right after "Beat ID" instead of a minute later, and logs no "unable to lookup FQDN" warning.

Related issues

Use cases

Collectors and agents on hosts with a slow or unreachable DNS server start their beat receivers a minute earlier when features.fqdn is disabled, which is the default.

Logs

N/A

NewBeatForReceiver looks the host FQDN up once per process, with a one minute
timeout. When the lookup cannot succeed, for example because the DNS server
does not answer for the host name, it always waits for the whole timeout, and
every receiver waits for it because they share the result. On such a host the
collector started 60s after the agent started it, before running any check.

The lookup is best effort: on failure the receiver falls back to the OS
hostname. Lower the timeout to 5s so a failing lookup costs 5s instead of 60s.
A working lookup takes milliseconds and is not affected, a lookup slower than
5s now falls back to the hostname instead of waiting for the answer.
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2026
@shahzad31 shahzad31 added Heartbeat and removed needs_team Indicates that the issue/PR needs a Team:* label labels Oct 13, 2026
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@mergify

mergify Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @shahzad31? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

…is enabled

Info.FQDN is only read through FQDNAwareHostname, when features.fqdn is
enabled. NewBeatForReceiver looked the FQDN up regardless, so on a host whose
DNS server does not answer for the host name every receiver waited a minute
for a value nothing used.

Receivers only get the feature flags from their own config, read before the
lookup, so skip the lookup when the feature is disabled and set Info.FQDN to
the hostname. Keep the one minute timeout when the feature is enabled, the
same as add_host_metadata, so the two keep agreeing on the FQDN.
@shahzad31 shahzad31 changed the title instance: bound the FQDN lookup of beat receivers to 5 seconds instance: only look the FQDN up in beat receivers when features.fqdn is enabled Nov 2, 2026
@shahzad31
shahzad31 marked this pull request as ready for review November 2, 2026 13:51
@shahzad31
shahzad31 requested a review from a team as a code owner November 2, 2026 13:51
@shahzad31
shahzad31 requested a review from rdner November 2, 2026 13:51
@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@shahzad31
shahzad31 merged commit aec0f2d into elastic:main Nov 2, 2026
135 checks passed
@shahzad31
shahzad31 deleted the shahzad/receiver-fqdn-startup branch November 2, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Heartbeat needs_team Indicates that the issue/PR needs a Team:* label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OTel] FQDN lookup delays the start of beat receivers by up to a minute

3 participants