Knowledge

A log-collection Compose stack: VictoriaLogs, Vector and rsyslog

Updated 2026-11-08 · Present

Estimated time: 50 minutes.

Quick summary

Step 1 — Build the directory structure for the stack

Three components in one project directory: compose.yaml, vector.yaml and the data directory. Every ./... path in a compose file is resolved relative to the location of that file itself (Compose file reference).

When it breaks: If files are scattered around, bind mounts point to the wrong place: Vector receives an empty configuration file, or VictoriaLogs writes data into an unintended directory.

mkdir -p ~/docker-practice/observability-lab/victoria-logs-data
cd ~/docker-practice/observability-lab
ls -la

Observe with:

pwd ; ls -la ; tree -L 2 (if available)

Notes: The victoria-logs-data directory must exist and be writable before startup, otherwise the VictoriaLogs container will restart continuously.

Step 2 — Write vector.yaml with three log sources

http_server receives JSON from applications, syslog receives logs from other servers, docker_logs collects the logs of every container on the host. The remap transform applies only to the HTTP source; the other two sources go into the sink as they are (http_server, syslog, docker_logs).

When it breaks: The old encoding key of http_server has been replaced by decoding.codec — copying old documentation makes Vector fail to start.

cat > vector.yaml <<'EOF'
api:
  enabled: true
  address: 0.0.0.0:8686

sources:
  http_input:
    type: http_server
    address: 0.0.0.0:9000
    decoding:
      codec: json

  source_syslogudp:
    type: syslog
    address: 0.0.0.0:9514
    mode: udp

  source_docker:
    type: docker_logs

transforms:
  normalize:
    type: remap
    inputs:
      - http_input
    source: |
      .timestamp = now()
      .host = "docker-lab"
      .source = "vector-http"
      if !exists(.message) {
        .message = encode_json(.)
      }

sinks:
  victorialogs:
    type: http
    inputs:
      - normalize
      - source_syslogudp
      - source_docker
    uri: http://victorialogs:9428/insert/jsonline?_stream_fields=host,source&_msg_field=message&_time_field=timestamp
    compression: gzip
    encoding:
      codec: json
    framing:
      method: newline_delimited
    healthcheck:
      enabled: false
EOF

cat vector.yaml

Observe with:

cat vector.yaml ; compare the input names in the sink with the declared source names

Notes: The three parameters on the uri tell VictoriaLogs which field is the content, which field is the time, and which pair of fields identifies the log stream. Note that .timestamp = now() overwrites the application's original timestamp — acceptable only in a lab.

Step 3 — Understand why the sink points to a service name, not an IP

Two services on the same observability-net network resolve each other through internal DNS by service name. Inside the Vector container, 127.0.0.1 is itself — not VictoriaLogs (VictoriaLogs: receiving logs from Vector).

When it breaks: Putting loopback here makes Vector run normally, with no obvious connection error, yet VictoriaLogs stays empty — the hardest kind of bug to find in this exercise.

grep -n "uri:" vector.yaml
docker compose exec vector getent hosts victorialogs

Observe with:

grep uri vector.yaml ; docker compose exec vector getent hosts victorialogs (after up)

Symptoms when it breaks:

How to fix:

  1. Change the uri to the service name, then recreate the vector service

    sed -i "s#http://127.0.0.1:9428#http://victorialogs:9428#" vector.yaml && docker compose up -d
    

Notes: The VictoriaLogs container uses a distroless base image and therefore has no shell — an exec into it always fails. That is how the image is designed. The fact that Vector sends logs successfully is already proof that internal DNS works.

Step 4 — Write compose.yaml for the stack's two services

VictoriaLogs receives its parameters through command and mounts the data directory from the host; Vector depends on VictoriaLogs through depends_on, publishes three ports and mounts three things: the configuration file, the Docker socket and Docker's log directory (Compose file reference, Compose: depends_on).

When it breaks: Without the /var/run/docker.sock mount, the docker_logs source is silent; without the bind mount for the data directory, logs are lost the first time the container is recreated.

