DEV Community

Cover image for Deploying Netdata Open-Source Infrastructure Monitoring Platform
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Deploying Netdata Open-Source Infrastructure Monitoring Platform

Netdata is an open-source monitoring system for Linux-based operating systems that provides real-time performance monitoring through dashboards updating every second, with collectors for CPU, memory, processes, disk usage, IPv4 and IPv6 networks, the system firewall, and applications such as Nginx, MySQL, MongoDB, Redis, Elasticsearch, PostgreSQL, and PHP-FPM. It also integrates with tools such as Prometheus, Graphite, Kafka, and Grafana. This guide deploys Netdata on a Linux server using Docker Compose with a Traefik reverse proxy for TLS termination, then configures its basic settings. By the end, you'll have a Netdata dashboard served over HTTPS behind basic authentication, tuned for cache size, update frequency, and enabled plugins.


Prerequisites


Set Up the Directory Structure, Configuration, and Environment Variables

The project directory holds the Docker Compose file, Netdata configuration, and environment variables. The Netdata dashboard does not offer authentication by default, so this deployment adds HTTP authentication in front of it and stores the credentials in the .env file.

1. Create the project directory and enter it:

$ mkdir ~/netdata-docker
$ cd ~/netdata-docker
Enter fullscreen mode Exit fullscreen mode

2. Create a directory for Netdata configuration:

$ mkdir netdata-config
Enter fullscreen mode Exit fullscreen mode

3. Install the apache2-utils package, which provides the htpasswd utility:

$ sudo apt install apache2-utils -y
Enter fullscreen mode Exit fullscreen mode

4. Generate the credentials to be used in the .env file:

$ htpasswd -n netdataadmin
Enter fullscreen mode Exit fullscreen mode

The command prompts you to enter and confirm the password for the netdataadmin user, which you use to access the dashboard. It then prints a single line in the netdataadmin:HASH format. Copy the output.

5. Create a .env file:

$ nano .env
Enter fullscreen mode Exit fullscreen mode

6. Add the following configuration:

DOMAIN=netdata.example.com
LETSENCRYPT_EMAIL=admin@example.com
TRAEFIKADMIN='netdataadmin:$apr1$F.lvKJ8G$.Khv7IaXl6DGMZNiW2HlZ/'
Enter fullscreen mode Exit fullscreen mode

Replace:

  • netdata.example.com with your domain
  • admin@example.com with your email
  • netdataadmin:$apr1$F.lvKJ8G$.Khv7IaXl6DGMZNiW2HlZ/ with the output from the htpasswd utility

Save and close the file. Keep the single quotes around the TRAEFIKADMIN value. They prevent Docker Compose from treating the $ characters in the password hash as variables.


Deploy with Docker Compose

The Docker Compose file runs the Netdata service and uses various mounts to monitor the host server. Traefik acts as a reverse proxy.

1. Create the Docker Compose configuration file:

$ nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

2. Add the following configuration:

services:
  traefik:
    image: traefik:v3.7.12
    container_name: traefik
    networks:
      - proxy
    command:
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
      - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "./letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    restart: unless-stopped

  netdata:
    image: netdata/netdata:v2.13.0
    container_name: netdata
    hostname: netdata
    pid: host
    environment:
      - DISABLE_TELEMETRY=1
    networks:
      - proxy
    restart: unless-stopped
    cap_add:
      - SYS_PTRACE
      - SYS_ADMIN
    security_opt:
      - apparmor:unconfined
    volumes:
      - ./netdata-config:/etc/netdata
      - netdata-lib:/var/lib/netdata
      - netdata-cache:/var/cache/netdata
      - /:/host/root:ro,rslave
      - /etc/passwd:/host/etc/passwd:ro
      - /etc/group:/host/etc/group:ro
      - /etc/localtime:/etc/localtime:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /etc/os-release:/host/etc/os-release:ro
      - /var/log:/host/var/log:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /run/dbus:/run/dbus:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.netdata.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.netdata.entrypoints=websecure"
      - "traefik.http.routers.netdata.tls.certresolver=letsencrypt"
      - "traefik.http.services.netdata.loadbalancer.server.port=19999"
      - "traefik.http.middlewares.netdata-auth.basicauth.users=${TRAEFIKADMIN}"
      - "traefik.http.routers.netdata.middlewares=netdata-auth"

volumes:
  netdata-lib:
  netdata-cache:

networks:
  proxy:
Enter fullscreen mode Exit fullscreen mode

