netdata/netdata · error

protocols.sampling_cache_max_entries_per_stream must be grea

Error message

protocols.sampling_cache_max_entries_per_stream must be greater than 0

What it means

The per-stream companion to sampling_cache_max_entries bounds sampler cache entries keyed per observation stream (source observation domain / exporter stream). Like the global cap, 0 would make the cache unusable, so validate_listener_and_protocols() fails fast when it is 0.

Source

Thrown at src/crates/netflow-plugin/src/plugin_config/validation/listener.rs:46

        || cfg.protocols.ipfix
        || cfg.protocols.sflow)
    {
        anyhow::bail!("at least one protocol must be enabled");
    }

    if cfg
        .protocols
        .v9_template_lifetime
        .get()
        .is_some_and(|lifetime| lifetime.is_zero())
    {
        anyhow::bail!("protocols.v9_template_lifetime must be greater than 0 or null");
    }
    if cfg.protocols.sampling_cache_max_entries == 0 {
        anyhow::bail!("protocols.sampling_cache_max_entries must be greater than 0");
    }
    if cfg.protocols.sampling_cache_max_entries_per_stream == 0 {
        anyhow::bail!("protocols.sampling_cache_max_entries_per_stream must be greater than 0");
    }

    Ok(())
}

View on GitHub (pinned to 4864de85e2)

Solutions

  1. Set protocols.sampling_cache_max_entries_per_stream to a positive integer (e.g. 1000)
  2. Keep it <= sampling_cache_max_entries so the per-stream cap is meaningful
  3. If the key was absent, add it next to sampling_cache_max_entries under 'protocols:'

Example fix

# before
protocols:
  sampling_cache_max_entries: 10000
  sampling_cache_max_entries_per_stream: 0

# after
protocols:
  sampling_cache_max_entries: 10000
  sampling_cache_max_entries_per_stream: 1000
Defensive patterns

Strategy: validation

Validate before calling

fn per_stream_entries_ok(cfg: &PluginConfig) -> bool {
    cfg.protocols.sampling_cache_max_entries_per_stream > 0
        && cfg.protocols.sampling_cache_max_entries_per_stream <= cfg.protocols.sampling_cache_max_entries
}

Try / catch

Fatal config error; fix both sampling cache fields together.

Prevention

When it happens

Trigger: PluginConfig loaded with protocols.sampling_cache_max_entries_per_stream == 0 — set explicitly, defaulted from a missing key, or copy-pasted from a config block where the global entries were tuned to 0.

Common situations: Adjusting sampling cache settings and zeroing both fields; config generated for large deployments where the author misunderstood 0 as 'auto'; forgetting this second field exists after an upgrade split the single cache setting into global and per-stream.

Related errors


AI-assisted analysis of netdata/netdata@4864de85e2 (2026-08-15). Data as JSON: /api/errors/4effef29e9a1f2e4. Report an issue: GitHub.