cat > compose.yaml <<'EOF'
services:
  victorialogs:
    image: docker.io/victoriametrics/victoria-logs:v1.52.0
    container_name: victorialogs-lab
    restart: unless-stopped
    command:
      - -storageDataPath=/victoria-logs-data
      - -retentionPeriod=7d
    ports:
      - "9428:9428"
    volumes:
      - ./victoria-logs-data:/victoria-logs-data
    networks:
      - observability-net

  vector:
    image: timberio/vector:0.57.0-debian
    container_name: vector-lab
    restart: unless-stopped
    depends_on:
      - victorialogs
    ports:
      - "8686:8686"
      - "9000:9000"
      - "9514:9514/udp"
    volumes:
      - ./vector.yaml:/etc/vector/vector.yaml:ro
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
      - type: bind
        source: /var/lib/docker
        target: /var/lib/docker
    networks:
      - observability-net

networks:
  observability-net:
    driver: bridge
EOF

docker compose config

Observe with:

docker compose config ; docker inspect vector-lab --format "{{json .Mounts}}" (after up)

Notes: The image tags are pinned so the lab is reproducible. depends_on only guarantees the startup order, not that VictoriaLogs is ready to accept connections — Vector retries on its own, which is enough for this exercise.

Step 5 — Validate in two layers before creating any container

Layer one is docker compose config for compose syntax. Layer two is a temporary container running vector validate against the exact configuration file that will be used — catching errors before any service has been created (docker compose config).

When it breaks: If you skip layer two, Vector configuration errors only surface once the stack is half-running, and the error message is buried in the merged log of the whole project.

docker compose config

docker run --rm \
  -v "$PWD/vector.yaml:/etc/vector/vector.yaml:ro" \
  timberio/vector:0.57.0-debian \
  validate /etc/vector/vector.yaml

Observe with:

The output of compose config ; the Validated line at the end of the vector validate output

Symptoms when it breaks:

How to fix:

  1. Check that the configuration file is a real file, not a symbolic link

    ls -l vector.yaml ; readlink -f vector.yaml
    
  2. Fix the configuration until validate is clean before running up

    docker run --rm -v "$PWD/vector.yaml:/etc/vector/vector.yaml:ro" timberio/vector:0.57.0-debian validate /etc/vector/vector.yaml
    

Step 6 — Start the stack and check each port

up -d pulls the images and then creates the two containers in the order given by depends_on. Check the ports with ss before curl to tell "the service is not listening" apart from "the service is listening but returns an error" (VictoriaLogs quickstart).

When it breaks: If you jump straight to the web interface without checking the ports, you cannot tell which layer the failure is in when the page does not open.

docker compose up -d
docker compose ps
ss -lntp | grep -E ":(9428|8686|9000) "
ss -lnup | grep -E ":9514 "
curl -s http://127.0.0.1:9428/ | head -5
curl -s http://127.0.0.1:8686/health

Observe with:

docker compose ps ; ss -lntp filtered for 9428/8686/9000 ; curl the health endpoint

Symptoms when it breaks:

How to fix:

  1. Grant write permission on the bind-mount directory on the host, then restart

    sudo chown -R "$(id -u):$(id -g)" ./victoria-logs-data && chmod 755 ./victoria-logs-data && docker compose up -d
    

Notes: The query interface opens at http://<IP_DOCKER_HOST>:9428/select/vmui — it is built into VictoriaLogs, nothing extra to install.

Step 7 — Inject logs through the HTTP source and verify

The simplest source, used to confirm that the path from Vector to VictoriaLogs works before trying the other two sources (Vector: http_server).

When it breaks: If you try all three sources at once and see nothing, you cannot tell where it is stuck — accept them one at a time to narrow the scope.

curl --fail --show-error \
  -X POST -H 'Content-Type: application/json' \
  -d '{"message":"hello from docker vector lab","level":"info","app":"demo-web"}' \
  http://127.0.0.1:9000/

for i in 1 2 3 4 5; do
  curl --silent --show-error \
    -X POST -H 'Content-Type: application/json' \
    -d "{\"message\":\"docker lab event $i\",\"level\":\"info\",\"app\":\"demo-web\"}" \
    http://127.0.0.1:9000/
done

docker compose logs --tail 50 vector

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query=_msg:"docker lab"' \
  --data-urlencode 'limit=20'

Observe with:

docker compose logs --tail 50 vector ; a LogsQL query on _msg

Notes: The nested double quotes in the loop must be escaped as " because the variable $i has to be expanded — outer single quotes would not expand it.

Step 8 — Collect the logs of every container through the docker_logs source

The docker_logs source receives logs directly through Docker and automatically attaches labels for container name, ID and image — so containers created later are still collected without changing the configuration (Vector: docker_logs).

