Linux Labs

Observability: metrics, alerts, logs / Stage 7 of 9

Logs in one place

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · on a machine · 5 min

Forwarding to the collector

The collector gets a machine's lines only if that machine's rsyslog sends them itself — this takes a forwarding rule.

A rule's action can be another machine's address: then rsyslog sends a copy of the line over the network, which is forwarding (in the Wiki). The standard syslog port is 514, and the sign before the address sets the protocol:

text
*.* @@10.0.0.5:514      # all lines — over TCP
*.* @10.0.0.5:514       # all lines — over UDP

The same action in the newer syntax is action(type="omfwd" target="10.0.0.5" port="514" protocol="tcp"). Your own rule goes into a separate file in /etc/rsyslog.d ending in .conf: the package's files will be updated, and yours will stay. rsyslog reads its rules at startup, so an edit takes two commands: sudo rsyslogd -N1 checks the syntax of all the files (in the Wiki) without touching the running service, and sudo systemctl restart rsyslog applies the rules.

Only new lines are forwarded: what rsyslog wrote before the rule stays in the machine's own files. Delivery is checked with a test logger line — on the collector it lands in the directory named after the machine.

Exercise · do it

Forward the lines to the collector

Make this machine's rsyslog forward all of its lines to the collector at 127.0.0.1:514 over TCP. The setting must stay after rsyslog restarts.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Get the machine's lines to the collector not done yet
  • Keep forwarding in the rsyslog settings not done yet

Step goals

0 of 2
  • Get the machine's lines to the collector — not done yet
  • Keep forwarding in the rsyslog settings — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Get the machine's lines to the collector — not done yet
  • Keep forwarding in the rsyslog settings — not done yet
Loading…