dd-agent
dd-agent copied to clipboard
[dogstatsd] Hostname ignored for ecs hosts
We are running a set of ecs clusters; 2 per env
In alerts the {{host.name}} is simple resolving to the ec2 id (eg i-0123456789abcdef0)
To give a clearer idea of which cluster and env the alert is coming from I tried setting some non standard hostnames: {cluster_name}-{ec2-id}.{domain}
None of these are getting passed by the datadog agent. It appears the problem is Platform.is_ecs_instance()
in this line
Is there a reason for not allowing ecs hosts to use non standard hostnames?
Thanks for reaching out, and sorry for the delay in reply.
We introduced this shortly after Amazon launched ECS, as we found that in many cases ECS exposed inconsistent hostnames to containers. Sometimes it was the hostname of the host and sometimes the instance id. So we hard-coded it to one of the two based on customer feedback at the time.
While it looks like ECS has now improved its hostname logic to address this issue, reverting the behavior now would be a breaking change for a large number of users who rely on this behavior in their alerts. We are currently evaluating whether to remove this logic in the next major release though.
In the mean time for users who prefer to alter the hostname, we allow configuration of the hostname directly in datadog.conf. The most popular way to do this in docker is via environment variables as demonstrated in this example here.
I hope this helps, let us know if you have any further questions.