16.04.2023

Introduction§ 

Netdata is a server monitoring tool. It produces both graphs to visualize a system’s status and an endpoint to fetch data using Grafana, Prometheus…

Installation§ 

The official installation instructions are available here. However, I wanted to install Netdata using my package manager, and not the one-liner script, so I will detail below what I’ve done. These instructions have been tested on a Fedora server. The installation is quite simple :

sudo dnf install netdata
sudo systemctl start netdata
sudo systemctl enable netdata

The webserver visualization will then be available on http://localhost:19999.

Configuration§ 

The following assumptions are made :

Collecting data with Prometheus§ 

Nginx configuration§ 

This documentation describes how to run Netdata behind a Nginx proxy.

We will thus create an Nginx site configuration file in /etc/nginx/sites-available/netdata-servername.example.net.conf.

upstream netdata {
    # the Netdata server
    server 127.0.0.1:19999;
    keepalive 64;
}

server {
	server_name netdata-servername.example.net;

	location / {
		auth_basic "Protected";
		auth_basic_user_file passwords.d/netdata;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header Forwarded         $proxy_add_forwarded;
		proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Forwarded-Host  $host;
		proxy_set_header X-Forwarded-Server $host;
		proxy_set_header X-Forwarded-Port  $server_port;

		index index.php;
		proxy_pass http://netdata/;
		proxy_http_version 1.1;
		#proxy_redirect off;
		#try_files $uri $uri/ /index.php =404;
        	proxy_pass_request_headers on;
        	proxy_set_header Connection "keep-alive";
        	proxy_store off;
	}

}
server {


	server_name netdata-servername.example.com;
    listen 80;


}

The file in /etc/nginx/passwords.d/netdata will contain the authentication credentials to access Netdata. We will create it using the following command, replacing <username> with the username of your choice. There will then be a prompt for your password.

sudo printf "<username>:$(openssl passwd -apr1)" > /etc/nginx/passwords.d/netdata

Once done, we can enable the site. We first need to symlink the config file from /etc/nginx/sites-available/ in /etc/nginx/sites-enabled/ : ln -s /etc/nginx/sites-available/netdata-servername.example.net.conf /etc/nginx/sites-enabled/. Then we reload Nginx using nginx -s reload.

The current configuration lacks TLS support, so we’ll add it using Certbot from Let’s Encrypt : sudo certbot --nginx.

You can now browse to netdata-servername.example.net and log in using the credentials you’ve chosen above.

Prometheus configuration§ 

You may want to follow the official documentation, but as always, below is the configuration snippet required to collect the data with Prometheus.

scrape_configs:
  - job_name: 'netdata servername'
    metrics_path: '/api/v1/allmetrics'
    params:
      format: [prometheus_all_hosts]
    honor_labels: true
    scrape_interval: 5s
    basic_auth:
      username: <username>
      password: <password>
    scheme: https # because we have used Certbot on Netdata
    static_configs:
      - targets: [ 'netdata-servername.example.net' ]

After restarting Prometheus, you should be getting your metrics !