Using AWS EC@ User-data on templated instance launch...service fails

Hi there,

I’m using aws ec2 instance template, with user-data cloud-init to run the wget add node agent script. It works well manually, but per the log from cloud-init, the claim is successful yet upon instance launch the service is in failed state. Seems like the agent does get added to the cloud dashboard which is odd.

I think the kickstater.sh script is having trouble setting “home”.

Does anyone do this or have an automated way to run the agent addition to the cloud dashboard?

I’m not sure we’ve done it this way ourselves, I’ll ask one of our SREs to see if they can help. Because it’s already weekend for them though, it may take a couple of days for a response.

In the meantime, can you provide any relevant info from the following?

If you can get the instance’s /var/log/netdata/error.log lines that contain “aclk” it would also help with the debugging.

I assume you just entered the wget command under the runcmd section, right?

Ther is no /var/log/netdata directory…and the service per systemctl status netdata is in failed state.

The HOME doesn’t get set, not sure if that is an issue? Tried Dumping full log from cloud-init-output and last line has “cant find home”, but this chat complaining.

Also, per the log the claim succeeds

/tmp/netdata-kickstart.sh: line 398: cd: HOME not set

Also, In the launch template there is a section for “user-data” I added shebang then the wget command

We can’t seem to be able to replicate the behavior. The following is from @Witold_Duranek, maybe you can try exactly the same :

I’ve made a test launching ubuntu 20.04 in AWS, with user data like this:

#!/bin/bash
wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh

and it finished without any issues:

root@ip-10-40-48-81:/etc/apparmor.d# tail -n 12 /var/log/cloud-init-output.log
Successfully installed the Netdata Agent.

Official documentation can be found online at https://learn.netdata.cloud/docs/.

Looking to monitor all of your infrastructure with Netdata? Check out Netdata Cloud at https://app.netdata.cloud.

Join our community and connect with us on:
  - GitHub: https://github.com/netdata/netdata/discussions
  - Discord: https://discord.gg/5ygS846fR6
  - Our community forums: https://community.netdata.cloud/
Cloud-init v. 22.2-0ubuntu1~20.04.3 running 'modules:final' at Mon, 05 Dec 2022 07:17:36 +0000. Up 23.60 seconds.
Cloud-init v. 22.2-0ubuntu1~20.04.3 finished at Mon, 05 Dec 2022 07:18:08 +0000. Datasource DataSourceEc2Local.  Up 55.45 seco

Thanks Christopher. Does this actually claim the agent? I was trying to include the token for the claim.