Installing mackerel-agent in Amazon Linux

The content described on this page is also available from the New Host registration screen in Mackerel.

Install the package

Execute the following command:

curl -fsSL https://mackerel.io/file/script/amznlinux/setup-all-yum-v2.sh | MACKEREL_APIKEY='<YOUR_API_KEY>' sh

You can check the API key from the Organization page’s API Keys tab. Keep in mind that this key is used to identify your organization, so we strongly advise not sharing it with others.

Updates can be performed using the yum command.

sudo yum update mackerel-agent

Installation can also be done directly using the rpm command.

Using the rpm command

To install mackerel-agent with rpm run the following command:

sudo rpm -ivh https://mackerel.io/file/agent/rpm/mackerel-agent-latest.amzn2.x86_64.rpm

To update Mackerel-agent with rpm run the following command:

sudo rpm -Uvh https://mackerel.io/file/agent/rpm/mackerel-agent-latest.amzn2.x86_64.rpm

Edit the configuration file

Edit the /etc/mackerel-agent/mackerel-agent.conf file to configure the agent.

By using the configuration file, the following can be implemented:

For more details, check out the mackerel-agent specifications help page.

Please be sure to configure the API key if installed from rpm. This is done automatically if set up with the setup script.

apikey = "<YOUR_API_KEY>"

You can check the API key from the Organization page’s API Keys tab. Keep in mind that this key is used to identify your organization, so we strongly advise not sharing it with others.

Starting the agent

The agent will start by running the following command:

sudo systemctl start mackerel-agent

The log is output to Journal. You can check the mackerel-agent log with the following command.

sudo journalctl -u mackerel-agent.service

When the agent begins to run properly, it will be registered as a host in Mackerel. Please confirm this in dashboards etc.

Uninstall the agent

To uninstall mackerel-agent, run the following command.

sudo yum erase mackerel-agent

By doing so, a file with the host ID documented will remain (at /var/lib/mackerel-agent/id under default settings), so please make sure to delete it.