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
| VictoriaLogs | Loki | Elasticsearch | |
|---|---|---|---|
| Text search | Fast, full-text | Slow without a targeted label | Fast, full-text |
| Memory at rest | A few megabytes | A few hundred megabytes | Several gigabytes |
| Components to deploy | One binary | One binary or several services | A JVM cluster |
| Query language | LogsQL | LogQL | Query DSL, KQL |
| Compatible agents | Elasticsearch, Loki, OpenTelemetry | Loki, OpenTelemetry | Elasticsearch |
| Built-in interface | vmui | No, goes through Grafana | No, 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
Prepare the folder and the password
Create the application folder and a
.envfile holding the password of theadminuser.mkdir -p /opt/victorialogs && cd /opt/victorialogs echo "ADMIN_PASSWORD=$(openssl rand -hex 16)" > .env chmod 600 .envWrite the docker-compose.yml file
The port is only published on the loopback interface: only nginx reaches it. The two
-httpAuthoptions protect every endpoint — interface, queries and ingestion.-retentionPeriod=30dkeeps thirty days, and-retention.maxDiskUsagePercent=80drops 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: {}Start the container
Startup takes less than a second. The log should show "started VictoriaLogs".
docker compose up -d docker compose logs --tail 20Publish 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,fileRestart 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() errorsThe 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.
servorbit.com/ma-en/blog/self-host-victorialogs-vps-log-database