When it breaks: Without the Docker socket mount, this source is completely silent: the service is up, the configuration is valid, and no container logs arrive.

docker inspect vector-lab --format '{{json .Mounts}}'

docker run --rm hello-world

curl -s http://127.0.0.1:8080/does-not-exist >/dev/null 2>&1 || true

docker compose logs --tail 30 vector

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query=container_name:*' \
  --data-urlencode 'limit=20'

Observe with:

docker inspect vector-lab --format "{{json .Mounts}}" ; vmui filtered by container_name

Symptoms when it breaks:

How to fix:

  1. Add the Docker socket bind mount to the vector service, then recreate it

    docker compose up -d --force-recreate vector
    

Notes: The container_name and image labels are already parsed by Vector in the Docker style, with no extra configuration — this is the advantage of collecting through Docker over reading log files.

Step 9 — Push syslog from a client machine to Vector

The client machine does not need Docker installed: add one line to /etc/rsyslog.conf pointing to port 9514 of the host running the stack. One @ sign means UDP, two @@ signs mean TCP (rsyslog: actions, Vector: syslog).

When it breaks: If the protocol is declared inconsistently in three places — rsyslog, the mode in vector.yaml, and the way the port is published in compose — the connection fails with a very vague error message.

timedatectl

timedatectl set-timezone Asia/Ho_Chi_Minh
timedatectl set-ntp true
timedatectl

hostnamectl set-hostname client-01

cat >> /etc/rsyslog.conf <<'EOF'
*.* @<IP_DOCKER_HOST>:9514
EOF

systemctl restart rsyslog
systemctl status rsyslog --no-pager

logger "test message from client-01"

Observe with:

timedatectl on both machines ; ss -lnup | grep 9514 on the host ; vmui filtered by the client's host

Symptoms when it breaks:

How to fix:

  1. Set the timezone and enable NTP sync on both machines, then try again

    timedatectl set-timezone Asia/Ho_Chi_Minh && timedatectl set-ntp true && timedatectl
    
  2. Cross-check the protocol in three places: rsyslog (@ or @@), the mode in vector.yaml, and the protocol used when publishing the port

    grep -n "9514" /etc/rsyslog.conf vector.yaml compose.yaml
    
  3. To use TCP, change all three places: @@ in rsyslog, mode tcp in vector, and publish the TCP port

    docker compose up -d --force-recreate vector
    

Notes: Setting the hostname and timezone as soon as the machine is created is a step of the machine provisioning procedure, not something to fix later — the hostname is the label used to filter logs afterwards.

Step 10 — Query LogsQL in vmui

Start with a broad query to confirm there are logs, then narrow down: by content with _msg:, by log stream with {host="..."}, by container with container_name (LogsQL).

When it breaks: An empty query caused by a time window that is too narrow is often misread as logs not having arrived, leading to changes to a configuration that was correct.

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query=*' \
  --data-urlencode 'limit=20'

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query={host="docker-lab"}' \
  --data-urlencode 'limit=20'

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query=_msg:"404"' \
  --data-urlencode 'limit=20'

Observe with:

The vmui interface at :9428/select/vmui — the query tab and the overview tab to see the distribution

Notes: In the interface, increase the number of displayed rows and widen the time window from 5 minutes to 15 minutes before concluding there are no logs. The overview tab shows the distribution by image and container for quick scoping.

Step 11 — Verify persistence through down and then up

The data lives on the ./victoria-logs-data bind mount, so the container lifecycle does not affect it. The test: send an identifiable message, run down, up -d, then query for exactly that message again (Docker: bind mounts).

When it breaks: If you skip this check, a log-loss incident only surfaces when replacing containers in a real environment, exactly when you need the logs to investigate.

curl --fail --show-error \
  -X POST -H 'Content-Type: application/json' \
  -d '{"message":"persistent-log-before-recreate","level":"info"}' \
  http://127.0.0.1:9000/

du -sh ./victoria-logs-data

docker compose down
docker compose up -d

curl --get --fail --show-error \
  http://127.0.0.1:9428/select/logsql/query \
  --data-urlencode 'query=_msg:"persistent-log-before-recreate"' \
  --data-urlencode 'limit=20'

docker compose logs --tail 30
docker stats --no-stream victorialogs-lab vector-lab

Observe with:

du -sh ./victoria-logs-data before/after ; query again for the message that was sent

Notes: down does not delete the bind-mount directory. To delete the lab data you must rm that directory manually, and that action cannot be undone.