Save and close the file. This deployment specifies:

  • services: Launches two containers, traefik (reverse proxy serving Netdata over HTTPS with a Let's Encrypt certificate) and netdata (the monitoring web dashboard)
  • image: Specifies the container image for each service
  • volumes (traefik): The ./letsencrypt directory stores the TLS certificates, and /var/run/docker.sock exposes the Docker daemon UNIX socket to Traefik
  • volumes (netdata): /etc/netdata, /var/lib/netdata, and /var/cache/netdata store configuration, the registry and database, and the cache. The read-only mounts of /, /etc/passwd, /etc/group, /proc, /sys, /etc/os-release, /var/log, /var/run/docker.sock, and /run/dbus give Netdata visibility into the host file system, users and groups, CPU/memory/process/network metrics, container metrics, OS details, logs, containers, and systemd units. /etc/localtime synchronizes the Netdata time zone with the host
  • command (traefik): Configures the HTTP and HTTPS entry points, redirects all HTTP traffic to HTTPS, and enables the Let's Encrypt certificate resolver with the HTTP challenge
  • ports: Exposes ports 80 and 443 to serve the Netdata dashboard
  • networks: Joins Traefik and Netdata to a shared proxy network so Traefik can route to Netdata's dashboard port
  • environment: Defines DISABLE_TELEMETRY to disable anonymous telemetry
  • cap_add: Adds SYS_PTRACE (inspect running processes and collect host metrics) and SYS_ADMIN (inspect containers and the network)
  • apparmor:unconfined: Relaxes AppArmor restrictions so Netdata can inspect kernel and other Linux functions
  • labels: Instructs Traefik to route HTTPS requests for the Netdata domain to the container on port 19999 and to require HTTP basic authentication with the TRAEFIKADMIN credentials

Note: Netdata's own Docker documentation recommends network_mode: host for full network monitoring accuracy, because collectors such as proc.plugin, go.d.plugin, and the local-listener and network-viewer plugins read the host's real network interfaces and socket state directly. This deployment places Netdata on a custom bridge network instead, so that Traefik can route to it by container name. As a tradeoff, network-interface dashboards and local port discovery reflect the container's own virtual network rather than the host's, because Netdata only sees the host's real network state where it is exposed through the /proc and /sys mounts.

3. Start the containers:

$ docker compose up -d
Enter fullscreen mode Exit fullscreen mode

4. Check the container status:

$ docker ps
Enter fullscreen mode Exit fullscreen mode

Both the traefik and netdata containers show an Up status. The netdata container first reports (health: starting) and changes to (healthy) within about a minute. Traefik routes requests to Netdata only after the container is healthy, so the dashboard returns a 404 page not found error until then.


Access and Use the Netdata Dashboard

Netdata ships with a web interface that displays real-time statistics for the system and its services.

1. Open the dashboard: Replace netdata.example.com with your domain and open https://netdata.example.com in a web browser. Enter the netdataadmin username and the password you set with htpasswd when prompted.

2. Launch the dashboard: Click Skip and use the dashboard anonymously.

3. Pause or resume live updates: Click the Playing button at the top of the dashboard.

4. Explore the metrics: Check the System Overview at the top and check the rest of the dashboards by selecting from the right sidebar.


Configure Netdata

Netdata stores its main configuration in the /etc/netdata/netdata.conf file. This file contains only comments by default, because it is only used to override specific default values.

Database Usage

Netdata stores metrics data on disk using its own multi-tiered storage engine called dbengine, which compresses data across multiple retention tiers. A separate SQLite database stores host and chart metadata, not the metric values themselves.

1. Navigate to the Netdata configuration directory:

$ cd ~/netdata-docker/netdata-config
Enter fullscreen mode Exit fullscreen mode

2. Open the Netdata configuration file with the edit-config script, which edits and creates Netdata configuration files:

$ sudo ./edit-config netdata.conf
Enter fullscreen mode Exit fullscreen mode

3. Add the following lines at the bottom of the file:

[db]
    dbengine page cache size = 64MiB
    update every = 2
Enter fullscreen mode Exit fullscreen mode

Save and close the file. In the above configuration:

  • dbengine page cache size: Sets the amount of RAM used for caching Netdata metric values
  • update every: Sets how often collectors gather metrics. The value 2 reduces the collection frequency from every second to every 2 seconds, which lowers CPU and disk usage

4. Restart the Docker container to apply the changes:

$ docker restart netdata
Enter fullscreen mode Exit fullscreen mode

5. Check the container status:

$ docker ps
Enter fullscreen mode Exit fullscreen mode

Wait until the netdata container reports (healthy) before you reload the dashboard. Charts now update every 2 seconds.

Enable and Disable Plugins

You can use the configuration file to enable and disable specific plugins that collect metrics.

1. Navigate to the Netdata configuration directory:

$ cd ~/netdata-docker/netdata-config
Enter fullscreen mode Exit fullscreen mode

2. Open the Netdata configuration file:

$ sudo ./edit-config netdata.conf
Enter fullscreen mode Exit fullscreen mode

3. Add the following lines at the bottom of the file to disable the cgroups plugin that monitors Docker containers:

[plugins]
    cgroups = no
Enter fullscreen mode Exit fullscreen mode

Save and close the file.

4. Restart the Docker container to apply the change:

$ docker restart netdata
Enter fullscreen mode Exit fullscreen mode

After the netdata container reports (healthy) in the docker ps output, the dashboard no longer shows per-container charts, which confirms that Netdata stopped monitoring Docker containers.


Next Steps

Netdata is running behind Traefik with HTTPS and basic authentication. From here you can:

  • Re-enable the cgroups plugin if you want per-container charts back
  • Connect Netdata to Prometheus, Graphite, or Grafana to export or visualize metrics
  • Monitor multiple nodes by deploying the same stack on additional servers
  • Review the official Netdata documentation for advanced metric collection

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)