How to install Netdata on Linux

How to Install Netdata on Linux: Complete Guide for System Monitoring Netdata is a powerful, real-time system monitoring tool that provides comprehensive insights into your Linux server's performance. This open-source solution offers beautiful visualizations, minimal resource usage, and zero-configuration monitoring out of the box. Whether you're a system administrator, DevOps engineer, or simply want to monitor your Linux system effectively, this comprehensive guide will walk you through every aspect of installing and configuring Netdata on Linux. Table of Contents - [What is Netdata?](#what-is-netdata) - [Prerequisites and System Requirements](#prerequisites-and-system-requirements) - [Installation Methods Overview](#installation-methods-overview) - [Method 1: One-Line Installation Script](#method-1-one-line-installation-script) - [Method 2: Package Manager Installation](#method-2-package-manager-installation) - [Method 3: Docker Installation](#method-3-docker-installation) - [Method 4: Building from Source](#method-4-building-from-source) - [Post-Installation Configuration](#post-installation-configuration) - [Accessing Netdata Dashboard](#accessing-netdata-dashboard) - [Security Considerations](#security-considerations) - [Troubleshooting Common Issues](#troubleshooting-common-issues) - [Best Practices and Optimization](#best-practices-and-optimization) - [Advanced Configuration](#advanced-configuration) - [Conclusion and Next Steps](#conclusion-and-next-steps) What is Netdata? Netdata is a distributed, real-time performance and health monitoring solution for systems and applications. It provides unparalleled insights into everything happening on your Linux systems and applications with stunning, interactive web dashboards and powerful performance troubleshooting tools. Key features include: - Real-time monitoring: Updates every second with zero lag - Comprehensive metrics: Monitors CPU, memory, disk, network, applications, and more - Zero configuration: Works out of the box with automatic detection - Low resource usage: Minimal impact on system performance - Beautiful dashboards: Interactive, responsive web interface - Alerting capabilities: Built-in alert notifications - Extensible: Supports custom plugins and integrations Prerequisites and System Requirements Before installing Netdata on your Linux system, ensure you meet the following requirements: System Requirements - Operating System: Any modern Linux distribution (Ubuntu, CentOS, RHEL, Debian, Fedora, SUSE, etc.) - Architecture: x86_64, ARM, or ARM64 - RAM: Minimum 128MB, recommended 512MB or more - Disk Space: At least 100MB free space - CPU: Any modern processor (Netdata uses minimal CPU resources) Network Requirements - Port Access: Port 19999 (default) should be available - Internet Access: Required for initial installation and updates - Firewall: Configure firewall rules if accessing remotely User Permissions - Root Access: Required for installation and system-level monitoring - Sudo Privileges: Alternative to direct root access Dependencies Most dependencies are automatically installed, but ensure your system has: - Package Manager: apt, yum, dnf, or zypper - Basic Tools: curl, wget, or similar download utilities - Compiler Tools: gcc, make (if building from source) Installation Methods Overview Netdata offers multiple installation methods to accommodate different use cases and preferences: 1. One-Line Script: Fastest and most convenient method 2. Package Managers: Distribution-specific packages 3. Docker: Containerized deployment 4. Source Compilation: Maximum customization and control Each method has its advantages, and we'll cover all of them in detail. Method 1: One-Line Installation Script The one-line installation script is the recommended method for most users. It automatically detects your system and installs the appropriate version of Netdata. Step 1: Download and Execute the Script Open your terminal and run the following command: ```bash bash <(curl -Ss https://my-netdata.io/kickstart.sh) ``` Alternatively, if you prefer wget: ```bash bash <(wget -O - https://my-netdata.io/kickstart.sh) ``` Step 2: Follow the Interactive Prompts The script will: 1. Detect your Linux distribution 2. Install required dependencies 3. Download the latest Netdata version 4. Compile and install Netdata 5. Create necessary user accounts 6. Configure system services 7. Start Netdata automatically Step 3: Verify Installation After installation completes, verify Netdata is running: ```bash sudo systemctl status netdata ``` You should see output indicating Netdata is active and running. Installation Script Options The installation script supports various options for customization: ```bash Install without prompts (non-interactive) bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait Install to a custom directory bash <(curl -Ss https://my-netdata.io/kickstart.sh) --install /opt/netdata Install without starting the service bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-start-it Install with specific user bash <(curl -Ss https://my-netdata.io/kickstart.sh) --local-files ``` Method 2: Package Manager Installation Many Linux distributions provide Netdata packages through their official repositories. Ubuntu/Debian Installation For Ubuntu and Debian systems: ```bash Update package lists sudo apt update Install Netdata sudo apt install netdata Start and enable Netdata service sudo systemctl start netdata sudo systemctl enable netdata ``` CentOS/RHEL/Fedora Installation For Red Hat-based distributions: CentOS/RHEL 7/8: ```bash Install EPEL repository (if not already installed) sudo yum install epel-release Install Netdata sudo yum install netdata Start and enable Netdata service sudo systemctl start netdata sudo systemctl enable netdata ``` Fedora: ```bash Install Netdata sudo dnf install netdata Start and enable Netdata service sudo systemctl start netdata sudo systemctl enable netdata ``` SUSE/openSUSE Installation For SUSE-based distributions: ```bash Install Netdata sudo zypper install netdata Start and enable Netdata service sudo systemctl start netdata sudo systemctl enable netdata ``` Arch Linux Installation For Arch Linux users: ```bash Install from AUR (using yay) yay -S netdata Or using makepkg git clone https://aur.archlinux.org/netdata.git cd netdata makepkg -si Start and enable Netdata service sudo systemctl start netdata sudo systemctl enable netdata ``` Method 3: Docker Installation Docker provides an isolated and portable way to run Netdata. Prerequisites for Docker Installation Ensure Docker is installed and running: ```bash Check Docker status sudo systemctl status docker If not installed, install Docker curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh ``` Basic Docker Installation Run Netdata in a Docker container: ```bash docker run -d --name=netdata \ -p 19999:19999 \ -v netdataconfig:/etc/netdata \ -v netdatalib:/var/lib/netdata \ -v netdatacache:/var/cache/netdata \ -v /etc/passwd:/host/etc/passwd:ro \ -v /etc/group:/host/etc/group:ro \ -v /proc:/host/proc:ro \ -v /sys:/host/sys:ro \ -v /etc/os-release:/host/etc/os-release:ro \ --restart unless-stopped \ --cap-add SYS_PTRACE \ --security-opt apparmor=unconfined \ netdata/netdata ``` Docker Compose Installation Create a `docker-compose.yml` file: ```yaml version: '3' services: netdata: image: netdata/netdata container_name: netdata hostname: example.com # set to fqdn of host ports: - 19999:19999 restart: unless-stopped cap_add: - SYS_PTRACE security_opt: - apparmor:unconfined volumes: - netdataconfig:/etc/netdata - netdatalib:/var/lib/netdata - netdatacache:/var/cache/netdata - /etc/passwd:/host/etc/passwd:ro - /etc/group:/host/etc/group:ro - /proc:/host/proc:ro - /sys:/host/sys:ro - /etc/os-release:/host/etc/os-release:ro volumes: netdataconfig: netdatalib: netdatacache: ``` Deploy using Docker Compose: ```bash docker-compose up -d ``` Method 4: Building from Source Building from source provides maximum control and customization options. Step 1: Install Build Dependencies Ubuntu/Debian: ```bash sudo apt update sudo apt install zlib1g-dev uuid-dev libuv1-dev liblz4-dev libjudy-dev \ libssl-dev libelf-dev libmnl-dev gcc make git autoconf autoconf-archive \ autogen automake pkg-config curl python3 ``` CentOS/RHEL/Fedora: ```bash sudo yum install zlib-devel libuuid-devel libuv-devel lz4-devel \ Judy-devel openssl-devel elfutils-libelf-devel libmnl-devel gcc make \ git autoconf autoconf-archive autogen automake pkgconfig curl python3 ``` Step 2: Clone the Repository ```bash git clone https://github.com/netdata/netdata.git --depth=100 --recursive cd netdata ``` Step 3: Build and Install ```bash Run the installer script sudo ./netdata-installer.sh ``` Step 4: Configure Build Options You can customize the build with various options: ```bash Install to custom prefix sudo ./netdata-installer.sh --install /opt/netdata Install without system service integration sudo ./netdata-installer.sh --dont-start-it Build with specific features sudo ./netdata-installer.sh --enable-plugin-cups --enable-plugin-freeipmi ``` Post-Installation Configuration After successful installation, you may want to customize Netdata's configuration. Configuration File Locations Netdata configuration files are typically located at: - Main Config: `/etc/netdata/netdata.conf` - Plugin Configs: `/etc/netdata/` - Custom Configs: `/etc/netdata/custom/` Generate Configuration File Generate a complete configuration file with all options: ```bash sudo /usr/sbin/netdata -W set 2>/dev/null | sudo tee /etc/netdata/netdata.conf ``` Basic Configuration Options Edit the main configuration file: ```bash sudo nano /etc/netdata/netdata.conf ``` Key configuration sections: ```ini [global] # Change default port default port = 19999 # Bind to specific IP bind socket to IP = 127.0.0.1 # Set hostname hostname = my-server # Update frequency update every = 1 [web] # Web files directory web files directory = /usr/share/netdata/web # Enable/disable web server mode = static-threaded [plugins] # Enable/disable specific plugins apps = yes cgroups = yes diskspace = yes ``` Restart Netdata Service After making configuration changes: ```bash sudo systemctl restart netdata ``` Accessing Netdata Dashboard Local Access Once installed and running, access Netdata through your web browser: ``` http://localhost:19999 ``` Or using your server's IP address: ``` http://YOUR_SERVER_IP:19999 ``` Dashboard Features The Netdata dashboard provides: - Real-time Charts: Live updating performance metrics - System Overview: CPU, memory, disk, and network usage - Process Monitoring: Individual application performance - Alert Status: Current system alerts and warnings - Historical Data: Time-series data visualization - Interactive Controls: Zoom, pan, and filter capabilities Mobile Access Netdata's dashboard is fully responsive and works well on mobile devices. Simply navigate to the same URL from your mobile browser. Security Considerations Network Security By default, Netdata binds to all interfaces. For security, consider: Bind to Localhost Only Edit `/etc/netdata/netdata.conf`: ```ini [web] bind to = 127.0.0.1 ``` Configure Firewall For Ubuntu/Debian: ```bash Allow specific IP sudo ufw allow from YOUR_IP to any port 19999 Allow local network sudo ufw allow from 192.168.1.0/24 to any port 19999 ``` For CentOS/RHEL: ```bash Add firewall rule sudo firewall-cmd --permanent --add-port=19999/tcp --source=YOUR_IP sudo firewall-cmd --reload ``` Access Control Basic Authentication Configure basic authentication by editing `/etc/netdata/netdata.conf`: ```ini [web] enable web responses gzip compression = yes web files directory = /usr/share/netdata/web respect do not track policy = no x-frame-options response header = allow connections from = localhost * allow dashboard from = localhost * allow badges from = * allow streaming from = * allow netdata.conf from = localhost fd 10. 192.168. 172.16. 172.17. 172.18. 172.19. 172.20. 172.21. 172.22. 172.23. 172.24. 172.25. 172.26. 172.27. 172.28. 172.29. 172.30. 172.31.* ``` Reverse Proxy Setup Use Nginx or Apache as a reverse proxy with authentication: Nginx Configuration: ```nginx server { listen 80; server_name netdata.example.com; auth_basic "Netdata"; auth_basic_user_file /etc/nginx/.htpasswd; location / { proxy_pass http://127.0.0.1:19999; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ``` Create password file: ```bash sudo htpasswd -c /etc/nginx/.htpasswd username ``` Troubleshooting Common Issues Installation Issues Issue: Permission Denied Problem: Installation fails with permission errors. Solution: ```bash Ensure you have sudo privileges sudo -v Or run as root su - bash <(curl -Ss https://my-netdata.io/kickstart.sh) ``` Issue: Missing Dependencies Problem: Build fails due to missing dependencies. Solution: ```bash Ubuntu/Debian sudo apt update && sudo apt install build-essential CentOS/RHEL sudo yum groupinstall "Development Tools" Fedora sudo dnf groupinstall "Development Tools" ``` Issue: Port Already in Use Problem: Port 19999 is already occupied. Solution: ```bash Check what's using the port sudo netstat -tlnp | grep 19999 Kill the process or change Netdata port sudo nano /etc/netdata/netdata.conf Change: default port = 19999 to default port = 19998 ``` Service Issues Issue: Netdata Won't Start Problem: Service fails to start after installation. Solution: ```bash Check service status sudo systemctl status netdata Check logs sudo journalctl -u netdata -f Check configuration sudo netdata -W set | head -20 ``` Issue: High CPU Usage Problem: Netdata consuming too much CPU. Solution: ```bash Reduce update frequency sudo nano /etc/netdata/netdata.conf Change: update every = 1 to update every = 2 Disable unnecessary plugins Add under [plugins] section: apps = no cgroups = no ``` Access Issues Issue: Can't Access Dashboard Problem: Unable to reach Netdata dashboard. Solution: ```bash Check if Netdata is running sudo systemctl status netdata Check listening ports sudo netstat -tlnp | grep netdata Check firewall sudo ufw status # Ubuntu sudo firewall-cmd --list-all # CentOS/RHEL Test local access curl http://localhost:19999 ``` Issue: Blank Dashboard Problem: Dashboard loads but shows no data. Solution: ```bash Check plugin status sudo netdata -W set | grep -A 5 "\[plugins\]" Restart netdata sudo systemctl restart netdata Check permissions ls -la /var/lib/netdata/ ``` Performance Issues Issue: High Memory Usage Problem: Netdata using excessive memory. Solution: ```bash Reduce history sudo nano /etc/netdata/netdata.conf Add under [global]: history = 3600 # Keep 1 hour of data Reduce memory mode Add: memory mode = ram ``` Best Practices and Optimization Resource Optimization Memory Management Configure memory usage based on your system: ```ini [global] # For systems with limited RAM memory mode = ram history = 1800 # 30 minutes # For systems with plenty of RAM memory mode = save history = 14400 # 4 hours ``` CPU Optimization Reduce CPU usage for resource-constrained systems: ```ini [global] update every = 2 # Update every 2 seconds instead of 1 [plugins] # Disable resource-intensive plugins apps = no cgroups = no python.d = no ``` Monitoring Best Practices Essential Metrics to Monitor Focus on key performance indicators: 1. CPU Usage: Overall and per-core utilization 2. Memory Usage: RAM and swap utilization 3. Disk I/O: Read/write operations and latency 4. Network Traffic: Bandwidth utilization 5. System Load: Load average trends 6. Process Monitoring: Critical service health Alert Configuration Set up meaningful alerts: ```bash Create custom alert configuration sudo nano /etc/netdata/health.d/custom.conf ``` Example alert configuration: ```ini CPU usage alert alarm: cpu_usage on: system.cpu lookup: average -3m unaligned of user,system,softirq,irq,guest units: % every: 10s warn: $this > 75 crit: $this > 90 info: CPU utilization is high Memory usage alert alarm: ram_usage on: system.ram lookup: average -1m unaligned of used calc: $this * 100 / ($this + $available) units: % every: 10s warn: $this > 80 crit: $this > 90 info: RAM utilization is high ``` Maintenance Procedures Regular Updates Keep Netdata updated: ```bash For script installation sudo netdata-updater For package installation sudo apt update && sudo apt upgrade netdata # Ubuntu/Debian sudo yum update netdata # CentOS/RHEL ``` Log Management Configure log rotation: ```bash Check current log size du -sh /var/log/netdata/ Configure logrotate sudo nano /etc/logrotate.d/netdata ``` Example logrotate configuration: ``` /var/log/netdata/*.log { daily missingok rotate 14 compress notifempty create 644 netdata netdata postrotate /bin/kill -HUP `cat /var/run/netdata.pid 2> /dev/null` 2> /dev/null || true endscript } ``` Backup Configuration Backup your Netdata configuration: ```bash Create backup directory sudo mkdir -p /backup/netdata Backup configuration sudo tar -czf /backup/netdata/netdata-config-$(date +%Y%m%d).tar.gz /etc/netdata/ Backup data (optional) sudo tar -czf /backup/netdata/netdata-data-$(date +%Y%m%d).tar.gz /var/lib/netdata/ ``` Advanced Configuration Custom Plugins Create custom monitoring plugins: ```bash Create custom plugin directory sudo mkdir -p /etc/netdata/custom-plugins.d/ Create a simple custom plugin sudo nano /etc/netdata/custom-plugins.d/custom-metrics.sh ``` Example custom plugin: ```bash #!/bin/bash Custom metrics plugin for Netdata CHART="custom.metrics" PRIORITY=60000 UPDATE_EVERY=1 Create chart cat << EOF CHART ${CHART} '' "Custom Metrics" "units" "custom" "" line ${PRIORITY} ${UPDATE_EVERY} DIMENSION metric1 '' absolute 1 1 DIMENSION metric2 '' absolute 1 1 EOF Generate data while true; do echo "BEGIN ${CHART}" echo "SET metric1 = $((RANDOM % 100))" echo "SET metric2 = $((RANDOM % 50))" echo "END" sleep ${UPDATE_EVERY} done ``` Make the plugin executable: ```bash sudo chmod +x /etc/netdata/custom-plugins.d/custom-metrics.sh ``` Integration with External Systems Prometheus Integration Export metrics to Prometheus: ```ini [backend] enabled = yes type = prometheus_remote_write destination = http://prometheus-server:9090/api/v1/write update every = 10 ``` Grafana Integration Use Netdata as a Grafana data source: 1. Install Grafana 2. Add Netdata as a data source 3. Use URL: `http://netdata-server:19999` 4. Import Netdata dashboards Clustering and Scaling Master-Slave Configuration Set up Netdata streaming: Master Configuration (`/etc/netdata/stream.conf`): ```ini [11111111-2222-3333-4444-555555555555] enabled = yes allow from = * default history = 3600 default memory = ram health enabled by default = auto ``` Slave Configuration: ```ini [stream] enabled = yes destination = master-server:19999 api key = 11111111-2222-3333-4444-555555555555 ``` Conclusion and Next Steps Installing Netdata on Linux provides you with a powerful, real-time monitoring solution that offers comprehensive insights into your system's performance. Throughout this guide, we've covered multiple installation methods, from the simple one-line script to advanced source compilation, ensuring you can choose the approach that best fits your environment and requirements. Key Takeaways 1. Multiple Installation Options: Choose between one-line script, package managers, Docker, or source compilation based on your needs 2. Zero Configuration: Netdata works out of the box with sensible defaults 3. Comprehensive Monitoring: Monitor CPU, memory, disk, network, and applications in real-time 4. Security Considerations: Implement proper access controls and network security 5. Customization: Extensive configuration options for optimization and custom requirements 6. Troubleshooting: Common issues have well-documented solutions 7. Best Practices: Follow optimization and maintenance procedures for optimal performance Next Steps After successfully installing Netdata, consider these next steps: 1. Explore the Dashboard: Familiarize yourself with all available metrics and visualizations 2. Configure Alerts: Set up meaningful alerts for critical system metrics 3. Customize Configuration: Tailor Netdata to your specific monitoring requirements 4. Integrate with Other Tools: Connect Netdata with Prometheus, Grafana, or other monitoring systems 5. Set Up Monitoring for Multiple Servers: Implement streaming for centralized monitoring 6. Create Custom Plugins: Develop custom monitoring solutions for specific applications 7. Establish Maintenance Procedures: Implement regular updates and backup strategies Additional Resources - Official Documentation: [https://docs.netdata.cloud/](https://docs.netdata.cloud/) - Community Forum: [https://community.netdata.cloud/](https://community.netdata.cloud/) - GitHub Repository: [https://github.com/netdata/netdata](https://github.com/netdata/netdata) - Plugin Development Guide: Available in the official documentation - Configuration Reference: Complete configuration options documentation Netdata's combination of powerful monitoring capabilities, minimal resource usage, and ease of installation makes it an excellent choice for Linux system monitoring. Whether you're managing a single server or a complex infrastructure, Netdata provides the visibility and insights needed to maintain optimal system performance and quickly identify potential issues before they impact your operations.