Log forwarding to VictoriaLogs

Published

In this guide we’ll go through how to setup log forwarding to a VictoriaLogs server.

This guide applies to both Cradle CMS and eCommerce, it works in the same way on both systems.

Log forwarding is essential when operating larger sites or shops as it lets you gather all the logs in one place.

Further more

  • it does not eat up local storage
  • you can store information in a secure place
  • it lets you quickly search and find information
  • it allows for operational support system (OSS) integrations

We currently support log forwarding to victorialogs and questdb servers.

To setup victorialogs you should have a separate server for the installation.

We’ll assume you are using a debian based distribution but this process should be the same on most systemd based distros.

Install victorialogs

Start by downloading the latest victorialogs release matching your server type. Create a log directory and install the binary into /logs, your victorialogs release is likely not same as we use here.

mkdir /logs
tar zxvf victoria-logs-linux-amd64-v1.55.0.tar.gz -C /logs

Change owner of the logs directory to www-data as we will use that for the log server.

chmod -R www-data:www-data /logs

Install systemd service

Copy the following content into a /etc/systemd/system/victorialogs.service file.

[Unit]
Description=Victorialogs server
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/logs
Environment="PATH=/logs"
ExecStart=/logs/victoria-logs-prod -retention.maxDiskUsagePercent=80
ExecReload=/bin/kill -s HUP $MAINPID
RestartSec=5

[Install]
WantedBy=multi-user.target

Start the victorialogs service

systemctl daemon-reload
systemctl enable -now victorialogs

Check for any startup issues

systemctl status victorialogs

Check the server listener port.

ss -tunlp

Configure cradle settings

Login to your cradle server and add the following into your settings file settings.conf. You need to change the server url with your log server host or ip.

[site.log]
server = "http://log_server_hostname_or_ip:9428
noLog = true

noLog=true disables standard log output on your cradle instances.

Apply the settings with podman secret create settings settings.conf --replace

With docker you need to create a new settings version, but it’s essentially the same process.

Access your victorialogs vmUI and start inspecting your logs.

Searching in VictoriaLogs vmUI for http 404 errors - enjoy all the bots!

Now can be a good time to learn more about victoria logs