Watchlog Agent Installation Guide
This guide will walk you through the steps to install and run the Watchlog Agent on your server.
The Watchlog Agent is a Node.js application designed to collect and send server metrics to Watchlog.
Please follow the steps below to get started.
Ubuntu
Source (Other Servers)
How to install Watchlog on Ubuntu Server?
Installation
Install the Watchlog Agent with the following script:
Replace your-api-key and your-server with your actual Watchlog API key and server from your Dashboard.
sudo apiKey="your-api-key" server="your-server" MEMORY="300MB" bash -c "$(curl -L https://watchlog.io/ubuntu/watchlog-script.sh)"
Copy
MEMORY: This environment variable sets the maximum memory limit for the Watchlog Agent managed by PM2. The default is 300MB, but if your server has more available memory or your agent requires more memory, you can increase this value (e.g., MEMORY="500MB").
Managing the Agent

The Watchlog Agent is managed using PM2 via the systemd service watchlog-agent.service. Use the following PM2 commands to control your agent:

  • Start the agent:
    pm2 start watchlog-agent
    Copy
  • Reload the agent:
    pm2 reload watchlog-agent
    Copy
  • Stop the agent:
    pm2 stop watchlog-agent
    Copy
  • Remove the agent:
    pm2 stop watchlog-agent
    Delete the agent directory:
    sudo rm -rf /opt/watchlog-agent
    Remove the systemd service file:
    sudo rm /etc/systemd/system/watchlog-agent.service
    Reload systemd:
    sudo systemctl daemon-reload
Note: The Watchlog Agent is managed by PM2. If the agent exceeds the memory limit (default: 300MB, configurable via the MEMORY variable), PM2 will automatically restart it.
After installing the agent on the server. You must connect to it in code. You can do this through the following packages :
Nodejs
Python
Php
Java
INSTALLATION
$ npm install watchlog-metric
Usage