Skip to content

Deploying Vector (by Datadog, OSS) on AlmaLinux 9 with reshape transforms and dual sink

Install Vector OSS as a logs + metrics router on AlmaLinux 9 — VRL transforms for reshaping events, dual sink (Clickhouse + Loki), disk buffer, and acknowledgement-aware backpressure.

You have three log shippers running today — one for application logs, one for syslog, one for cloud audit feeds. Each parses fields differently. Each retries differently. When the destination changes, you touch three configs. The case for collapsing onto a single agent is obvious; the case against is that “one agent” usually means committing to one vendor’s data model. Vector (Datadog’s open-source observability pipeline, MPL-2.0 licensed and operable without any Datadog SaaS) is the alternative — it speaks every source format, transforms with a typed scripting language (VRL), and routes to as many sinks as you want with per-sink buffering and acknowledgement-aware backpressure. Below is the AlmaLinux 9 installer that does it properly.

What’s happening

Vector’s pipeline is sources → transforms → sinks, all declared in a single TOML/YAML config. Sources pull events: file, journald, kafka, syslog, http_server, prometheus_scrape. Transforms reshape: remap (the VRL transform — typed, fast, the workhorse), filter, route, reduce, dedupe, throttle. Sinks ship out: clickhouse, loki, elasticsearch, aws_s3, kafka, prometheus_remote_write. The piece that distinguishes Vector from older shippers is end-to-end acknowledgements — when a sink supports it, Vector only marks a source’s event as “delivered” once the sink has confirmed write. On disk-buffered sinks that’s also when the source is allowed to advance its read pointer. Combined with buffer.type = "disk" on every sink, this gives you a pipeline that survives sink outages and agent restarts without losing or duplicating events. The other piece operators underestimate is VRL — it’s a real typed language with compile-time errors, abortable transforms, and metric-emitting primitives. You can do parsing that would be a Lua filter chain in Fluent Bit in three lines of VRL.

How to verify

After the agent is running, four checks confirm the pipeline is healthy:

# 1. Service is up and the config validated at start
systemctl status vector --no-pager
journalctl -u vector -n 50 --no-pager

# 2. Vector's API exposes per-component metrics
curl -s http://127.0.0.1:8686/graphql -X POST -H 'Content-Type: application/json' \
  -d '{"query":"{ sources { edges { node { componentId metrics { receivedEventsTotal { receivedEventsTotal } } } } } }"}' | jq

