Health and Metrics
This document explains how to retrieve health and metrics data for your MikroTik routers using the provided API endpoints.
Retrieve Router Metrics
The /api/routers/{router_id}/metrics
endpoint allows you to retrieve metrics about the router's uptime and downtime
over the past 24 hours. This data is based on the heartbeats received from the router and may be up to 60 minutes old.
Endpoint
GET
/api/routers/{router_id}/metrics
Sample Response
{
"status": "success",
"data": [
{
"date": "2024-05-28T02:00:00+00:00",
"minutes_down": 0,
"percentage_down": 0
},
{
"date": "2024-05-28T03:00:00+00:00",
"minutes_down": 0,
"percentage_down": 0
},
// Additional data points...
{
"date": "2024-05-29T01:00:00+00:00",
"minutes_down": 1,
"percentage_down": 1.67
}
]
}
Metrics Object
Property | Type | Description |
---|---|---|
date | string | The date and hour of the recorded metric (ISO 8601 format). |
minutes_down | number | The number of minutes the router was down during the specified hour. |
percentage_down | number | The percentage of downtime during the specified hour. |
Retrieve Router Faults
The /api/routers/{router_id}/faults
endpoint allows you to retrieve the last 100 faults for a specific router, ordered
from newest to oldest.
Endpoint
GET
/api/routers/{router_id}/faults
Sample Response
{
"status": "success",
"data": [
{
"id": "00000000-0000-0000-0000-000000000001",
"rid": "00000000-0000-0000-0000-000000000002",
"message": "Site Offline: ExampleRouter",
"severity": "error",
"type": "site",
"cause": "Unknown",
"created_at": "2024-05-29T01:32:15+00:00",
"resolved_at": null,
"duration": null
}
]
}
Faults Object
Property | Type | Description |
---|---|---|
id | string | The unique identifier for the fault. |
rid | string | The unique identifier of the affected resource. |
message | string | A message describing the fault. |
severity | string | The severity level of the fault (e.g., "error"). |
type | string | The type of fault (e.g., "site"). |
cause | string | The cause of the fault. If the fault is ongoing, the cause is "Unknown". |
created_at | string | The timestamp of when the fault was created (ISO 8601 format). |
resolved_at | string | The timestamp of when the fault was resolved, if applicable. |
duration | number | The duration of the fault in seconds. If ongoing, this will be null . |
status | string | The current status of the fault (e.g., "completed", "ongoing"). |
Heartbeat fault conditions are recorded when a router misses 10 consecutive heartbeats, which means a sensitivity threshold of 5 minutes. A fault is cleared the moment the next heartbeat is received, and the downtime is calculated as the delta between the start and end times of the fault condition.
Was this page helpful?