Hostname

The hostname is the official name (canonical hostname) that the Datadog Agent uses to identify itself to Datadog. The Agent gathers candidates from its configuration file, DNS, and EC2 information, picks one in a fixed order, and sends the rest as aliases.

Overview

Even for the same machine there are several candidate names: the name written in the configuration, the DNS name, the EC2 instance ID, and so on. What Datadog treats as one host is the single name chosen as the canonical one, and it is also through this name that the host's tags are carried over to metrics and logs. It is the concept to keep in mind when the same machine appears twice in a list, when an Agent update or configuration change looks likely to change the name, and when you run the Agent from a container.

There is one canonical name, and the other names become aliases

The Agent gathers name candidates from several sources and lists them in the Hostnames field of agent status. These are rows such as hostname, agent-hostname, ec2-hostname, and instance-id (Source: How does Datadog determine the Agent hostname?). It picks one of them as the canonical name to identify itself to Datadog and sends the remaining names as alias candidates. How the host's tags are carried over to data is left to Host.

Candidates are tested against four rules from the top down

The canonical name is decided by applying the following rules from the top and taking the first one that matches (as of October 2026; Source: How does Datadog determine the Agent hostname?).

  • A name set explicitly in the Agent's configuration file (agent-hostname), excluding names that begin with ip- or domu
  • The DNS hostname (on Linux, hostname -f), as long as it is not in the EC2 default form such as ip-192-0-0-1
  • The instance ID, if the host can reach the EC2 metadata
  • If none of these match, the DNS hostname even in the EC2 default form
Source: the Potential host names section of How does Datadog determine the Agent hostname? (as of October 2026)

A name judged not to be unique, such as localhost.localdomain, makes that rule fail and moves on to the next rule. If you want to pin the name by hand, a name in the configuration file or the environment variable DD_HOSTNAME, which falls under the first rule, is the strongest, and it is not affected even if an Agent update changes the resolution method. The official documentation also has an example where an update changed an FQDN to a short name, and it recommends setting hostname_fqdn, which keeps the name, to true whenever possible (as of October 2026). How to write the configuration key is left to the datadog.yaml entry.

Why does one EC2 instance look like two?

When you run Kubernetes on EC2 or EKS, the same machine can appear as two hosts. One is the name the Agent identified itself with, and the other is the instance-id collected by the AWS integration (Source: Duplicate hosts with Kubernetes on AWS (EC2 or EKS)). Normally the Agent takes the instance-id from the EC2 metadata and sends it as an alias, merging the two into one host. If it cannot reach the metadata, the alias is not sent, and the two stay separate. The fix is to open the path to the metadata (as of October 2026). In environments that allow only IMDSv2, either use Agent 7.64.0 or later, which uses IMDSv2 by default, or on earlier versions set DD_EC2_PREFER_IMDSV2 to true, and raise the hop limit from 1 to 2. The steps on the AWS side are left to Setting up the AWS integration.

Aliases cannot be found from the search bar

Aliases appear only in the panel opened from the Inspect button on a host's row in the Infrastructure List. They cannot be used for searching or filtering (as of October 2026; Source: How does Datadog determine the Agent hostname?). Entering an instance-id in the search bar fails to hit the intended host when that name has been assigned as an alias rather than the canonical name. When searching the list, filter by the canonical name or by tags attached to the host. On the log side as well, the reserved Attribute host receives the name defined in the metrics, and Datadog attaches to the log the tags of the host that matches that name (Source: Attributes and Aliasing).

Start reading from the Hostnames field of agent status

The unit of host counted for billing is left to Host. For most problems that arise on the name side, comparing the candidates the Agent found with the canonical name it chose tells you where the problem is. For an Agent running on EC2, first check whether there is an instance-id row in the Hostnames field of agent status. If there is no such row, it has not reached the metadata, and the conditions for the same machine to split into two with the AWS integration are in place. One way to proceed is to put the hostname row in the Hostnames field next to the name shown in the Infrastructure List, and if they differ, apply the four rules again from the top to see which one decided it.

Share