Skip to content

How to Build a Log Pipeline with Vector

This guide shows you how to build a log pipeline with Vector, an open-source tool that collects logs and sends them where you need them. You will read logs from journald and files, clean them up, and send them to Loki, a file, or your screen.

This guide walks you through building a log pipeline with Vector, an open-source tool that collects logs from a server and sends them somewhere useful. It is written for admins who want their logs in one searchable place instead of scattered across hosts. A Vector pipeline has three kinds of stages. Sources read logs in, transforms reshape them, and sinks (Vector’s word for destinations) write them out. The whole pipeline lives in one YAML file at /etc/vector/vector.yaml.

You will start from an empty config and add a journald source, which reads from the log service built into systemd (or a file source for plain log files). Next you add a remap transform that turns each raw line into named fields using VRL (Vector Remap Language, a small scripting language built into Vector). Then you connect a sink such as Loki (Grafana’s log storage system), a local file, or the console. Each stage has a name, and each later stage lists by name the stages it reads from. Along the way you check the config with vector validate, watch traffic with vector top, and look at real events as they pass through with vector tap.

What you’ll accomplish

  • Install Vector and confirm the version supports the config you write.
  • Read host logs from a journald source (and a file source as an alternative).
  • Parse each event into structured fields and drop noise with a remap transform in VRL.
  • Send parsed events to a sink — Loki for production, console or file while you develop.
  • Validate the topology, run it under systemd, and inspect live events with vector tap.