Step 12 — Position Compose on the scale spectrum and prepare the path to Kubernetes

Compose orchestrates on a single host: if the host dies, every service on that host dies, and there is no mechanism to move a service to another machine. The layer above is cluster orchestration with a separate control-plane and workers (Kubernetes: components, Docker: Swarm mode).

When it breaks: Moving to a cluster too early means taking on one more system to operate, when the original problem only needed good control of volumes and networks.

docker info --format "Server version: {{.ServerVersion}}"
docker compose ls
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"

Observe with:

docker info to see the number of nodes ; compare the number of servers and services in the system you actually operate

Notes: A commonly used pragmatic threshold: with fewer than 10 servers and an application that is not too large, Docker with Compose is enough. When you genuinely must move to a cluster, the vocabulary changes — service becomes pod/deployment, volume becomes PersistentVolumeClaim, network becomes a CNI plugin you must choose yourself, with Ingress/Egress added — and manifests must live in Git with CI/CD from day one.

Common misconceptions

Each container has its own network namespace, so its loopback does not lead to another container even on the same host. Services on the same network of a Compose project resolve each other through internal DNS by service name (Compose: networking, VictoriaLogs: receiving logs from Vector). This is the biggest difference when moving a stack from docker run to Compose: the earlier docker run version ran Vector under systemd on the host, so 127.0.0.1:9428 was correct; in the container version that address points back at itself. The characteristic symptom is that Vector runs normally, with no obvious connection-error logs, yet VictoriaLogs is empty. Consequence: every address in a container's configuration must be written with the service name, never an IP or loopback. In return, container IPs changing after each recreation has no effect at all.

The docker_logs source connects to Docker to receive the log stream of running containers together with name/ID/image labels (Vector: docker_logs). When Vector runs in a container, the path to Docker is the host's socket — so the container version must mount it explicitly (Vector: install on Docker). Two ways of granting permission for the same purpose: the systemd installation only needs the user running Vector to be in the docker group; the container version needs the socket mounted. Both fail silently — the service is up, the configuration is valid, there are just no logs arriving. Security consequence: mounting /var/run/docker.sock is equivalent to granting that container control of the whole host's Docker. Only do it with a trusted agent, and do not expose the agent's management port to an untrusted network (Docker: bind mounts).

Logs are tied to timestamps; if the sending machine has a timezone mismatch or is not NTP-synchronized, the message still arrives but falls outside the time window being viewed in the interface, which looks like "no logs" (timedatectl). The second trap is the protocol: rsyslog uses one @ sign for UDP and two @@ signs for TCP (rsyslog: actions), while Vector's syslog source declares the mode explicitly (Vector: syslog) and compose publishes the port with its own protocol. These three places must agree. A common mistake: the port is published as TCP by default while vector.yaml declares mode udp, so telnet to that port fails to connect — which is exactly as it should be, not a fault. Consequence for the order of diagnosis: check timedatectl on both machines and cross-check the protocol in three places BEFORE opening the firewall or reading Vector's logs.

By default a container writes into its own writable layer, which is lost with the container. But this stack mounts the data directory from outside via a bind mount and passes -storageDataPath pointing at exactly that mount point, so storage lives independently of the container lifecycle (Docker: bind mounts, VictoriaLogs quickstart). The acceptance test is: send a message with identifiable content, run down then up -d, and query for exactly that message again. If it is lost, the fault is in the mount or in the storageDataPath parameter, not in the down command. Consequence: down can be used freely to free ports and clean up containers. To delete the data for real you must delete the directory on the host manually — and that action cannot be undone.

Compose is a single-host tool; for multiple hosts you must move up to cluster orchestration, which has a separate control-plane and workers along with a scheduler (Kubernetes: components). Docker Swarm used to be a middle path, but the ecosystem around it has been thinning out (Docker: Swarm mode). The pragmatic advice runs against the usual expectation: with fewer than 10 servers and an application that is not too large, Docker with Compose is enough — good control of volumes and networks already solves the problem, and it is much leaner and easier to maintain. Building a cluster just to run a log-collection system is operational cost that is not worth it. Consequence when you genuinely must move: both the vocabulary and the way of thinking change — service becomes pod/deployment, volume becomes PersistentVolumeClaim, network becomes a CNI plugin you must choose yourself, with Ingress/Egress added. And the prerequisite is that manifests live in Git with CI/CD from day one, never hand-edited on the servers.