# 3. Disk buffer for each sink — should not exceed configured limit
du -sh /var/lib/vector/buffers/*/

# 4. Validate the config without restarting
vector validate /etc/vector/vector.toml

The GraphQL endpoint is the right place to look. receivedEventsTotal per source and sentEventsTotal per sink should both be climbing. If a sink’s buffer-on-disk is at its max_size, you’ll see discardedEventsTotal climb — that’s data being dropped because the destination has been unreachable for too long. Either fix the destination or raise the buffer ceiling.

The fix

Save the script as /root/setup-vector.sh, edit the destinations at the top (CH_HOST, LOKI_URL, etc.), and run as root on AlmaLinux 9. The installer adds the official Timber repository, installs the vector RPM, lays out /var/lib/vector/buffers/ with the right ownership, drops in a TOML config with: journald + file sources, a remap VRL transform that parses, normalizes service/host/environment fields, and emits one of three event categories, a route transform that fans out by category, a Clickhouse sink (analytical) with bulk batching, a Loki sink (operational) with label sanitization, and a prometheus_exporter sink so a Prometheus scrape can read Vector’s internal metrics. systemd unit ships with LimitNOFILE=200000, disk buffers per sink, and acknowledgements wired source-to-sink.

#!/usr/bin/env bash
set -euo pipefail

### AlmaLinux 9 Vector OSS deployment — logs router, dual sink
### Pipeline: file/journald -> remap (VRL) -> route -> Clickhouse + Loki
### Run as root. Edit the destination block.

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT ME ===
NODE_NAME="$(hostname -s)"
ENVIRONMENT="prod"
CH_HOST="clickhouse.example.internal"
CH_PORT="8123"
CH_DB="logs"
CH_TABLE="events"
CH_USER="vector"
CH_PASS="CHANGE_ME_CH"
LOKI_URL="https://loki.example.internal/loki/api/v1/push"
LOKI_TENANT="ops"
# ===============

echo
echo "========================================"
echo "Vector OSS on ${NODE_NAME} (${ENVIRONMENT})"
echo "========================================"
echo

echo "==> Base packages"
dnf -y update
dnf -y install epel-release
dnf -y install curl jq tar gzip ca-certificates

echo "==> Adding Timber/Vector RPM repository"
curl -1sLf 'https://repositories.timber.io/public/vector/cfg/setup/bash.rpm.sh' | bash

echo "==> Installing vector"
dnf -y install vector

echo "==> Buffer + config directories"
mkdir -p /var/lib/vector/buffers/clickhouse \
         /var/lib/vector/buffers/loki \
         /etc/vector
id -u vector >/dev/null 2>&1 || useradd -r -s /sbin/nologin -d /var/lib/vector vector
chown -R vector:vector /var/lib/vector

echo "==> Writing vector.toml"
cat > /etc/vector/vector.toml <<EOF
# ---------- GLOBAL ----------
data_dir = "/var/lib/vector"

[api]
enabled = true
address = "127.0.0.1:8686"

# ---------- SOURCES ----------
[sources.journald]
type = "journald"
current_boot_only = false
include_units = []
exclude_units = []
batch_size = 16
acknowledgements.enabled = true

[sources.app_logs]
type = "file"
include = ["/var/log/app/*.log", "/var/log/app/*.json.log"]
ignore_older_secs = 86400
read_from = "beginning"
fingerprint.strategy = "checksum"
fingerprint.bytes = 256
oldest_first = true
acknowledgements.enabled = true

[sources.nginx_access]
type = "file"
include = ["/var/log/nginx/access.log"]
read_from = "beginning"
fingerprint.strategy = "checksum"
fingerprint.bytes = 256
acknowledgements.enabled = true

[sources.audit]
type = "file"
include = ["/var/log/audit/*.log"]
read_from = "beginning"
fingerprint.strategy = "checksum"
fingerprint.bytes = 256
acknowledgements.enabled = true

# ---------- TRANSFORMS ----------
# Reshape every event into a normalized schema.
[transforms.reshape]
type = "remap"
inputs = ["journald", "app_logs", "nginx_access", "audit"]
drop_on_error = false
drop_on_abort = true
reroute_dropped = true
source = '''
.host = "${NODE_NAME}"
.environment = "${ENVIRONMENT}"

# Normalize timestamps to RFC3339
if !exists(.timestamp) {
  .timestamp = now()
}

# Default category. The route transform below dispatches on this.
.category = "operational"

# ---- journald path
if exists(.SYSTEMD_UNIT) {
  .service = del(.SYSTEMD_UNIT)
  .level = .PRIORITY ?? "6"
  .message = .MESSAGE ?? ""
  .category = "operational"
} else if exists(.file) && string!(.file) == "/var/log/nginx/access.log" {
  # ---- nginx access path: JSON or combined log
  parsed, err = parse_json(.message)
  if err == null {
    . = merge(., parsed)
    .service = "nginx"
    .category = "http"
  } else {
    parsed, err = parse_regex(string!(.message), r'^(?P<remote>\S+) \S+ \S+ \[(?P<ts>[^\]]+)\] "(?P<method>\S+) (?P<path>\S+) \S+" (?P<status>\d+) (?P<bytes>\d+)')
    if err == null {
      . = merge(., parsed)
      .status = to_int!(.status)
      .bytes = to_int!(.bytes)
      .service = "nginx"
      .category = "http"
    }
  }
} else if exists(.file) && contains(string!(.file), "/var/log/audit/") {
  .service = "auditd"
  .category = "audit"
  parsed, err = parse_key_value(string!(.message), key_value_delimiter: "=", field_delimiter: " ")
  if err == null { . = merge(., parsed) }
} else if exists(.file) && contains(string!(.file), "/var/log/app/") {
  # Application JSON
  parsed, err = parse_json(string!(.message))
  if err == null {
    . = merge(., parsed)
    .service = .service ?? "app"
  } else {
    .service = "app"
  }
  .category = "application"
}

# Drop verbose debug from app stream in prod
if .environment == "prod" && string!(.level) == "debug" && .category == "application" {
  abort
}

# Clean keys not allowed by Loki
del(.MESSAGE)
del(.SYSLOG_IDENTIFIER)
del(.__CURSOR)
'''

# Route by category. Vector emits routed.<name> as output names.
[transforms.router]
type = "route"
inputs = ["reshape"]

[transforms.router.route]
http       = '.category == "http"'
audit      = '.category == "audit"'
application = '.category == "application"'
operational = '.category == "operational"'

# Throttle noisy operational repeats — 1000/sec per service is plenty.
[transforms.throttle_ops]
type = "throttle"
inputs = ["router.operational"]
threshold = 1000
window_secs = 1
key_field = "{{ service }}"

# ---------- SINKS ----------
# Clickhouse for analytics: bulk-batched, all categories.
[sinks.clickhouse]
type = "clickhouse"
inputs = ["router.http", "router.audit", "router.application", "throttle_ops"]
endpoint = "http://${CH_HOST}:${CH_PORT}"
database = "${CH_DB}"
table = "${CH_TABLE}"
auth.strategy = "basic"
auth.user = "${CH_USER}"
auth.password = "${CH_PASS}"
compression = "gzip"
batch.max_bytes = 5_000_000
batch.timeout_secs = 5
buffer.type = "disk"
buffer.max_size = 1_073_741_824
buffer.when_full = "block"
acknowledgements.enabled = true
healthcheck.enabled = true

# Loki for operator-facing tail: only http + operational + audit (skip raw app for noise).
[sinks.loki]
type = "loki"
inputs = ["router.http", "router.audit", "throttle_ops"]
endpoint = "${LOKI_URL}"
encoding.codec = "json"
compression = "snappy"
tenant_id = "${LOKI_TENANT}"
batch.max_bytes = 1_048_576
batch.timeout_secs = 1
buffer.type = "disk"
buffer.max_size = 536_870_912
buffer.when_full = "block"
acknowledgements.enabled = true

[sinks.loki.labels]
service = "{{ service }}"
host = "{{ host }}"
environment = "{{ environment }}"
category = "{{ category }}"

# Internal metrics for Prometheus to scrape
[sources.internal_metrics]
type = "internal_metrics"
scrape_interval_secs = 10

[sinks.prometheus]
type = "prometheus_exporter"
inputs = ["internal_metrics"]
address = "127.0.0.1:9598"
EOF

chown vector:vector /etc/vector/vector.toml
chmod 640 /etc/vector/vector.toml

echo "==> Validating config"
vector validate /etc/vector/vector.toml

echo "==> systemd drop-in"
mkdir -p /etc/systemd/system/vector.service.d
cat > /etc/systemd/system/vector.service.d/override.conf <<'EOF'
[Service]
LimitNOFILE=200000
LimitNPROC=8192
Restart=on-failure
RestartSec=5s
EOF

echo "==> SELinux: allow vector to read app + nginx + audit log paths"
if command -v semanage >/dev/null 2>&1; then
  dnf -y install policycoreutils-python-utils || true
fi
semanage fcontext -a -t var_log_t "/var/log/app(/.*)?" || true
restorecon -Rv /var/log/app /var/log/nginx /var/log/audit || true

echo "==> Starting vector"
systemctl daemon-reload
systemctl enable --now vector
sleep 4

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo

echo "Service:"
systemctl is-active vector || true
echo

echo "Recent logs:"
journalctl -u vector -n 20 --no-pager || true
echo

echo "API health:"
curl -s http://127.0.0.1:8686/health || true
echo
echo
echo "Component metrics (received/sent):"
curl -s http://127.0.0.1:8686/graphql -X POST -H 'Content-Type: application/json' \
  -d '{"query":"{ sources { edges { node { componentId metrics { receivedEventsTotal { receivedEventsTotal } } } } } sinks { edges { node { componentId metrics { sentEventsTotal { sentEventsTotal } } } } } }"}' \
  | jq || true
echo
echo "Buffer usage:"
du -sh /var/lib/vector/buffers/* 2>/dev/null || true
echo
echo "Next: confirm rows arriving in Clickhouse table ${CH_DB}.${CH_TABLE} and Loki labels."

Make it executable and run:

chmod 700 /root/setup-vector.sh
/root/setup-vector.sh

When it returns, vector top (run interactively) gives you a live view of events per component and the buffer pressure per sink. Confirm rows in Clickhouse: clickhouse-client -h CH_HOST -q "SELECT count() FROM logs.events WHERE timestamp > now() - INTERVAL 5 MINUTE". Confirm Loki: logcli --addr LOKI_URL query '{environment="prod"}' --limit=10. If the audit path is hot, the operational throttle is probably too tight — raise threshold and reload (systemctl reload vector is supported).

For environments where the pipeline itself becomes a tier — multi-region aggregator nodes, Kafka in the middle, Clickhouse replicas — Stack Harbor operates the full observability layer alongside the workloads under environment management with monitoring + on-call hooked in. Plan it with us.