Prerequisites

  • A running Linux host (systemd-based, so journald is available). Vector runs on Debian, Ubuntu, RHEL, and their derivatives.
  • Vector 0.40 or newer. Older releases used a slightly different VRL standard library and some functions behave differently.
  • Root or sudo access to install the package, read the journal, and manage the service.
  • The config file lives at /etc/vector/vector.yaml. Vector also accepts TOML and JSON; this guide uses YAML because it is the format the official examples default to.
  • Optional: a reachable Loki endpoint (for example http://loki.internal:3100). If you do not have one yet, the pipeline still works against a console or file sink, and you can add Loki later. See our guide on deploying Loki and Promtail if you need to stand one up.

How it works

Vector models a pipeline as a directed graph of three component kinds. Sources pull or receive raw events — journald reads the systemd journal, file tails files on disk, and there are dozens of others (syslog, HTTP, Kafka). Transforms take events from one or more components and emit reshaped events; the workhorse is remap, which runs a small program written in VRL. Sinks write events out — to Loki, Elasticsearch, S3, a file, or the console. Each component has a unique key, and every transform and sink lists its inputs by those keys, which is how the graph is wired.

VRL (Vector Remap Language) is a purpose-built expression language for editing events. In a remap transform, the current event is the root object: .message is the raw log line, .host is a field you can set, and functions like parse_json, parse_syslog, and parse_regex turn a string into structured fields. VRL is strongly typed and many functions are fallible — they can error on bad input — so you either handle the error with the ?? coalescing operator or assert success with the ! suffix. That distinction is the single most common source of config errors, and the next sections show both forms.

Internally, events flow through in-memory channels between components, and each sink has a buffer. When a sink’s destination slows down or returns errors, its buffer fills and Vector applies backpressure upstream — sources slow their reads rather than dropping data silently. You can switch a sink’s buffer to disk so a short outage does not lose events, at the cost of disk space you have to watch. The diagram below shows the flow from sources through the VRL transform to sinks.

Vector log pipeline sources transforms and sinks topology

Step-by-step

1. Install Vector and confirm the version. Use the official install script or your package manager. On a Debian or Ubuntu host:

curl -1sLf https://setup.vector.dev/apt/setup.deb.sh | sudo -E bash
sudo apt-get install -y vector
vector --version

Expected output — the version must be 0.40 or later:

vector 0.40.0 (x86_64-unknown-linux-gnu)

2. Start from a minimal config with one source and a console sink. Before parsing anything, prove that events flow. Write this to /etc/vector/vector.yaml:

sources:
  host_journal:
    type: journald
    current_boot_only: true

sinks:
  out_console:
    type: console
    inputs:
      - host_journal
    encoding:
      codec: json

The console sink prints every event as JSON to stdout, which is the fastest way to see raw structure. If your host has no systemd journal, swap the source for a file source:

sources:
  app_files:
    type: file
    include:
      - /var/log/app/*.log
    read_from: beginning

3. Validate the config before running it. vector validate checks syntax, that every inputs reference resolves, and that VRL compiles:

vector validate /etc/vector/vector.yaml

Expected output:

Validated

4. Add a remap transform to parse and enrich events. Insert a transform between the source and the sink, then repoint the sink’s inputs at the transform. This example parses a JSON application log, adds two fields, and normalizes the level field:

transforms:
  parse_app:
    type: remap
    inputs:
      - app_files
    source: |
      # parse the JSON body; fall back to keeping the raw line on failure
      structured, err = parse_json(.message)
      if err == null {
        . = merge(., structured)
      }
      # enrich every event with static context
      .host = get_hostname!()
      .env = "prod"
      # normalize the level field so downstream queries are consistent
      .level = downcase(string!(.level ?? "info"))

sinks:
  out_console:
    type: console
    inputs:
      - parse_app
    encoding:
      codec: json

Two VRL details matter here. parse_json is fallible, so it returns a (value, error) pair — the structured, err = form captures both instead of aborting. get_hostname!() uses the ! suffix to assert it cannot fail; string!(.level ?? "info") first supplies a default with ??, then asserts the result is a string. Get these wrong and vector validate fails with a type error rather than starting.

5. Filter out events you do not want to ship. Drop noisy debug lines directly in VRL with the abort path, or use a dedicated filter transform. Inside remap:

      # stop processing and drop the event entirely
      if .level == "debug" {
        abort
      }

Aborted events are removed from the stream, so the sink never sees them.

6. Point the pipeline at a real sink. For production, replace the console sink with Loki. Labels should be low-cardinality — use env and level, never a request ID:

sinks:
  to_loki:
    type: loki
    inputs:
      - parse_app
    endpoint: http://loki.internal:3100
    encoding:
      codec: json
    labels:
      host: "{{ host }}"
      env: "{{ env }}"
      level: "{{ level }}"

If you want a durable local copy while developing, a file sink writes newline-delimited JSON:

sinks:
  to_file:
    type: file
    inputs:
      - parse_app
    path: /var/log/vector/parsed-%Y-%m-%d.log
    encoding:
      codec: json

7. Run it under systemd. The package ships a unit file. Enable and start it, then confirm it is active:

sudo systemctl enable --now vector
systemctl status vector --no-pager

Expected output includes an active state and no restart loop:

● vector.service - Vector
     Active: active (running) since ...

If the journald source cannot read the journal, add the service user to the systemd-journal group and restart (see Troubleshooting).

8. Watch throughput with vector top. This terminal UI shows events in and out per component, so you can confirm the source is reading and the sink is writing:

vector top

You should see non-zero counts under the source and sink, and a rising “Events Out” for the sink. Press q to quit.

Validate it works

Confirm each stage independently. First, watch live events flow through a named component with vector tap — it prints the actual events emitted by whatever component you name:

vector tap --outputs-of parse_app

You should see structured JSON with your added fields (host, env, level) present, which proves the VRL ran:

{"host":"web-01","env":"prod","level":"info","message":"request served","status":200}

Then confirm the sink received the data. For a file sink, tail the output:

tail -n 3 /var/log/vector/parsed-2026-07-20.log

Each line is one parsed event as newline-delimited JSON:

{"host":"web-01","env":"prod","level":"info","message":"request served","status":200}

For Loki, query the labels you set — for example with logcli or Grafana, {env="prod", level="error"} should return the parsed lines. Cross-check with vector top: the sink’s “Events Out” should track the “Events In” of your source minus anything you dropped in the filter.

Troubleshooting

vector validate fails with a component error. Almost always an inputs key that does not match a component name, or a YAML indentation slip. Read the error — it names the component and the missing reference. Fix the key and re-run vector validate before touching the service.

VRL type errors: “fallible function call” or “expected string, got null”. A fallible function was used without handling its error, or a field was null where a concrete type was required. Two fixes: assert with ! when you are certain the input is valid (parse_json!(.message)), or coalesce with ?? to supply a fallback (.level = .level ?? "info"). Use ?? for untrusted input and ! only when a failure genuinely means the config is broken.

journald source reads nothing / permission denied. The user Vector runs as must be able to read /var/log/journal. Add it to the journal group and restart:

sudo usermod -aG systemd-journal vector
sudo systemctl restart vector

Confirm with vector top that the source’s event count starts climbing.

Loki sink returns 4xx or auth errors. A 400 usually means a label problem — high-cardinality labels or a timestamp Loki rejects. A 401/403 means missing tenant or basic-auth. Add the X-Scope-OrgID header via the sink’s request.headers, or an auth block, and keep labels to a few low-cardinality fields. Check the sink’s error rate in vector top.

Disk buffer grows without bound. If you set a sink to buffer.type: disk and its destination is down, the buffer keeps events until the disk fills. Cap it with buffer.max_size (bytes) and decide when_full behavior — block applies backpressure, drop_newest sheds load. Monitor the buffer directory under Vector’s data dir so a downstream outage does not fill the volume.

When this is the wrong approach

Vector earns its place when you have more than one source, need real parsing and routing, or ship to several destinations. For a single small host where journald alone is fine and you only ever read logs locally with journalctl, a full pipeline is more moving parts than the problem needs — leave it at the journal.

If a collector is already in place and fits, do not replace it for its own sake. A Kubernetes cluster already running Promtail or the Grafana observability stack gets little from swapping in Vector. Fluent Bit is a reasonable choice when you want the smallest possible footprint on edge nodes and do not need VRL’s transform power. Reach for Vector when its parsing, filtering, and multi-sink routing solve a problem your current tool cannot.

For the official reference on components and VRL, see the Vector documentation.

If alerts fire into an empty room after hours, that’s exactly what 24/7 Monitoring & Response closes — book a monitoring and response review.