Hands-on 1 — Build the log-collection stack with Compose

30 minutes

Rewrite the log-collection system built in the VictoriaLogs lesson as a single compose file, validate in two layers, then start it — acceptance through the HTTP source is the simplest path (VictoriaLogs quickstart).

docker compose config && docker compose up -d

Observe: docker compose ps ; ss filtered for 9428/8686/9000 ; curl Vector's /health ; vmui at :9428/select/vmui

1. Create ~/docker-practice/observability-lab/victoria-logs-data and then cd into the project directory.

The data directory exists and is writable.

2. Write vector.yaml with three sources (http_server :9000, syslog :9514 mode udp, docker_logs), a remap transform that applies only to the HTTP source, and a single sink merging all three that points to http://victorialogs:9428/insert/jsonline?....

The file reads back with the right content; the input names in the sink match the declared source names.

3. Write compose.yaml: the victorialogs service (command -storageDataPath and -retentionPeriod=7d, port 9428, bind mount ./victoria-logs-data) and the vector service (depends_on, ports 8686/9000/9514 udp, mounts vector.yaml:ro + /var/run/docker.sock + /var/lib/docker), network observability-net.

The file exists with the correct three-component structure in the project directory.

4. Validate layer one: docker compose config. Validate layer two: docker run --rm -v "$PWD/vector.yaml:/etc/vector/vector.yaml:ro" timberio/vector:0.57.0-debian validate /etc/vector/vector.yaml.

Both commands are clean. If there is an error, fix it until clean before moving to the next step.

5. docker compose up -d then docker compose ps, ss -lntp | grep -E ":(9428|8686|9000) " and curl -s http://127.0.0.1:8686/health.

Both services are Up; three TCP ports are listening; Vector's health endpoint responds.

6. Inject one JSON message into :9000, then the 5-message loop, then query _msg:"docker lab".

The query returns exactly the messages just sent; Vector's log has no ERROR lines related to the sink.

Analysis

Observation: The whole stack comes up with a single command, and the validate step catches errors before any container is created.

Mechanism: Compose creates the network and then the two containers in the order given by depends_on; Vector calls VictoriaLogs through internal DNS by service name.

Lesson: Internal infrastructure should also be described by configuration in Git, not by two different installation procedures.

Troubleshooting:

Hands-on 2 — Collect every container's logs and search with LogsQL

25 minutes

Verify the docker_logs source: containers created AFTER the agent started are still collected, and the name/image labels are available for filtering with no extra configuration (Vector: docker_logs, LogsQL).

docker inspect vector-lab --format '{{json .Mounts}}'

Observe: The Mounts list of vector-lab ; the vmui query tab and overview tab

1. Check the mounts: docker inspect vector-lab --format '{{json .Mounts}}'.

All three mounts are present: vector.yaml, /var/run/docker.sock and /var/lib/docker.

2. Run a new container: docker run --rm hello-world.

That container's log appears in vmui — a container created after the agent is still collected.

3. Generate load against a running web container, including a non-existent path to produce a 404 status.

The web access log appears in the centralized log.

4. In vmui, query container_name:*, then open the overview tab, increase the number of displayed rows and widen the time window to 15 minutes.

You see the log distribution by container_name and image, already parsed in the Docker style.

5. Filter progressively: _msg:"404", then {host="docker-lab"}, then container_name:"<container-name>".

Each query narrows down to exactly the expected set of logs.

6. Send an identifiable message, run docker compose down then up -d, and then query for that same message again.

The old log can still be queried — proof that the data lives on the host's bind mount.

Analysis

Observation: Logs from new containers appear without changing the agent configuration; the name and image labels are available for filtering.

Mechanism: The docker_logs source receives the log stream directly through the Docker socket together with container metadata, so containers created later still fall within the collection scope.

Lesson: Collecting through Docker rather than reading log files is the right choice: the container ID changes every time it is recreated, while the labels are always there.

Troubleshooting:

Hands-on 3 — Push syslog from a client machine and handle two classic traps

30 minutes

A machine without Docker can also push logs: rsyslog points to Vector's syslog port. This exercise drills the two most silent traps — time mismatch and protocol mismatch (rsyslog: actions, timedatectl).

timedatectl && systemctl restart rsyslog

Observe: timedatectl on both machines ; ss -lnup | grep 9514 on the host ; vmui filtered by the client's hostname

