Vous avez lancé le one-liner Netdata sur chaque hôte, les tableaux de bord par nœud sont apparus, vous en avez marqué quelques-uns, vous êtes passé à autre chose. Six mois plus tard, le port 19999 est ouvert au public sur trois de vos VM de périphérie parce que personne ne l’a verrouillé, chaque agent stocke ses propres métriques sans rétention centrale, les seuils d’alarme sont restés sur les valeurs par défaut et sont soit trop bruyants soit trop discrets, et quand un ingénieur demande « est-ce que le CPU a piqué à 02:00 mardi dernier ? » la réponse dépend de si ce nœud a été redémarré depuis.
Ce qui se passe
Un seul agent Netdata par hôte est excellent pour le dépannage en direct et terrible comme stockage de métriques à long terme. Pour le rendre prêt pour la production, le parc tourne en topologie parent/enfant : chaque enfant a une courte rétention locale et stream tout vers un parent central, qui garde une rétention par paliers (récent en haute résolution, plus vieux sous-échantillonné) et est le seul agent qui parle aux opérateurs. L’écouteur web de chaque enfant appartient à 127.0.0.1 — il n’y a aucune raison qu’il soit sur le NAT public, jamais. Le raccordement à Netdata Cloud est facultatif mais utile : il donne aux opérateurs un panneau unique et à la rotation d’astreinte un endroit où router les alarmes sans monter un Grafana séparé. Le réglage des alarmes fait partie de l’installation, pas d’un todo plus tard — laisser les valeurs par défaut, c’est la partie la plus bruyante d’un cimetière Netdata.
Comment vérifier
Sur un enfant, l’agent doit être lié uniquement au localhost :
ss -lntp | grep ':19999'
# 127.0.0.1:19999 netdata
Sur le parent, le même écouteur peut être sur 0.0.0.0 parce que nginx le fronte avec TLS. Santé du streaming depuis l’enfant :
curl -s http://127.0.0.1:19999/api/v1/info | python3 -c \
'import json,sys; d=json.load(sys.stdin); print("stream:", d.get("stream_enabled"), "destination:", d.get("stream_destinations"))'
Sur le parent, confirmez que les enfants sont connectés :
curl -s http://127.0.0.1:19999/api/v1/info | python3 -c \
'import json,sys; d=json.load(sys.stdin); print("hosts:", d.get("hosts_available"))'
Si un enfant affiche stream_enabled: False, la topologie n’est qu’un ensemble de N agents indépendants — corrigez avant de faire confiance aux tableaux de bord.
Le correctif
Enregistrez le script ci-dessous sous /root/setup-netdata-almalinux9.sh, puis exécutez-le. Il déroule l’installation complète sur une VM AlmaLinux 9.x fraîche dans l’un de deux rôles, posé par variable d’environnement : mise à jour de base + EPEL, SELinux enforcing, fail2ban, mises à jour de sécurité automatiques, l’installeur officiel Netdata (kickstart) qui tire la version stable courante, une configuration parent/enfant qui câble le streaming avec une clé API partagée, écouteur localhost-only sur les enfants, rétention dbengine dimensionnée sur le parent pour le parc, un gabarit d’alarme de démarrage (CPU + disque + mémoire) qui surcharge les valeurs par défaut bruyantes, NETDATA_CLAIM_TOKEN facultatif pour la bascule vers Netdata Cloud, nginx + certbot uniquement sur le parent. Le script attend l’écouteur avant de continuer.
#!/usr/bin/env bash
set -euo pipefail
### AlmaLinux 9.x Netdata Agent clean VM installer
### NETDATA_ROLE=parent -> central, retention-heavy, optionally public via nginx
### NETDATA_ROLE=child -> localhost-bound, streams to parent
### Set NETDATA_CLAIM_TOKEN to opt into Netdata Cloud (parent only)
### Keeps root SSH key login; disables password auth
### No local backups; assumes VM-level backup
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${NETDATA_ROLE:?Set NETDATA_ROLE to 'parent' or 'child'}"
: "${NETDATA_STREAM_API_KEY:?Set NETDATA_STREAM_API_KEY (uuidgen) — same on parent + all children}"
if [[ "$NETDATA_ROLE" == "parent" ]]; then
: "${ND_DOMAIN:?Set ND_DOMAIN for parent, e.g. metrics.example.com}"
: "${ND_EMAIL:?Set ND_EMAIL for Let's Encrypt}"
fi
if [[ "$NETDATA_ROLE" == "child" ]]; then
: "${NETDATA_PARENT_HOST:?Set NETDATA_PARENT_HOST (parent FQDN or IP)}"
fi
NETDATA_CLAIM_TOKEN="${NETDATA_CLAIM_TOKEN:-}"
NETDATA_CLAIM_ROOMS="${NETDATA_CLAIM_ROOMS:-}"
echo
echo "========================================"
echo "Netdata AlmaLinux 9 Setup"
echo "Role: $NETDATA_ROLE"
echo "========================================"
echo
echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y update
echo "==> Installing base packages"
dnf -y install \
curl wget vim ca-certificates gnupg2 \
chrony fail2ban dnf-automatic \
policycoreutils-python-utils \
lsof tcpdump bind-utils iproute net-tools jq
systemctl enable --now chronyd
timedatectl set-ntp true
echo "==> SELinux enforcing on next boot"
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config || true
setenforce 1 2>/dev/null || true
echo "==> sysctl + file limits"
cat > /etc/sysctl.d/99-netdata.conf <<'SYSCTL'
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
fs.file-max = 2097152
kernel.dmesg_restrict = 1
SYSCTL
sysctl --system
cat > /etc/security/limits.d/99-netdata.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
netdata soft nofile 64000
netdata hard nofile 64000
LIMITS
echo "==> Hardening SSH (keep root key)"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
set_sshd() {
local k="$1" v="$2"
if grep -qE "^[#[:space:]]*${k}[[:space:]]+" /etc/ssh/sshd_config; then
sed -i "s|^[#[:space:]]*${k}[[:space:]].*|${k} ${v}|" /etc/ssh/sshd_config
else
echo "${k} ${v}" >> /etc/ssh/sshd_config
fi
}
set_sshd PermitRootLogin prohibit-password
set_sshd PasswordAuthentication no
set_sshd PubkeyAuthentication yes
set_sshd KbdInteractiveAuthentication no
set_sshd X11Forwarding no
set_sshd ClientAliveInterval 300
set_sshd MaxAuthTries 4
sshd -t
systemctl restart sshd
echo "==> fail2ban + dnf-automatic"
cat > /etc/fail2ban/jail.d/sshd.local <<'F2B'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
F2B
systemctl enable --now fail2ban
cat > /etc/dnf/automatic.conf <<'DNFA'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
[base]
debuglevel = 1
DNFA
systemctl enable --now dnf-automatic.timer
echo "==> Installing Netdata Agent (stable channel)"
KICKSTART_ARGS="--stable-channel --disable-telemetry --dont-wait --non-interactive"
if [[ -n "$NETDATA_CLAIM_TOKEN" && "$NETDATA_ROLE" == "parent" ]]; then
KICKSTART_ARGS="$KICKSTART_ARGS --claim-token ${NETDATA_CLAIM_TOKEN} --claim-rooms ${NETDATA_CLAIM_ROOMS:-} --claim-url https://app.netdata.cloud"
fi
# shellcheck disable=SC2086
bash <(curl -fsSL https://get.netdata.cloud/kickstart.sh) ${KICKSTART_ARGS}
echo "==> Writing role-specific configuration"
NETDATA_CONF_DIR="/etc/netdata"
mkdir -p "$NETDATA_CONF_DIR/stream.d" "$NETDATA_CONF_DIR/health.d"
if [[ "$NETDATA_ROLE" == "parent" ]]; then
cat > "$NETDATA_CONF_DIR/netdata.conf" <<'PARENTCONF'
[global]
hostname = netdata-parent
memory mode = dbengine
page cache size = 64
dbengine multihost disk space = 4096
[web]
bind to = 0.0.0.0:19999
allow connections from = localhost 127.0.0.1
allow dashboard from = localhost 127.0.0.1
allow streaming from = *
allow management from = localhost 127.0.0.1
[ml]
enabled = yes
[health]
enabled = yes
PARENTCONF
cat > "$NETDATA_CONF_DIR/stream.conf" <<STREAMP
# Parent: accept streams using this API key
[${NETDATA_STREAM_API_KEY}]
enabled = yes
default history = 3600
default memory mode = dbengine
health enabled by default = auto
allow from = *
STREAMP
else
cat > "$NETDATA_CONF_DIR/netdata.conf" <<CHILDCONF
[global]
hostname = $(hostname)
memory mode = ram
history = 600
[web]
bind to = 127.0.0.1:19999
allow connections from = localhost 127.0.0.1
allow dashboard from = localhost 127.0.0.1
allow management from = localhost 127.0.0.1
[ml]
enabled = no
[health]
enabled = no
CHILDCONF
cat > "$NETDATA_CONF_DIR/stream.conf" <<STREAMC
# Child: stream to parent
[stream]
enabled = yes
destination = ${NETDATA_PARENT_HOST}:19999
api key = ${NETDATA_STREAM_API_KEY}
timeout seconds = 60
default port = 19999
send charts matching = *
buffer size bytes = 10485760
reconnect delay seconds = 5
initial clock resync iterations = 60
STREAMC
fi
echo "==> Writing starter alarm overrides (override the noisier defaults)"
cat > "$NETDATA_CONF_DIR/health.d/cpu.conf" <<'HCPU'
template: 10min_cpu_usage
on: system.cpu
class: Utilization
type: System
component: CPU
hosts: *
calc: 100 - $idle
units: %
every: 1m
warn: $this > 85
crit: $this > 95
delay: down 15m multiplier 1.5 max 1h
info: 10 minute average CPU utilization
HCPU
cat > "$NETDATA_CONF_DIR/health.d/disk.conf" <<'HDISK'
template: disk_space_usage
on: disk.space
class: Utilization
type: System
component: Disk
hosts: *
units: %
every: 1m
calc: $used * 100 / ($avail + $used)
warn: $this > 85
crit: $this > 95
delay: down 15m multiplier 1.5 max 1h
info: disk space utilization
HDISK
cat > "$NETDATA_CONF_DIR/health.d/ram.conf" <<'HRAM'
template: ram_in_use
on: system.ram
class: Utilization
type: System
component: Memory
hosts: *
calc: ($used + $buffers + $active) * 100 / ($used + $buffers + $active + $cached + $free)
units: %
every: 1m
warn: $this > 85
crit: $this > 95
delay: down 15m multiplier 1.5 max 1h
info: RAM in use
HRAM
chown -R netdata:netdata /etc/netdata
mkdir -p /etc/systemd/system/netdata.service.d
cat > /etc/systemd/system/netdata.service.d/limits.conf <<'NDLIM'
[Service]
LimitNOFILE=64000
NDLIM
systemctl daemon-reload
systemctl restart netdata
echo "==> Waiting for Netdata listener"
if [[ "$NETDATA_ROLE" == "parent" ]]; then
EXPECTED="0.0.0.0:19999"
else
EXPECTED="127.0.0.1:19999"
fi
for i in {1..30}; do
if ss -lntp | grep -q "$EXPECTED"; then
echo " netdata bound on $EXPECTED"
break
fi
sleep 1
done
if [[ "$NETDATA_ROLE" == "parent" ]]; then
echo "==> Installing nginx + Let's Encrypt for parent UI"
dnf -y install nginx certbot python3-certbot-nginx
cat > /etc/nginx/conf.d/netdata.conf <<NGINX_BOOT
server {
listen 80;
server_name ${ND_DOMAIN};
location /.well-known/acme-challenge/ { root /var/lib/letsencrypt; }
location / { return 200 'bootstrap'; }
}
NGINX_BOOT
mkdir -p /var/lib/letsencrypt
systemctl enable --now nginx
nginx -t && systemctl reload nginx
if [[ ! -d /etc/letsencrypt/live/${ND_DOMAIN} ]]; then
certbot certonly --webroot -w /var/lib/letsencrypt \
-d "${ND_DOMAIN}" -m "${ND_EMAIL}" --agree-tos --non-interactive
fi
cat > /etc/nginx/conf.d/netdata.conf <<NGINX
server {
listen 80;
server_name ${ND_DOMAIN};
location /.well-known/acme-challenge/ { root /var/lib/letsencrypt; }
location / { return 301 https://\$host\$request_uri; }
}
server {
listen 443 ssl http2;
server_name ${ND_DOMAIN};
ssl_certificate /etc/letsencrypt/live/${ND_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${ND_DOMAIN}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
add_header Strict-Transport-Security "max-age=31536000" always;
location / {
proxy_pass http://127.0.0.1:19999/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 300s;
}
}
NGINX
nginx -t && systemctl reload nginx
systemctl enable --now certbot-renew.timer 2>/dev/null || true
fi
echo "==> Final package update"
dnf -y update
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Role: $NETDATA_ROLE"
echo "Listeners:"
ss -lntp | grep -E ':(19999|443|80)\b' || true
echo
echo "Service:"
systemctl is-active netdata fail2ban chronyd || true
echo
echo "Netdata info:"
curl -s http://127.0.0.1:19999/api/v1/info | head -c 600 || true
echo
if [[ "$NETDATA_ROLE" == "parent" ]]; then
echo "Public URL: https://${ND_DOMAIN}/"
if [[ -n "$NETDATA_CLAIM_TOKEN" ]]; then
echo "Netdata Cloud claim attempted with token (check app.netdata.cloud)"
else
echo "Netdata Cloud: not claimed. To claim later:"
echo " netdata-claim.sh -token=<token> -rooms=<room> -url=https://app.netdata.cloud"
fi
else
echo "Streaming to: ${NETDATA_PARENT_HOST}:19999"
echo "Confirm on parent that hosts_available > 1"
fi
echo
echo "Retention sizing (parent):"
echo " dbengine multihost disk space = 4096 MB"
echo " ~ keeps about 30-90 days of per-second metrics for a 10-host fleet."
echo " For larger fleets, bump this AND mount /var/cache/netdata on its own volume."
Rendez-le exécutable et lancez-le. Sur le parent d’abord :
chmod 700 /root/setup-netdata-almalinux9.sh
NETDATA_ROLE=parent ND_DOMAIN=metrics.example.com ND_EMAIL=ops@example.com \
NETDATA_STREAM_API_KEY=$(uuidgen) \
NETDATA_CLAIM_TOKEN=<token-cloud-facultatif> \
NETDATA_CLAIM_ROOMS=<room-id-facultatif> \
/root/setup-netdata-almalinux9.sh
Puis sur chaque VM enfant, avec la même clé API :
NETDATA_ROLE=child NETDATA_PARENT_HOST=metrics.example.com \
NETDATA_STREAM_API_KEY=<meme-cle-que-le-parent> \
/root/setup-netdata-almalinux9.sh
Le script affiche à la fin l’état des écouteurs, le statut du service et le JSON d’info de l’API. La dbengine sur le parent est dimensionnée à 4 Go par défaut — environ 30 à 90 jours pour un petit parc selon la densité de charts ; augmentez délibérément et mettez /var/cache/netdata sur un volume séparé avant de le faire, parce que la croissance n’est pas triviale à faire reculer. Les surcharges d’alarme CPU/disque/mémoire ramènent les valeurs par défaut bruyantes à des seuils 85/95 % avec un hold-off de 15 minutes, ce qui est habituellement le bon point de départ — ajustez de là selon ce qui réveille vraiment l’astreinte.
Stack Harbor opère Netdata en topologie parent/enfant dans le cadre des environnements infogérés — alarmes ajustées, rétention dimensionnée, et le raccordement Cloud qui atterrit dans la rotation d’astreinte que notre pratique Surveillance et support opère. Réservez une revue de topologie.