vectordotdev/vector · critical

metrics initialization failed

Error message

metrics initialization failed

What it means

Vector panics during global metrics initialization when `crate::metrics::init_global()` returns an Err. This function registers the process-wide metrics registry very early at startup, before any component runs, so a failure here is fatal and unrecoverable. The panic message 'metrics initialization failed' comes from the `expect` call in `init_global` in src/cli.rs.

Solutions

  1. Check that the process does not initialize global metrics more than once (relevant when embedding Vector or running tests that each init metrics)
  2. Review recently changed metrics-related configuration/environment and revert to defaults
  3. Run with `VECTOR_LOG=debug` to surface the underlying error returned by init_global
  4. Update or downgrade Vector; if reproducible on a clean config, file a bug with the underlying error message
Defensive patterns

Strategy: try-catch

Validate before calling

// Only relevant when embedding Vector:
// assert metrics not already initialized
// std::env::vars().filter(|(k,_)| k.starts_with("VECTOR_")).for_each(|(k,v)| println!("{k}={v}"));

Try / catch

// In embedded Rust usage, run init on a thread that captures panics:
let result = std::panic::catch_unwind(vector::cli::init_global);
match result {
    Ok(_) => {},
    Err(e) => eprintln!("metrics init panicked: {:?}", e),
}

Prevention

When it happens

Trigger: Calling the vector CLI (which calls `init_global` early in main) when the internal metrics registry fails to construct or has already been initialized; e.g. an unsupported/invalid metrics storage backend configuration or a double-initialization attempt.

Common situations: Corrupt or incompatible `METRICS`-related environment configuration; running Vector embedded twice in one process (embedding Vector in another Rust binary and calling init twice); internal regression in metrics setup.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/86722b06887546b0. Report an issue: GitHub.

Appendix: source

Thrown at src/cli.rs:335

        ])
        .map(|(path, hint)| config::ConfigPath::File(path, hint))
        .chain(
            self.config_dirs
                .iter()
                .map(|dir| config::ConfigPath::Dir(dir.to_path_buf())),
        )
        .collect()
    }

    pub fn init_global(&self) {
        if !self.openssl_no_probe {
            // SAFETY: Initialization runs before worker threads start.
            unsafe {
                openssl_probe::init_openssl_env_vars();
            }
        }

        crate::metrics::init_global().expect("metrics initialization failed");
    }
}

/// Raise the soft file descriptor limit (RLIMIT_NOFILE) as high as the OS allows.
///
/// Many systems default the soft limit to 1024 (Linux) or 256 (macOS), which is too low
/// for Vector when it monitors large numbers of log files. Raising it prevents
/// "Too many open files (os error 24)" errors without requiring manual sysadmin intervention.
///
/// On Linux, the soft limit is raised to the hard limit (typically 65536+).
/// On macOS, the hard limit can be RLIM_INFINITY, so we first try the hard limit,
/// then fall back to the kernel-enforced `kern.maxfilesperproc` (typically 10240).
#[cfg(unix)]
pub(crate) fn raise_file_descriptor_limit() {
    use nix::sys::resource::{Resource, getrlimit, setrlimit};
    use tracing::{info, warn};

    let (soft, hard) = match getrlimit(Resource::RLIMIT_NOFILE) {

View on GitHub (pinned to bdb87aeaa4)