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

Amazon Linux and Amazon Linux 2 LTS run different commands for installation. Please check out each procedure. Installation can also be done directly using the rpm command.

When using Amazon Linux 2 LTS

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.

When using Amazon Linux

Execute the following command:

curl -fsSL https://mackerel.io/file/script/amznlinux/setup-all-yum.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.

Using the rpm command with Amazon Linux 2 LTS

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

Using the rpm command with Amazon Linux

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

sudo rpm -ivh https://mackerel.io/file/agent/rpm/mackerel-agent-latest.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.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

When using Amazon Linux 2 LTS

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.

When using Amazon Linux

The agent will start by running the following command:

sudo /sbin/service mackerel-agent start

The agent’s log is output to /var/log/mackerel-agent.log.

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.