K

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

PropertyTypeDescription
datestringThe date and hour of the recorded metric (ISO 8601 format).
minutes_downnumberThe number of minutes the router was down during the specified hour.
percentage_downnumberThe 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

PropertyTypeDescription
idstringThe unique identifier for the fault.
ridstringThe unique identifier of the affected resource.
messagestringA message describing the fault.
severitystringThe severity level of the fault (e.g., "error").
typestringThe type of fault (e.g., "site").
causestringThe cause of the fault. If the fault is ongoing, the cause is "Unknown".
created_atstringThe timestamp of when the fault was created (ISO 8601 format).
resolved_atstringThe timestamp of when the fault was resolved, if applicable.
durationnumberThe duration of the fault in seconds. If ongoing, this will be null.
statusstringThe 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?