Skip to content

How to install and configure Netdata

Last updated on March 13, 2019

Before we start we’ll make sure that we have the latest packages from the apt repository available to us, we’ll run this command…

sudo apt-get update

We can install the software simply by running the following command and accept the new packages that the installer will ask to install (DO NOT use sudo here, it’ll do it automatically if required!)

bash <(curl -Ss https://my-netdata.io/kickstart.sh)

The installer will prompt you to confirm the build and will advise of the file locations etc (shown below) – simply press return to accept them!

Once you have installed the software, you should then start the daemon and enable it to run at system boot using the following commands:

systemctl start netdata
systemctl enable netdata

By default, Netdata does not monitor Nginx, we need to enable a few things first, lets start by editing our Nginx configuration file and enabling the Nginx stub_status module…

vi /etc/nginx/sites-available/default

Paste the following block of code under the location /{} block:

location /stub_status {
        stub_status;
        allow 127.0.0.1;
        deny all;
}

Now save the file and exit Vim.

We now need to restart Nginx, we can do this by running the following command:

service nginx restart

Assuming all went well, you should now be able to use cURL on the server and “hit” the stub_status endpoint, if it succeeded it means that the Nginx stub_status module is now enabled in Nginx and we can move on…

curl http://127.0.0.1/stub_status

Next up we need to tell Netdata about the Nginx stub_status module, we do this by editing one of Netdata’s configuration files, type the following command:

vi /etc/netdata/python.d/nginx.conf

If the following code block does not exist in the file, add it!

localhost:
  name : 'local'
  url  : 'http://localhost/stub_status'

Finally, save the file and then restart the netdata daemon like so:

systemctl restart netdata

You should now be able to access the monitoring dashboard using the following URL (if you’re using a firewall (which you should be ;)) please ensure you’ve added TCP 19999 to the allowed ports):

http://{your-server-hostname-or-ip-address}:19999/

Configure firewall

ufw allow ssh
ufw allow http
ufw allow https
ufw allow 19999/tcp

Configure nginx

Add to nginx.conf to the http section

log_format netdata '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'$request_length $request_time $upstream_response_time "$host" '
'"$http_referer" "$http_user_agent"';

Find access_log /var/log/nginx/access.log; in the same section, replace it with access_log /var/log/nginx/access.log netdata;

Restart nginx.service
Restart netdata.service
Published inLinuxShell