Self-hosting

Self-Host VictoriaLogs on a VPS: Centralise and Search Logs

When an application runs on several servers, finding an error quickly turns into opening SSH sessions one by one and chaining `grep` commands. Classic centralisation stacks solve the problem, but Elasticsearch needs gigabytes of memory and Loki struggles as soon as you search the text. VictoriaLogs is an open-source log database (Apache-2.0 licensed) from the VictoriaMetrics team: one binary, a few megabytes of RAM at rest, fast full-text search. This guide installs it on a VPS with Docker Compose, publishes it over HTTPS behind nginx, and connects your first servers.

Deploy on a VPS Cloud →
6 min read4 steps
Contents· Why centralise your logs1/11
  1. 01Why centralise your logs
  2. 02What VictoriaLogs brings
  3. 03VictoriaLogs compared with Loki and Elasticsearch
  4. 04Prerequisites
  5. 05Install VictoriaLogs with Docker Compose
  6. 06Without a password, your logs are public
  7. 07Ship your servers' logs with Vector
  8. 08Collect Docker logs with Grafana Alloy or Promtail
  9. 09Search with LogsQL
  10. 10Retention, disk and backup
  11. 11VictoriaLogs in one click on ServOrbit

Why centralise your logs

Every server writes its logs in its own corner: journald for the system, /var/log/nginx for the web server, standard output for your containers. With a single machine, journalctl and docker logs are enough. With three, the question "when did this customer's payment fail, and on which server?" costs a quarter of an hour.

Centralising means shipping every line to a single database as it is written, then querying it from one place. VictoriaLogs plays that database role: an agent on each server — Vector, Fluent Bit, Grafana Alloy or Promtail — sends it the lines, and you find them with a query, from its web interface or from Grafana.

What VictoriaLogs brings

  • LogsQL — full-text search, field and time filters, statistics and grouping in a single query.
  • Works with your agents — Elasticsearch and Loki ingestion APIs, OpenTelemetry and JSON lines.
  • vmui interface — log exploration, filters, hit histogram and result export.
  • Lightweight — one Go binary, a few megabytes of RAM at rest, strong compression on disk.
  • Controlled retention — adjustable retention period and disk usage cap.
  • Grafana — an official data source plugin for your dashboards and alerts.

VictoriaLogs compared with Loki and Elasticsearch

Scroll the table

VictoriaLogsLokiElasticsearch
Text searchFast, full-textSlow without a targeted labelFast, full-text
Memory at restA few megabytesA few hundred megabytesSeveral gigabytes
Components to deployOne binaryOne binary or several servicesA JVM cluster
Query languageLogsQLLogQLQuery DSL, KQL
Compatible agentsElasticsearch, Loki, OpenTelemetryLoki, OpenTelemetryElasticsearch
Built-in interfacevmuiNo, goes through GrafanaNo, goes through Kibana

Prerequisites

An Ubuntu 24.04 VPS with 1 GB of RAM is enough to start; it is the disk you need to size, according to your log volume and the retention you want. You need Docker with the Compose plugin, nginx with an HTTPS certificate, and a stable name — for example logs.example.com — since your servers and Grafana will connect to it.

Install VictoriaLogs with Docker Compose

  1. Prepare the folder and the password

    Create the application folder and a .env file holding the password of the admin user.

    mkdir -p /opt/victorialogs && cd /opt/victorialogs
    echo "ADMIN_PASSWORD=$(openssl rand -hex 16)" > .env
    chmod 600 .env
  2. Write the docker-compose.yml file

    The port is only published on the loopback interface: only nginx reaches it. The two -httpAuth options protect every endpoint — interface, queries and ingestion. -retentionPeriod=30d keeps thirty days, and -retention.maxDiskUsagePercent=80 drops the oldest logs before the disk is full.

    services:
      victorialogs:
        image: victoriametrics/victoria-logs:v1.55.0
        restart: unless-stopped
        ports:
          - "127.0.0.1:9428:9428"
        command:
          - -storageDataPath=/vlogs
          - -retentionPeriod=30d
          - -retention.maxDiskUsagePercent=80
          - -httpAuth.username=admin
          - -httpAuth.password=${ADMIN_PASSWORD}
        volumes:
          - victorialogs-data:/vlogs
    
    volumes:
      victorialogs-data: {}
  3. Start the container

    Startup takes less than a second. The log should show "started VictoriaLogs".

    docker compose up -d
    docker compose logs --tail 20
  4. Publish over HTTPS with nginx

    In your domain's vhost (certificate obtained with certbot), proxy to the local port. Raise client_max_body_size: batches sent by agents quickly exceed the default limit.

    location / {
        proxy_pass http://127.0.0.1:9428;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 64m;
    }

