chef-datadog icon indicating copy to clipboard operation
chef-datadog copied to clipboard

Incorrect Hostname in datadog.yaml file

Open vpilania opened this issue 3 years ago • 4 comments

Hi I'm using chef-client 12.22.1 on Amazon Linux AMI release 2018.03 to install datadog-linux-agent v7 via latest chef-cookbook. I'm seeing that in the datadog.yaml, the hostname when I leave it to autodetect it's not picking up the instance-id but "Name" of the AWS instance

How to fix that?

vpilania avatar Jun 11 '21 16:06 vpilania

Hi @vpilania,

Can you confirm that, in datadog.yaml, the hostname: field is not specified or has an empty value?

If so, then the cookbook works as expected to make the Agent autodetect its hostname, so please open a case with our support team and send them a flare so that our support team has all the necessary information to look into your issue.

Thanks!

olivielpeau avatar Jun 14 '21 11:06 olivielpeau

hostname: field is not empty when I run but captures Name of the instance and not for example 'i-abcw123eqe' which I expect!

vpilania avatar Jun 14 '21 11:06 vpilania

The default behavior of this cookbook is to set the agent hostname to the Chef node name (node['datadog']['hostname'] = node.name, see default attribute). To set the agent hostname to the AWS instance ID, you can override this default to node.ec2.instance_id, for example with:

 default_attributes(
   'datadog' => {
     'hostname' => node.ec2.instance_id,
     'use_ec2_instance_id' => true
   }
 )

('use_ec2_instance_id' => true is also set here so that the Chef Datadog Handler, if enabled, reports tags, metrics and events using the instance ID as the hostname as well).

Let me know if this solves your issue, thanks.

olivielpeau avatar Jun 14 '21 11:06 olivielpeau

image

I'm getting this problem in which hostname is getting registered with two different instance-id out of which one is correct....not sure where it is picking up this - i-00aa96d1c9d27da57 which is incorrect......why would that happen?

vpilania avatar Jun 23 '21 12:06 vpilania