
Netdata is an open-source monitoring system for Linux-based operating systems. It provides real-time performance monitoring through dashboards that update every second, with collectors for CPU, memory, system processes, disk usage, IPv4 and IPv6 networks, the system firewall, and applications such as Nginx, MySQL, MongoDB, Redis, Elasticsearch, PostgreSQL, and PHP-FPM. It integrates with other monitoring tools such as Prometheus, Graphite, Kafka, and Grafana.
This article explains how to deploy Netdata on a Linux server using Docker Compose with a Traefik reverse proxy for TLS termination. It also explains how to configure Netdata's basic settings.
Before you begin, you need to:
sudo privileges.docker group.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.
Create the project directory.
Enter the project directory.
Create a directory for Netdata configuration.
Install the apache2-utils package, which provides the htpasswd utility.
Generate the credentials to be used in the .env file. The command prompts you to enter and confirm the password for the netdataadmin user, which you use to access the dashboard.
The command prints a single line in the netdataadmin:HASH format. Copy the output.
Create a .env file.
Add the following configuration.
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.
The Docker Compose file runs the Netdata service and uses various mounts to monitor the Host server. Traefik acts as a reverse proxy.
Create the Docker Compose Configuration file.
Add the following configuration.
Save and close the file.
This deployment specifies:
services: Launches two containers to deploy the Netdata monitoring dashboard:traefik: Functions as the reverse proxy and serves Netdata over HTTPS with a Let's Encrypt certificate.netdata: Hosts the Netdata 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: Stores Netdata configuration files./var/lib/netdata: Stores the Netdata Cloud configuration, registry, and database./var/cache/netdata: Stores the Netdata cache./host/root:ro,rslave: Bind-mounts the host file system into the Netdata container so that it has access to the host and container file systems./etc/passwd and /etc/group: Give Netdata access to the host's users and groups./etc/localtime:/etc/localtime:ro: Synchronizes the Netdata time zone with the host./proc:/host/proc:ro: Provides Netdata access to CPU, memory, process, kernel, and network metrics./sys:/host/sys:ro: Provides Netdata with container metrics for monitoring Docker and Kubernetes./etc/os-release: Tells Netdata the Linux distribution and OS version./var/log:/host/var/log:ro: Gives Netdata access to system and application logs./var/run/docker.sock:/var/run/docker.sock:ro: Gives Netdata access to the containers./run/dbus:/run/dbus:ro: Gives Netdata access to systemd unit information.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 the DISABLE_TELEMETRY environment variable to disable anonymous telemetry.cap_add: Adds the following Linux capabilities to Netdata:SYS_PTRACE: Allows Netdata to inspect running processes and collect host metrics.SYS_ADMIN: Allows Netdata to inspect containers and the network.apparmor:unconfined: Relaxes AppArmor restrictions and allows Netdata to 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.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.
Start the containers.
Check the container status.
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.
Netdata ships with a web interface that displays real-time statistics for the system and its services.
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.
Click Skip and use the dashboard anonymously to launch the dashboard.
Click the Playing button at the top of the dashboard to pause or resume live chart updates.
Check the System Overview at the top and check the rest of the dashboards by selecting from the right sidebar.
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.
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.
Navigate to the Netdata configuration directory.
Netdata provides an edit-config script to edit and create Netdata configuration files. Open the Netdata configuration file.
Add the following lines at the bottom of the file.
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.Restart the Docker container to apply the changes.
Check the container status.
Wait until the netdata container reports (healthy) before you reload the dashboard. Charts now update every 2 seconds.
You can use the configuration file to enable and disable specific plugins that collect metrics.
Navigate to the Netdata configuration directory.
Open the Netdata configuration file.
Add the following lines at the bottom of the file to disable the cgroups plugin that monitors Docker containers.
Save and close the file.
Restart the Docker container to apply the change.
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.
You have deployed Netdata with Docker Compose and secured its public dashboard with HTTP basic authentication and Traefik for TLS termination. You also configured basic settings, including cache size, update frequency, and enabled plugins. For advanced metric collection, monitoring various nodes, or further information, visit the official Netdata documentation.
0 Comments
Be the first to comment and share your perspective with the community.