Without a password, your logs are public

Without the -httpAuth options, anyone who knows the address can read all your logs — e-mail addresses, IP addresses, sometimes tokens slipped into a message by mistake — and inject fake ones. Keep authentication enabled, and never publish port 9428 directly on the public IP: always go through the HTTPS reverse proxy.

Ship your servers' logs with Vector

On each server, Vector reads journald and nginx's files, then sends them through VictoriaLogs' Elasticsearch API. The query parameters tell VictoriaLogs which field carries the message, which one carries the timestamp, and which fields identify a stream.

sources:
  journald:
    type: journald
  nginx:
    type: file
    include: ["/var/log/nginx/*.log"]

sinks:
  victorialogs:
    type: elasticsearch
    inputs: [journald, nginx]
    endpoints: ["https://logs.example.com/insert/elasticsearch/"]
    mode: bulk
    api_version: v8
    healthcheck:
      enabled: false
    auth:
      strategy: basic
      user: admin
      password: "<ADMIN_PASSWORD>"
    query:
      _msg_field: message
      _time_field: timestamp
      _stream_fields: host,file

Restart Vector, then open https://logs.example.com/select/vmui/: the first lines appear within seconds. Fluent Bit, Filebeat and Logstash connect the same way, through their Elasticsearch output to /insert/elasticsearch/.

Collect Docker logs with Grafana Alloy or Promtail

If your servers already send their logs to Loki, you only need to change the address: VictoriaLogs accepts Loki's push API. With Grafana Alloy, the loki.write component becomes:

loki.write "victorialogs" {
  endpoint {
    url = "https://logs.example.com/insert/loki/api/v1/push"
    basic_auth {
      username = "admin"
      password = "<ADMIN_PASSWORD>"
    }
  }
}

With Promtail, the same address goes into clients[].url, with a basic_auth block. Labels — container name, service, host — arrive as fields, and can then be filtered in LogsQL.

Search with LogsQL

LogsQL reads from left to right: filter first, compute next. A single word searches the message, field:value filters a field, _time: bounds the period, and a pipe chains a computation.

_time:1h error
_time:1h level:error
_time:24h "commande-42"
_time:1h error | stats by (host) count() errors

The last query counts the last hour's errors per server. The same queries can be sent from the command line, handy in a script or a scheduled task:

curl -u admin:<ADMIN_PASSWORD> \
  https://logs.example.com/select/logsql/query \
  -d 'query=_time:5m error'

Retention, disk and backup

VictoriaLogs stores logs per day, and drops a whole day once it falls outside the retention period. -retentionPeriod accepts days (30d), weeks or years; -retention.maxDiskUsagePercent adds a disk safeguard, dropping the oldest days first. Measure the space actually used after a week (du -sh on the volume) rather than estimating it.

To back up, stop the container while you copy the volume, or copy the folders of past days with rsync, since they no longer change. To upgrade, change the image tag in docker-compose.yml, then docker compose pull && docker compose up -d: the data in the volume is kept.

VictoriaLogs in one click on ServOrbit

On a ServOrbit VPS, the Marketplace does all of the above for you: official container, port on the loopback interface, admin user password generated and shown in your client area, authentication enabled on every endpoint, nginx reverse proxy over HTTPS. You choose the address — a subdomain of one of your domains, or the VPS's free subdomain — and all that is left is configuring your agents. For metrics, pair it with VictoriaMetrics, and with Grafana for dashboards.

Share this articleservorbit.com/ma-en/blog/self-host-victorialogs-vps-log-database

All your logs in one place, on your VPS

Prices shown excluding VAT, with their renewal price.