API user
The agent needs no RouterOS account. Three things on your host do: the collector’s API tier, the
relay transport, and the router-log markers. Give them one dedicated user with read and api,
plus test if you use the relay.
Required policies
Section titled “Required policies”| Used by | Runs over the binary API | Policy |
|---|---|---|
forward’s API tier |
/interface/, /interface/print (name, default-name, type, comment, actual-mtu), /interface/ (list, interface), /interface/ (interface, bridge), /interface/print stats-detail, /interface/, /system/resource/print, /system/, /system/health/print, /ip/, and once per reboot /log/print (topics, message, the memory buffer) |
read,api |
record --log-markers, mark --log-markers |
/log/print (time, topics, message) |
read,api |
the relay transport (--transport relay, or auto when direct does not answer) |
/tool/fetch output=user against the agent’s address |
read,api,test |
Scroll sideways to see every column
/tool fetch and /tool profile both require the test policy (verified).
mikroscope uses /tool fetch for the relay and does not use /tool profile.
read,api is enough for the API tier and for --log-markers. test is needed only when the relay
is used — --transport relay, or auto when the direct transport does not answer — whatever
--api-mode is. With --api-mode off the tier needs no user at all.
Not every call in the first row runs every time. /system/health/print is skipped in slow and
with --no-health; the conntrack count-only runs only when --conntrack-every is above 0, and
its default is 0 even in full; monitor-traffic runs only when --interfaces is set, while the three
configuration reads behind the interface inventory run whenever the tier is on, once before the
first kernel pull and again every --labels-every; the two stats reads follow --counters-every,
10 s by default. Which calls
run at which cadence is on RouterOS API tier.
Without an address and a user, each command says so differently:
forwardruns the kernel tier alone. With an address that does not answer it logsapi tier: not connected yet, will keep trying: …and keeps retrying.mark --log-markersand--transport relayfail withthe RouterOS API needs --api, --api-user and MIKROSCOPE_.API_ PASSWORD record --log-markerskeeps the recording, printslog markers: the RouterOS API needs …on stderr and exits 0.--transport auto, when the direct transport does not answer, fails withdirect transport did not answer and the relay is not configured: the RouterOS API needs … (or `install --expose`).
That check looks only at --api and --api-user. An empty MIKROSCOPE_API_PASSWORD is not caught
there; it shows up as a failed login, api <address>: ….
Create the user
Section titled “Create the user”-
Create a group that grants
read,apiandtestand denies by name every other policy RouterOS defines:/user/group/add name=mikroscope policy=read,api,test,!write,!ftp,!local,!telnet,!ssh,!reboot,!policy,!winbox,!password,!web,!sniff,!sensitive,!romon,!rest-apiDrop
testfrom the list if you will never use the relay. -
Create the user in that group, restricted to the collector’s address:
/user/add name=mikroscope group=mikroscope password=<generate> address=<collector host>/32 -
Restrict
/ip/serviceforapito your LAN. Withaddress=on the user, both are RouterOS-side limits on where the password is accepted from, and neither depends on mikroscope. -
Pass the address, the user and the password to the CLI, as in Pass the credentials.
Make this user for mikroscope rather than reusing one made for another tool. A least-privilege API
user built for something else typically belongs to a group that denies test, so it cannot run the
relay, and widening that group widens it for the other tool as well.
What read can see
Section titled “What read can see”read is not narrow. Over the binary API, /container/print returns every property of every
container, cmd and envlist included, to a user with only read,api (verified).
Whether it can also read the envlist entries’ values in /container/envs is not tested;
the design assumes this user can, and so treats the agent’s TOKEN entry, when one is set, as
readable by it.
The collector narrows what it asks for where it reads configuration. The three interface-inventory reads
name their properties — name, default-name, type, comment and actual-mtu; list and
interface; interface and bridge — and no other field, so none of them brings back a field that
could carry a secret; /system/resource, /system/resource/cpu, /system/health and /log/print carry
a .proplist as well. The counter reads — monitor-traffic, stats, stats-detail — and the
conntrack count-only do not. None of this limits what the user is allowed to request: it can
still ask for every container’s properties.
Pass the credentials
Section titled “Pass the credentials”| Setting | Flag | Environment variable |
|---|---|---|
| address | --api |
MIKROSCOPE_API_ADDR |
| user | --api-user |
MIKROSCOPE_API_USER |
| password | none | MIKROSCOPE_API_PASSWORD |
Scroll sideways to see every column
The password has no flag on purpose: a flag is visible in ps and in a shell history.
The repository’s .env.example gives the address as 192.168.88.1:8728.