Install Vector via Nix

Vector can be installed through the Nix package manager via Vector's Nix package. This package manager is generally used on NixOS.

Install

The daemon deployment strategy is designed for data collection on a single host. Vector runs in the background, in its own process, collecting all data for that host. Typically data is collected from a process manager, such as Journald via Vector's journald source, but can be collected through any of Vector's sources. The following diagram demonstrates how it works.

Vector daemon deployment strategyVector daemon deployment strategy
1. Your service logs to STDOUT
STDOUT follows the 12 factor principles.
2. STDOUT is captured
STDOUT is captured by your platform.
3. Vector collects & fans-out data
Vector collects data from your platform.

  1. Install Vector

    nix-env --file https://github.com/NixOS/nixpkgs/archive/master.tar.gz --install --attr vector
    explain this command

    Looking for a specific version?

  2. Configure Vector

    Where do you want to send your data?
    Console
    echo '
    [sources.in]
    type = "journald" # required
    [sinks.out]
    # General
    type = "console" # required
    inputs = ["in"] # required
    # Encoding
    encoding.codec = "json" # required
    ' > /etc/vector/vector.toml
    explain this command
  3. Start Vector

    vector --config /etc/vector/vector.toml
    explain this command

Configuring

The Vector nix package does not install any configuration files by default. You'll need to create a Vector configuration file and pass it to Vector via the --config flag when starting Vector.

Deploying

How you deploy Vector is largely dependent on your use case and environment. Please see the deployment section for more info on how to deploy Vector.

Administering

The Vector nix package does not use Systemd by default, but Vector does provide a Systemd service file that you can use as a starting point. How you manage the Vector process is up to you, and the process administration section covers how to do this:

Administration

Uninstalling

nix-env --uninstall vector

Updating

nix-env --file https://github.com/NixOS/nixpkgs/archive/master.tar.gz --upgrade vector

Package

Architectures

Vector's Nix packages only support the X86_64 architecture.

Versions

Installing previous versions of Vector through nix is possible, but not straightforward. For example, installing Vector 0.7.1 can be achieved with the following command:

nix-env --file https://github.com/NixOS/nixpkgs/archive/20bbe6cba68fb9d37b5d0e373b6180dce2961e0d.tar.gz --install --attr vector

20bbe6... represents the commit sha for the 0.7.1 on the nix package repo.

Listing Versions & Commit SHAs

For situations that required automated retrieval, we've thrown thogether this handy Ruby function that will list the Vector versions and their commit sha:

require "net/http"
require "json"
# Returns a hash mapping Vector versions to commits in `nixpkgs/nixos` repository
def nix_versions
nixpkgs_repo = "nixos/nixpkgs"
commits_url = "https://api.github.com/repos/#{nixpkgs_repo}/commits?path=pkgs/tools/misc/vector"
response = Net::HTTP.get URI(commits_url)
items = JSON.parse response
versions = {}
for item in items do
match = item["commit"]["message"].match "^vector:.*(\\d+\.\\d+\.\\d+)$"
if match
version = match[1]
versions[version] = item["sha"]
end
end
versions
end

Source Files

Vector's Nix source files are located in the Nix repo.