Install Vector From Source

This page covers installing Vector from source using the native toolchain for the host.

Vector can also be compiled to a static binary for Linux for x86_64, ARM64, and ARMv7 architectures. See compiling using Docker for details.

Installation

  1. Install Rust

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
  2. Install C and C++ compilers (GCC or Clang) and GNU make if they are not pre-installed on your system.

  3. Create the vector directory

    mkdir vector
  4. Download Vector's Source

    • Latest (0.7.1)
    • Master
    mkdir -p vector && \
    curl -sSfL --proto '=https' --tlsv1.2 https://api.github.com/repos/timberio/vector/tarball/v0.7.X | \
    tar xzf - -C vector --strip-components=1
  5. Change into the vector directory

    cd vector
  6. Compile Vector

    [FEATURES="<flag1>,<flag2>,..."] make build

    The FEATURES environment variable is optional. You can override the default features with this variable. See feature flags for more info.

    When finished, the vector binary will be placed in target/<target>/release/vector. For example, if you are building Vector on your Mac, your target triple is x86_64-apple-darwin, and the Vector binary will be located at target/x86_64-apple-darwin/release/vector.

  7. Start Vector

    Finally, start vector:

    target/<target>/release/vector --config config/vector.toml

Next Steps

Configuring

The Vector configuration file is located at:

config/vector.toml

A full spec is located at config/vector.spec.toml and examples are located in config/vector/examples/*. You can learn more about configuring Vector in the Configuration section.

Data Directory

We highly recommend creating a data directory that Vector can use:

mkdir /var/lib/vector

Vector offers a global data_dir option that you can use to specify the path of your directory.

vector.toml
data_dir = "/var/lib/vector" # default

Service Managers

Vector archives ship with service files in case you need them:

Init.d

To install Vector into Init.d run:

cp -av distribution/init.d/vector /etc/init.d

Systemd

To install Vector into Systemd run:

cp -av distribution/systemd/vector.service /etc/systemd/system

Updating

Simply follow the same installation instructions above.

How It Works

Feature Flags

The following feature flags are supported via the FEATURES env var when executing make build:

[FEATURES="<flag1>,<flag2>,..."] make build

There are three meta-features which can be used when compiling for the corresponding targets. If no features are specified, then the default one is used.

FeatureDescriptionEnabled by default
defaultDefault set of features for *-unknown-linux-gnu and *-apple-darwin targets.
default-muslDefault set of features for *-unknown-linux-musl targets. Requires cmake and perl as build dependencies.
default-msvcDefault set of features for *-pc-windows-msvc targets. Requires cmake and perl as build dependencies.

Alternatively, for finer control, it is possible to use specific features from the list below:

FeatureDescriptionIncluded in default feature
unixEnables features that require cfg(unix) to be present on the platform, namely support for Unix domain sockets in docker source and jemalloc instead of the default memory allocator.
vendoredForces vendoring of OpenSSL and ZLib dependencies instead of using their versions installed in the system. Requires perl as a build dependency.
leveldb-plainEnables support for disk buffers using vendored LevelDB.
leveldb-cmakeThe same as leveldb-plain, but is more portable. Requires cmake as a build dependency. Use it in case of compilation issues with leveldb-plain.
rdkafka-plainEnables vendored librdkafka dependency, which is required for kafka source and kafka sink.
rdkafka-cmakeThe same as rdkafka-plain, but is more portable. Requires cmake as a build dependency. Use it in case of compilation issues with rdkafka-plain.

Compiling using Docker

It is possible to build statically linked binaries of Vector for Linux using Docker.

In this case the dependencies listed in the previous section are not needed, as all of them would be automatically pulled by Docker.

Building steps:

  1. Download Vector's Source

    • Latest (0.7.1)
    • Master
    mkdir -p vector && \
    curl -sSfL --proto '=https' --tlsv1.2 https://api.github.com/repos/timberio/vector/tarball/v0.7.X | \
    tar xzf - -C vector --strip-components=1
  2. Build Vector using Docker

    • Linux (x86_64)
    • Linux (ARM64)
    • Linux (ARMv7)
    PASS_FEATURES=default-musl ./scripts/docker-run.sh builder-x86_64-unknown-linux-musl make build

    The command above builds a Docker image with Rust toolchain for a Linux target for the corresponding architecture using musl as the C library, then starts a container from this image, and then builds inside the Container. The target binary is located in target/<target triple>/release/vector like in the previous case.

Compiling on Windows

The steps to compile Vector on Windows are different from the ones for other operating systems.

  1. Install Rust using rustup. It would install toolchain for nightly-x86_64-pc-windows-msvc target on 64-bit machines by default. If you don't have VC++ build tools, the installer would prompt you to install them.

  2. Install Perl for Windows.

  3. In a Rust/MSVC environment (for example, using x64 Native Tools Command Prompt) add the binary directory of Perl installed on the previous step to PATH. For example, for default installation of Strawberry Perl it is

    set PATH=%PATH%;C:\Strawberry\perl\bin
  4. Get Vector's source using git:

    • Latest (0.7.1)
    • Master
    git clone https://github.com/timberio/vector
    git checkout v0.7.1
    cd vector
  5. Build Vector in release mode:

    set RUSTFLAGS=-Ctarget-feature=+crt-static
    cargo +nightly-x86_64-pc-windows-msvc build --no-default-features --features default-msvc --release
  6. After these steps a binary vector.exe in target\release would be created. It can be started by running

    .\target\release\vector --config config\vector.toml