1. On the client machine, set the hostname and timezone and enable NTP: hostnamectl set-hostname client-01, timedatectl set-timezone Asia/Ho_Chi_Minh, timedatectl set-ntp true.

timedatectl shows the correct timezone and NTP synchronized is yes.

2. Compare timedatectl on the machine running the stack with the client machine.

Both machines have the same timezone and the same time, off by no more than a few seconds.

3. Add the line *.* @<IP_DOCKER_HOST>:9514 to /etc/rsyslog.conf, then systemctl restart rsyslog and check systemctl status rsyslog.

The service is active (running), with no configuration errors.

4. Generate a message: logger "test message from client-01", then find it in vmui.

The message appears, and its timestamp matches the real time.

5. Try nc -zv <IP_DOCKER_HOST> 9514 (or telnet if it is installed — Ubuntu 24.04 minimal does not ship it).

The connection fails — as expected, because the configuration is UDP. This is the common protocol trap.

6. Switch to TCP in all three places: @@ in rsyslog, mode: tcp in vector.yaml, and publish the TCP port in compose. Run validate again, then up -d.

telnet connects and logs still arrive — proving the three places must match each other.

Analysis

Observation: Whether logs arrive depends on two conditions outside the agent configuration: correct time and a matching protocol.

Mechanism: Logs are tied to timestamps, so a time mismatch pushes messages outside the window being viewed; the protocol is declared in three places and the connection only succeeds when all three match.

Lesson: Order of diagnosis: check the time and protocol first, open the firewall afterwards. Setting the hostname and timezone as soon as the machine is created is a step of the machine provisioning procedure.

Troubleshooting:

Hands-on 4 — Prepare the Kubernetes lab for the next part

40 minutes · optional

The next part of the learning path is Kubernetes. Set up three nodes in advance and finish the groundwork (hostname, timezone, swap, snapshot) so you do not lose time during the hands-on session (Kubernetes: components).

hostnamectl set-hostname k8s-master && timedatectl set-ntp true && swapoff -a

Observe: hostnamectl ; timedatectl ; swapon --show (must be empty) ; ping between the three nodes

1. Create three virtual machines, each with one network card, with a minimum configuration of about 2 vCPU and 4-8 GB RAM. Roles: one control-plane, two workers.

The three machines can reach each other by ping on the same network range.

2. On each machine, set the hostname by role and a static IP according to the plan: hostnamectl set-hostname k8s-master (then k8s-worker1, k8s-worker2).

hostnamectl returns the right name; the names do not collide.

3. Set the timezone and enable NTP sync on all three machines.

timedatectl shows the correct timezone and NTP synchronized is yes on all three.

4. Turn off swap: swapoff -a and remove the swap line in /etc/fstab so it does not come back after reboot.

swapon --show prints nothing, even after a reboot.

5. Shut the machines down, then take a snapshot of all three labeled "base" — the version that already has the IP, hostname and timezone.

You can return to the base version at any time without reconfiguring from scratch.

6. Optional: set up an additional centralized-log node running exactly the VictoriaLogs + Vector stack from this lab, or use the control-plane node itself for that role.

All three nodes can push syslog to the log node — reusing exactly the configuration done in the previous phase.

7. Redraw the lab model yourself, with the IP of each node, and save it along with your lab notes.

The diagram clearly shows each node's role, the network range and the IPs — for quick lookup during an incident.

Analysis

Observation: Most of the time lost when practicing with a cluster goes into setting up the machines, not into cluster knowledge.

Mechanism: A cluster requires unique hostnames, synchronized time and swap off; if any one of the three is missing, the cluster initialization step fails with hard-to-read errors.

Lesson: Finish the groundwork and then snapshot: every retry starts from a known clean state.

Troubleshooting:

Review questions

Question 1. In a vector.yaml running in a container, which VictoriaLogs address should the sink point to?

  1. http://127.0.0.1:9428 because the two containers are on the same host
  2. http://victorialogs:9428 — the service name, resolved through the project network's internal DNS
  3. http://localhost:9428 because Compose automatically maps localhost between services
  4. The VictoriaLogs container IP obtained with docker inspect

Answer: http://victorialogs:9428 — the service name, resolved through the project network's internal DNS. Each container has its own network namespace, so its loopback is itself. Services on the same network resolve each other by service name (Compose: networking, VictoriaLogs: Vector setup).

