logs
Retrieve recent RouterOS log entries with optional topic filtering. Limits results to a specified number of entries.
Instructions
Read recent RouterOS log entries (most recent last).
limit must be positive and is capped at 500. topics, if given, is
matched as a plain substring against each entry's topics field - no
regex, no unbounded scans - and is applied BEFORE the limit cut:
the full log is filtered by topics first, then the last limit
matching entries are returned (not the last limit raw entries,
then filtered - that would silently drop matches).
R1: this reads the whole /log table via librouteros' path().select()
and slices in Python rather than asking RouterOS for only the last
limit rows. librouteros' structured API doesn't expose a clean
"give me only the tail" query for /log (RouterOS's own count-only
print flags aren't reachable through path().select() the way a
.limit()/offset would be), so a "request fewer rows" optimization
here would mean building a fragile ad-hoc workaround for a table
that is small in practice (a few hundred to low thousands of rows on
RouterOS's own ring buffer). Left as-is; revisit if a real device
turns out to have a much larger log buffer than expected.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| topics | No | ||
| device_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |