MikroTik

UTMStack v12 collects MikroTik RouterOS logs through the UTMStack Forwarder, which the web interface calls the Collector. You enable the MikroTik integration on a Collector, then add a remote logging action on the router that points at that Collector. Nothing is installed on the router.

Connection details

SettingValue
Card on the Integrations pageMikrotik (category Firewall)
Data typefirewall-mikrotik
Default ports on the Collector7007/UDP; 7007/TCP (also used for TLS)
Log format UTMStack readsRouterOS syslog messages (topics and message text), with or without a timestamp and host name
Parsing pipelinemikrotik/mikrotik-fw.yaml, version 3.2.0. Filters in the card's drawer opens it.
Detection rules6. Rules in the card's drawer opens them.

Before you begin

  • A Collector must be installed and online. If you do not have one, see UTMStack Forwarder. One Collector can serve all your integrations.

  • The router must reach the Collector host on the port you use. Open it on the Collector host and on any firewall in between.

  • You need the integrations.write permission to enable the integration from the web interface.

Step 1: Enable the integration on a Collector

  1. 1

    Open the integration

    In UTMStack, go to Configure > Integrations and open the Mikrotik card.

    MikroTik setup guide in UTMStack, showing How it works and the Enable this integration remotely panel with the Collector, Protocol and Port fields

    A different number typed in Port does not change the port the Collector listens on; see Use a different port below.

  2. 2

    Choose the Collector and protocol

    Under Enable this integration remotely, select the Collector and set Protocol to UDP. Leave Port at the default it fills in.

  3. 3

    Enable it

    Click Enable integration. The panel then shows, for example, Currently: enabled · udp · port 7007.

To do the same on the Collector host instead, run:

sudo /opt/utmstack-forwarder/utmstack_forwarder enable-integration firewall-mikrotik udp

The command prints the port the Collector really listens on, for example Integration "firewall-mikrotik" enabled on udp port 7007.

Use UDP. According to MikroTik's documentation, RouterOS sends remote logs in syslog format over UDP only; its TCP and TLS options work only with the CEF log format, which the UTMStack MikroTik pipeline does not read.

Use a different port

For built-in integrations, the Collector always listens on the port saved on the Collector host. That is the default port unless you change it there. A different number typed in Port, or on the enable-integration command line, is not used. To use another port:

  1. On the Collector host, change the saved port, for example:

    sudo /opt/utmstack-forwarder/utmstack_forwarder change-port firewall-mikrotik udp 7107
  2. In the Mikrotik card, type the same port in Port when you enable the integration. If it is already enabled, click Disable integration first, then enable it again with the new port. The panel shows the port you type there, not a value read from the Collector, so typing the same port keeps the two in step.

  3. Use the new port in remote-port in step 2.

Step 2: Configure MikroTik to forward logs

On the MikroTik router, create a remote logging action pointing at the Collector host and attach it to the log topics you need. Run the following from the RouterOS CLI (Terminal in Winbox). Replace <collector-ip> with the address of the Collector host.

/system logging action
add name=utmstack target=remote remote=<collector-ip> remote-port=7007 
    bsd-syslog=yes syslog-facility=local0 syslog-severity=auto

/system logging
add action=utmstack topics=account,error,info,warning

You can also do this in Winbox: System > Logging, then on the Actions tab add a Remote action, and on the Rules tab add rules that use the new action.

The setup guide in UTMStack fills in your UTMStack server's address in this step. Keep it only if the Collector runs on the UTMStack server; otherwise use the address of the Collector host.

  • Firewall rules only produce log messages when logging is turned on in the rule (log=yes). Turn it on for the rules whose hits you want to see.

  • Property names of logging actions changed between RouterOS versions. If your version does not accept bsd-syslog=yes, check MikroTik's Log documentation for the equivalent setting.

Step 3: Check that logs arrive

  1. 1

    Open the logs

    In the Mikrotik drawer, click View logs. Log Explorer opens with the firewall-mikrotik data type for the last 24 hours. You can also open Log Explorer, keep the data set logs and choose firewall-mikrotik as the data type.

  2. 2

    Check the parsed fields

    Expand an event. Firewall messages have standard fields such as origin.ip, target.ip and action, and every event has MikroTik fields under log.. The event should have no errors.

  3. 3

    Check the data source

    Within about 20 minutes, the router appears on the Data Sources page under Direct, named after the address its logs come from.

A quick way to create a message is to log in to the router: the login is logged under the account topic.

To list the latest events and any processing errors, switch Log Explorer to SQL mode and run:

SELECT `@timestamp`, dataSource, errors, raw
FROM logs
WHERE dataType = 'firewall-mikrotik'
  AND `@timestamp` > now() - INTERVAL 1 HOUR
ORDER BY `@timestamp` DESC
LIMIT 20

Troubleshooting

SymptomLikely causeWhat to do
Nothing arrivesThe Collector is offline, or the action points to the wrong address or port, or a firewall blocks the port.Check that the Collector shows as online in the Collector list. Run /system logging action print on the router. Check that the Collector host allows the port in. See Forwarder Troubleshooting.
Nothing arrives, and the Forwarder guide filled in the UTMStack server's addressThe router sends to the UTMStack server, but the Collector runs on another host.Set remote to the Collector host.
Nothing arrives, and the integration is enabled with TCPRouterOS sends syslog over UDP.Disable the integration and enable it again with UDP.
No firewall eventsLogging is off in the firewall rules, or the rule list does not include the info topic.Set log=yes on the rules, and keep info in the topics of the logging rule.
MikroTik logs appear under another data typeThe router sends to the port of a different integration.Send to the port that the MikroTik integration listens on.

Stop collecting

In the Mikrotik card, select the same Collector and click Disable integration, or run on the Collector host:

sudo /opt/utmstack-forwarder/utmstack_forwarder disable-integration firewall-mikrotik udp

Then remove the logging rule and the utmstack action from the router.