Question 2. Vector runs in a container, the configuration is valid, the HTTP source works, but no container logs arrive. What is the most likely cause?

  1. The bind mount /var/run/docker.sock is missing for the vector service
  2. The docker group permission has not been granted to the user inside the container
  3. VictoriaLogs does not have retention enabled
  4. Docker has not changed its log driver to json-file

Answer: The bind mount /var/run/docker.sock is missing for the vector service. The docker_logs source needs Vector to be able to talk to Docker. When Vector runs in a container, that path is the host's Docker socket, so it must be mounted explicitly (Vector: install on Docker).

Question 3. In /etc/rsyslog.conf, what does the line ". @192.0.2.10:9514" mean?

  1. Send all logs over TCP to 192.0.2.10 port 9514
  2. Send all logs over UDP to 192.0.2.10 port 9514
  3. Receive logs from 192.0.2.10 on port 9514
  4. Write logs to a file on the machine 192.0.2.10

Answer: Send all logs over UDP to 192.0.2.10 port 9514. One @ sign means UDP, two @@ signs mean TCP (rsyslog: actions). This protocol must match the mode declared in Vector's syslog source and the way the port is published in compose.

Question 4. The client machine's logs do not appear in the interface even though rsyslog was restarted and reports no errors. What should you check BEFORE opening the firewall?

  1. Increase VictoriaLogs retention
  2. Change Docker's log driver
  3. timedatectl on both machines: the timezone matches and NTP is synchronized
  4. Restart the whole stack with down and then up

Answer: timedatectl on both machines: the timezone matches and NTP is synchronized. Logs are tied to timestamps: a timezone mismatch or missing NTP sync makes messages arrive but fall outside the time window being viewed, which looks like there are no logs (timedatectl). This is the most silent cause, and checking it is very quick.

Question 5. Why should you run vector validate in a temporary container before docker compose up?

  1. To download the Vector image beforehand to save time
  2. To catch Vector configuration errors before any service has been created
  3. Because compose config cannot read the vector.yaml file
  4. Because Vector does not check its configuration on startup

Answer: To catch Vector configuration errors before any service has been created. With a bad configuration the service does not start and the error message is buried in the merged log of the whole project. Checking beforehand with a temporary container gives a clean error message, pointing at exactly the misconfigured block, and leaves no container to clean up.

Question 6. After docker compose down and then up -d, can the old logs still be queried, and why?

  1. No, because down removes the container so the data inside is lost with it
  2. Yes, because the data lives on the host's ./victoria-logs-data bind mount
  3. Yes, because VictoriaLogs automatically backs up into a cache
  4. Only if you had run docker compose stop instead of down

Answer: Yes, because the data lives on the host's ./victoria-logs-data bind mount. The -storageDataPath parameter points at the mount point, and that mount point is a real directory on the host. The data is outside the container lifecycle, so after down and then up -d it can still be queried (Docker: bind mounts).

Question 7. Where do the container_name and image labels in the logs on VictoriaLogs come from?

  1. From being declared in the remap transform of vector.yaml
  2. From the docker_logs source, which attaches them automatically when collecting logs through Docker
  3. From VictoriaLogs inferring them from the log content
  4. From having to set _stream_fields=container_name,image on the uri

Answer: From the docker_logs source, which attaches them automatically when collecting logs through Docker. The docker_logs source receives logs directly through Docker together with the container metadata: name, ID, image (Vector: docker_logs). No extra configuration is needed — that is the advantage over reading log files.

Question 8. According to the pragmatic threshold given in the lesson, at what scale is Kubernetes not yet needed?

  1. Fewer than 3 servers
  2. Fewer than about 10 servers and an application that is not too large — Docker with Compose is enough
  3. Only when there is exactly one server
  4. When there is no need for centralized logging

Answer: Fewer than about 10 servers and an application that is not too large — Docker with Compose is enough. Compose orchestrates on a single host, but good control of volumes and networks already solves most of the problem at this scale, and it is leaner and easier to maintain than a cluster (Kubernetes: components).

Question 9. Why does the command docker compose exec victorialogs sh always fail?

  1. Because that service was not declared in the network
  2. Because the VictoriaLogs image is distroless, with no shell inside
  3. Because of missing permission on the Docker socket
  4. Because you must use docker exec instead of docker compose exec

Answer: Because the VictoriaLogs image is distroless, with no shell inside. The image uses a distroless base — only the necessary process, with no shell packaged. That is how the image is designed, not a fault. The fact that Vector sends logs successfully is already proof that internal DNS and networking work.

Flashcards