zabbix_export:
  version: '7.0'
  template_groups:
  - uuid: 7b08c027e96f419e87792897a28aff44
    name: Templates/Applications
  templates:
  - uuid: 83b1d3ba3c3f49dc981f11c5f54e66de
    template: MikroTik Manager by HTTP
    name: MikroTik Manager by HTTP
    description: |-
      Monitors a MikroTik Manager (mikr) installation and, through it, every device the manager polls - no SNMP or SSH access to the devices themselves is required.

      Setup:
      1. In mikr, Settings - API keys: create a key with the viewer role and access to all sites.
      2. Link this template to a host and set {$MIKR.URL} and {$MIKR.API.KEY}.

      Devices are discovered from /api/devices; one item set and its triggers appear per enabled device. Every raw item keeps no history on purpose - the payloads carry hostnames, addresses and usernames.

      https://github.com/hreskiv/mikr
    groups:
    - name: Templates/Applications
    items:
    - uuid: 9683b18c614c4078b434784f05c0f3d1
      name: 'mikr: health (raw)'
      type: HTTP_AGENT
      key: mikr.health.raw
      delay: 1m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/health'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      description: Unauthenticated endpoint. Master item only - it keeps no history; every value below
        is extracted from it.
    - uuid: 16e7c391c11e42a9886ec4345bdce62b
      name: 'mikr: service status'
      type: DEPENDENT
      key: mikr.health.status
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.status
      - type: JAVASCRIPT
        parameters:
        - 'return value === ''ok'' ? 1 : 0;'
      tags:
      - tag: component
        value: health
      valuemap:
        name: Service state
    - uuid: 62bf5d4fb0bd4bfd9dffa9d8cda4e119
      name: 'mikr: version'
      type: DEPENDENT
      key: mikr.version
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.version
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1h
      tags:
      - tag: component
        value: health
      trends: '0'
    - uuid: 5ba0c31df48e40cc9a50f7287b87c7d6
      name: 'mikr: uptime'
      type: DEPENDENT
      key: mikr.uptime
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.process.uptimeSeconds
      tags:
      - tag: component
        value: health
      units: uptime
    - uuid: 43c1341785654b70b2b72d7ba8a0836c
      name: 'mikr: memory RSS'
      type: DEPENDENT
      key: mikr.mem.rss
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.process.memory.rssBytes
      tags:
      - tag: component
        value: health
      units: B
    - uuid: 8a6c919ff19e4af6928f43dc445c7493
      name: 'mikr: database size'
      type: DEPENDENT
      key: mikr.db.size
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.db.size
      tags:
      - tag: component
        value: database
      units: B
    - uuid: 07902188c72c4be7941d9589ecd3cfdf
      name: 'mikr: database WAL size'
      type: DEPENDENT
      key: mikr.db.wal
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.db.walSize
      tags:
      - tag: component
        value: database
      units: B
    - uuid: e9be6169629a46a2b8237f7e85038c42
      name: 'mikr: database total size'
      type: DEPENDENT
      key: mikr.db.bytes
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.db.totalBytes
      tags:
      - tag: component
        value: database
      units: B
    - uuid: 9cbd7d69f1f34d53a19489316ac30faf
      name: 'mikr: devices total'
      type: DEPENDENT
      key: mikr.devices.total
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.devices.total
      tags:
      - tag: component
        value: fleet
    - uuid: e7243f58ee6b4ef1a112e4befc00257b
      name: 'mikr: devices online'
      type: DEPENDENT
      key: mikr.devices.online
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.devices.online
      tags:
      - tag: component
        value: fleet
    - uuid: 94f0ca0e9c484865b7237144b4bb9abf
      name: 'mikr: syslog collector enabled'
      type: DEPENDENT
      key: mikr.features.syslog
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.features.syslog
      - type: BOOL_TO_DECIMAL
      tags:
      - tag: component
        value: features
      valuemap:
        name: Enabled
    - uuid: 251ba18f13044da68be6dc7576541a72
      name: 'mikr: CVE feed enabled'
      type: DEPENDENT
      key: mikr.features.cve
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.health.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.features.cve
      - type: BOOL_TO_DECIMAL
      tags:
      - tag: component
        value: features
      valuemap:
        name: Enabled
    - uuid: 1709f8c54ed14753a6d79863bd72bc42
      name: 'mikr: devices offline'
      type: CALCULATED
      key: mikr.devices.offline
      delay: 1m
      history: 31d
      value_type: UNSIGNED
      params: last(//mikr.devices.total)-last(//mikr.devices.online)
      tags:
      - tag: component
        value: fleet
    - uuid: 5b8091375bc241da96e2e1169aa11661
      name: 'mikr: devices (raw)'
      type: HTTP_AGENT
      key: mikr.devices.raw
      delay: 1m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/devices'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
      description: 'Master item for device discovery. Keeps no history: the payload is the full inventory
        (hostnames, addresses, usernames) and does not belong in Zabbix history.'
    - uuid: 3edd4017e4d44c1a8d86d98688a87939
      name: 'mikr: devices visible to API key'
      type: DEPENDENT
      key: mikr.devices.count
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.devices.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.length()
      tags:
      - tag: component
        value: fleet
      description: 'Doubles as the API-key health check: it stops updating when the key is revoked while
        /api/health keeps working.'
    - uuid: 214e865a2a7146dabe43bfc4d96340d1
      name: 'mikr: CVE summary (raw)'
      type: HTTP_AGENT
      key: mikr.cve.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/cve/summary'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 3e8156ab915b49f3a233d5484aa97302
      name: 'mikr: CVE critical'
      type: DEPENDENT
      key: mikr.cve.critical
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.bySeverity.CRITICAL
      tags:
      - tag: component
        value: security
    - uuid: 0155d813262a4202b1219cf8564338f3
      name: 'mikr: CVE high'
      type: DEPENDENT
      key: mikr.cve.high
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.bySeverity.HIGH
      tags:
      - tag: component
        value: security
    - uuid: edf3657ab16c4810b2a7254bef343016
      name: 'mikr: CVE medium'
      type: DEPENDENT
      key: mikr.cve.medium
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.bySeverity.MEDIUM
      tags:
      - tag: component
        value: security
    - uuid: 47a4d07ae77144a2a988ee8a26d1a796
      name: 'mikr: CVE low'
      type: DEPENDENT
      key: mikr.cve.low
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.bySeverity.LOW
      tags:
      - tag: component
        value: security
    - uuid: d62c3753500a4a4a9242b8dd8a051d93
      name: 'mikr: devices affected by CVEs'
      type: DEPENDENT
      key: mikr.cve.affected
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.affectedDevices
      tags:
      - tag: component
        value: security
    - uuid: 665e79077180494b8ca0aa28830a9834
      name: 'mikr: CVE records in feed'
      type: DEPENDENT
      key: mikr.cve.records
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.meta.totalRecords
      tags:
      - tag: component
        value: security
    - uuid: da4681d42c634c38b632fba34c53e298
      name: 'mikr: CVE feed age'
      type: DEPENDENT
      key: mikr.cve.age
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.cve.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.meta.lastFetchedAt
      - type: JAVASCRIPT
        parameters:
        - |-
          var t = Date.parse(value);
          if (isNaN(t)) { throw 'unparsable timestamp: ' + value; }
          return Math.round((Date.now() - t) / 1000);
        error_handler: DISCARD_VALUE
      tags:
      - tag: component
        value: security
      units: s
    - uuid: 7a91d031320c41d99660f9b43d857e70
      name: 'mikr: patch gaps (raw)'
      type: HTTP_AGENT
      key: mikr.patchgaps.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/cve/patch-gaps'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: dea1bc4273b54e9bbfe5e3b2b5d00f8c
      name: 'mikr: devices with patch gaps'
      type: DEPENDENT
      key: mikr.patchgaps.affected
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.patchgaps.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.affectedDevices
      tags:
      - tag: component
        value: security
      description: Devices running a RouterOS build older than a release that carries security-flagged
        changelog entries.
    - uuid: f14f5919fbdf402a95c804c2823829ad
      name: 'mikr: releases tracked for patch gaps'
      type: DEPENDENT
      key: mikr.patchgaps.releases
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.patchgaps.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.meta.totalReleases
      tags:
      - tag: component
        value: security
    - uuid: 71dbccd0aa3143c2850971040a2feec1
      name: 'mikr: patch-gap data age'
      type: DEPENDENT
      key: mikr.patchgaps.age
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.patchgaps.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.meta.lastFetchedAt
      - type: JAVASCRIPT
        parameters:
        - |-
          var t = Date.parse(value);
          if (isNaN(t)) { throw 'unparsable timestamp: ' + value; }
          return Math.round((Date.now() - t) / 1000);
        error_handler: DISCARD_VALUE
      tags:
      - tag: component
        value: security
      units: s
    - uuid: e04dfd28e9de4db78ff28f91af6df1c4
      name: 'mikr: license (raw)'
      type: HTTP_AGENT
      key: mikr.license.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/license'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 45dff02cf9714253bfa8ed53091b4e48
      name: 'mikr: license tier'
      type: DEPENDENT
      key: mikr.license.tier
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.tier
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1d
      tags:
      - tag: component
        value: license
      trends: '0'
    - uuid: eb32f5ebf7364e8d8f40401d930c81dc
      name: 'mikr: device limit'
      type: DEPENDENT
      key: mikr.license.max
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.maxDevices
      tags:
      - tag: component
        value: license
      description: 0 means unlimited.
    - uuid: 5c397230c01c44eebd150c95409a2347
      name: 'mikr: devices licensed'
      type: DEPENDENT
      key: mikr.license.current
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.currentDevices
      tags:
      - tag: component
        value: license
    - uuid: d9f49e20073d4ec2876665e17dcf7ac9
      name: 'mikr: device slots free'
      type: DEPENDENT
      key: mikr.license.free
      history: 31d
      value_type: FLOAT
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JAVASCRIPT
        parameters:
        - |-
          var o = JSON.parse(value);
          if (!o.maxDevices) { return -1; }
          return o.maxDevices - o.currentDevices;
      tags:
      - tag: component
        value: license
      description: -1 means an unlimited tier, so triggers must exclude negatives.
    - uuid: 9eef9b8d199849f8ad23ade1c2e7ce53
      name: 'mikr: days of updates left'
      type: DEPENDENT
      key: mikr.license.updates.days
      history: 31d
      value_type: FLOAT
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JAVASCRIPT
        parameters:
        - |-
          var o = JSON.parse(value);
          return o.updatesDaysLeft === null || o.updatesDaysLeft === undefined
            ? -1 : o.updatesDaysLeft;
      tags:
      - tag: component
        value: license
      description: -1 on tiers with lifetime updates, so triggers must exclude negatives.
    - uuid: c734ca9502bb4aa1abebcd4070562e6f
      name: 'mikr: days until license expiry'
      type: DEPENDENT
      key: mikr.license.expiry.days
      history: 31d
      value_type: FLOAT
      master_item:
        key: mikr.license.raw
      preprocessing:
      - type: JAVASCRIPT
        parameters:
        - |-
          var o = JSON.parse(value);
          return o.daysUntilExpiry === null || o.daysUntilExpiry === undefined
            ? -1 : o.daysUntilExpiry;
      tags:
      - tag: component
        value: license
    - uuid: aeaa2c018eaa4399bcb1c260f5169890
      name: 'mikr: manager update check (raw)'
      type: HTTP_AGENT
      key: mikr.update.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/version-check'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 736d44f4e72d4cce9904b3b8c5e7e157
      name: 'mikr: manager update available'
      type: DEPENDENT
      key: mikr.update.available
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.update.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.updateAvailable
      - type: BOOL_TO_DECIMAL
      tags:
      - tag: component
        value: health
      valuemap:
        name: Enabled
    - uuid: 8f4f3483b3fa4ac58a1434c9dc98a588
      name: 'mikr: latest manager release'
      type: DEPENDENT
      key: mikr.update.latest
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.update.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.latest
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1d
      tags:
      - tag: component
        value: health
      trends: '0'
    - uuid: b2a61e8856514cee88cacd706d081e3c
      name: 'mikr: latest RouterOS versions (raw)'
      type: HTTP_AGENT
      key: mikr.ros.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/upgrade/latest-versions'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 423072b85b474234be47fcbbc74237fa
      name: 'mikr: latest RouterOS (stable)'
      type: DEPENDENT
      key: mikr.ros.stable
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.ros.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.versions.stable
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1d
      tags:
      - tag: component
        value: routeros
      trends: '0'
    - uuid: d4acac020dc140ee9b158cb59103768e
      name: 'mikr: latest RouterOS (long-term)'
      type: DEPENDENT
      key: mikr.ros.longterm
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.ros.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.versions['long-term']
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1d
      tags:
      - tag: component
        value: routeros
      trends: '0'
    - uuid: 4edc6dd11f1a46a3801df159d15e2a0d
      name: 'mikr: latest RouterOS (testing)'
      type: DEPENDENT
      key: mikr.ros.testing
      history: 31d
      value_type: CHAR
      master_item:
        key: mikr.ros.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.versions.testing
      - type: DISCARD_UNCHANGED_HEARTBEAT
        parameters:
        - 1d
      tags:
      - tag: component
        value: routeros
      trends: '0'
    - uuid: 5bb2a8ecf3f24ae88c4f8273e9e1ae8a
      name: 'mikr: RouterOS version data age'
      type: DEPENDENT
      key: mikr.ros.age
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.ros.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.checkedAt
      - type: JAVASCRIPT
        parameters:
        - |-
          var t = Date.parse(value);
          if (isNaN(t)) { throw 'unparsable timestamp: ' + value; }
          return Math.round((Date.now() - t) / 1000);
        error_handler: DISCARD_VALUE
      tags:
      - tag: component
        value: routeros
      units: s
    - uuid: bde70249d534440a948a5210a3c6b2d5
      name: 'mikr: syslog stats (raw)'
      type: HTTP_AGENT
      key: mikr.syslog.raw
      delay: 5m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/syslog/stats'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: dcb7150e8cde464ea8fb9fe846ec525e
      name: 'mikr: syslog receiver enabled'
      type: DEPENDENT
      key: mikr.syslog.enabled
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.syslog.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.config.enabled
      - type: BOOL_TO_DECIMAL
      tags:
      - tag: component
        value: syslog
      valuemap:
        name: Enabled
    - uuid: 98581753cd014c2b8d44ec64027f9faf
      name: 'mikr: syslog messages stored'
      type: DEPENDENT
      key: mikr.syslog.messages
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.syslog.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.byDevice[*].n.sum()
      tags:
      - tag: component
        value: syslog
    - uuid: e29df7fccc9f44a09f790521cc5fd229
      name: 'mikr: devices sending syslog'
      type: DEPENDENT
      key: mikr.syslog.devices
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.syslog.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.byDevice.length()
      tags:
      - tag: component
        value: syslog
    - uuid: ba5662d6719c466b959ab77ffba7b5a3
      name: 'mikr: syslog retention'
      type: DEPENDENT
      key: mikr.syslog.retention
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.syslog.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.config.retentionDays
      tags:
      - tag: component
        value: syslog
      units: d
    - uuid: 16eab481f6524e5fb56685be235e94d0
      name: 'mikr: IDS blocked (raw)'
      type: HTTP_AGENT
      key: mikr.ids.blocked.raw
      delay: 5m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/ids/blocked'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: d196ec92b5844039a305918073b5ccf4
      name: 'mikr: IDS blocked addresses'
      type: DEPENDENT
      key: mikr.ids.blocked
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.ids.blocked.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.blocked.length()
      tags:
      - tag: component
        value: security
    - uuid: 585de84770cf425d9dcb614c0931d585
      name: 'mikr: IDS candidates (raw)'
      type: HTTP_AGENT
      key: mikr.ids.candidates.raw
      delay: 5m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/ids/candidates'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 12cddd057230473092660c100383e607
      name: 'mikr: IDS candidate addresses'
      type: DEPENDENT
      key: mikr.ids.candidates
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.ids.candidates.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.candidates.length()
      tags:
      - tag: component
        value: security
      description: Addresses seen brute-forcing a device but not blocked yet.
    - uuid: d81bfc0c4289430f922a74f9d8e686d6
      name: 'mikr: tasks (raw)'
      type: HTTP_AGENT
      key: mikr.tasks.raw
      delay: 5m
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/tasks'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: 2ce493b8cb69424582a83687b5e2ea0d
      name: 'mikr: tasks known'
      type: DEPENDENT
      key: mikr.tasks.total
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.tasks.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.tasks.length()
      tags:
      - tag: component
        value: tasks
    - uuid: c9866751819848d7bd43c5f3dac80102
      name: 'mikr: tasks running'
      type: DEPENDENT
      key: mikr.tasks.running
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.tasks.raw
      preprocessing:
      - type: JAVASCRIPT
        parameters:
        - |-
          var o = JSON.parse(value);
          return (o.tasks || []).filter(function (t) {
            return t.status !== 'done' && t.status !== 'error';
          }).length;
      tags:
      - tag: component
        value: tasks
    - uuid: 07424129a6864dc598405c1e0a632444
      name: 'mikr: tasks failed'
      type: DEPENDENT
      key: mikr.tasks.failed
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.tasks.raw
      preprocessing:
      - type: JAVASCRIPT
        parameters:
        - |-
          var o = JSON.parse(value);
          return (o.tasks || []).filter(function (t) {
            return t.status === 'error';
          }).length;
      tags:
      - tag: component
        value: tasks
    - uuid: 024977c3dfad49ab8d4c26e976e22ea5
      name: 'mikr: sites (raw)'
      type: HTTP_AGENT
      key: mikr.sites.raw
      delay: 1h
      history: '0'
      trends: '0'
      value_type: TEXT
      url: '{$MIKR.URL}/api/sites'
      status_codes: '200'
      verify_peer: 'NO'
      verify_host: 'NO'
      timeout: 30s
      tags:
      - tag: component
        value: raw
      headers:
      - name: X-API-Key
        value: '{$MIKR.API.KEY}'
    - uuid: bb16e73c89be423ba94b5afff918a248
      name: 'mikr: sites'
      type: DEPENDENT
      key: mikr.sites.count
      history: 31d
      value_type: UNSIGNED
      master_item:
        key: mikr.sites.raw
      preprocessing:
      - type: JSONPATH
        parameters:
        - $.length()
      tags:
      - tag: component
        value: fleet
    discovery_rules:
    - uuid: 709e5a9632c547f0b8fda7f8d7d22597
      name: Device discovery
      type: DEPENDENT
      key: mikr.device.discovery
      master_item:
        key: mikr.devices.raw
      lld_macro_paths:
      - lld_macro: '{#DEVID}'
        path: $.id
      - lld_macro: '{#NAME}'
        path: $.name
      - lld_macro: '{#HOST}'
        path: $.host
      - lld_macro: '{#SITEID}'
        path: $.siteId
      - lld_macro: '{#ENABLED}'
        path: $.enabled
      - lld_macro: '{#TRANSPORT}'
        path: $.monitoringTransport
      filter:
        evaltype: AND
        conditions:
        - macro: '{#ENABLED}'
          value: 'true'
          formulaid: A
        - macro: '{#NAME}'
          value: '{$MIKR.DEVICE.MATCHES}'
          formulaid: B
        - macro: '{#NAME}'
          value: '{$MIKR.DEVICE.NOT_MATCHES}'
          operator: NOT_MATCHES_REGEX
          formulaid: C
      item_prototypes:
      - uuid: b07a124e5a3e45d1b1526c39530f5637
        name: 'Device {#NAME}: online'
        type: DEPENDENT
        key: mikr.device.online[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.online.first()
        - type: BOOL_TO_DECIMAL
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        valuemap:
          name: Service state
      - uuid: 7bc3b8dfbced4e41b242ee74be53fc5b
        name: 'Device {#NAME}: IP reachable'
        type: DEPENDENT
        key: mikr.device.reachable[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.netReachable.first()
        - type: BOOL_TO_DECIMAL
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        description: TCP-reachable but possibly failing to poll - not the same as online.
        valuemap:
          name: Service state
      - uuid: 23bc2b3238fd49ccb035960e4148ed07
        name: 'Device {#NAME}: free memory'
        type: DEPENDENT
        key: mikr.device.mem.free[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.freeMemory.first()
        - type: JAVASCRIPT
          parameters:
          - |-
            var v = String(value).trim();
            var m = v.match(/^([0-9.]+)\s*(KiB|MiB|GiB|TiB)?$/);
            if (!m) { throw 'unparsable memory value: ' + v; }
            var mult = { KiB: 1024, MiB: 1048576, GiB: 1073741824, TiB: 1099511627776 };
            return Math.round(parseFloat(m[1]) * (m[2] ? mult[m[2]] : 1));
          error_handler: DISCARD_VALUE
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: B
      - uuid: 5bc4cbc2401e4faaab2442c91f4815a8
        name: 'Device {#NAME}: total memory'
        type: DEPENDENT
        key: mikr.device.mem.total[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.totalMemory.first()
        - type: JAVASCRIPT
          parameters:
          - |-
            var v = String(value).trim();
            var m = v.match(/^([0-9.]+)\s*(KiB|MiB|GiB|TiB)?$/);
            if (!m) { throw 'unparsable memory value: ' + v; }
            var mult = { KiB: 1024, MiB: 1048576, GiB: 1073741824, TiB: 1099511627776 };
            return Math.round(parseFloat(m[1]) * (m[2] ? mult[m[2]] : 1));
          error_handler: DISCARD_VALUE
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: B
      - uuid: 6711f5c7951347c9b7b4c9b2143d32be
        name: 'Device {#NAME}: uptime (RouterOS)'
        type: DEPENDENT
        key: mikr.device.uptime.text[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.uptime.first()
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: d1a78b4953134a549d560f9bfe014c52
        name: 'Device {#NAME}: RouterOS version'
        type: DEPENDENT
        key: mikr.device.ros[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.routerOsVersion.first()
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1h
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: 323cb2bd1a3d4b5d82f2e3e0f8595ee2
        name: 'Device {#NAME}: RouterOS version (number only)'
        type: DEPENDENT
        key: mikr.device.ros.bare[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.routerOsVersion.first()
        - type: REGEX
          parameters:
          - ^(\S+)
          - \1
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
        description: RouterOS reports "7.23.2 (stable)" - the build train is stripped here so the version
          can be compared with the latest release, which carries no suffix.
      - uuid: a0b99e12419844ea9668ab31d3c57363
        name: 'Device {#NAME}: latest RouterOS for its channel'
        type: DEPENDENT
        key: mikr.device.ros.latest[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.latestRouterOs.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: eecc8e2a2eaa4440806afcc60729b245
        name: 'Device {#NAME}: update channel'
        type: DEPENDENT
        key: mikr.device.channel[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.updateChannel.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: 6b01b9ae092d4039b409942f8a918f1a
        name: 'Device {#NAME}: RouterBOARD firmware'
        type: DEPENDENT
        key: mikr.device.fw[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.firmwareVersion.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: c73ad3a86e3b43a18b0d0c35ae56facb
        name: 'Device {#NAME}: RouterBOARD firmware available'
        type: DEPENDENT
        key: mikr.device.fw.upgrade[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.upgradeFirmware.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: d1cccaf0d37a4da38f3a4f78085a191b
        name: 'Device {#NAME}: board'
        type: DEPENDENT
        key: mikr.device.board[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.boardName.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: ea8fb80ed4b941828db5406e199475db
        name: 'Device {#NAME}: model'
        type: DEPENDENT
        key: mikr.device.model[{#DEVID}]
        history: 31d
        value_type: CHAR
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.model.first()
          error_handler: DISCARD_VALUE
        - type: DISCARD_UNCHANGED_HEARTBEAT
          parameters:
          - 1d
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        trends: '0'
      - uuid: 58f316e045d84fe3a2352eae0661eb3a
        name: 'Device {#NAME}: last polled'
        type: DEPENDENT
        key: mikr.device.lastseen[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].lastSeen.first()
        - type: JAVASCRIPT
          parameters:
          - |-
            var t = Date.parse(value);
            if (isNaN(t)) { throw 'unparsable timestamp: ' + value; }
            return Math.round((Date.now() - t) / 1000);
          error_handler: DISCARD_VALUE
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: s
      - uuid: 50b30d3ec39c44af8377626ed367d6a9
        name: 'Device {#NAME}: memory used'
        type: CALCULATED
        key: mikr.device.mem.pct[{#DEVID}]
        delay: 1m
        history: 31d
        value_type: FLOAT
        units: '%'
        params: 100*(last(//mikr.device.mem.total[{#DEVID}])-last(//mikr.device.mem.free[{#DEVID}]))/last(//mikr.device.mem.total[{#DEVID}])
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
      trigger_prototypes:
      - uuid: 5a1b70b19afe4c95b9ffbd5a6ef0efe3
        expression: last(/MikroTik Manager by HTTP/mikr.device.online[{#DEVID}])=0
        name: 'Device {#NAME}: offline'
        priority: HIGH
        description: The manager polled this device and failed.
        dependencies:
        - name: 'mikr: manager is unreachable'
          expression: nodata(/MikroTik Manager by HTTP/mikr.health.status,5m)=1
        tags:
        - tag: scope
          value: availability
      - uuid: de68685e379b4adba251c102e84ab1a6
        expression: last(/MikroTik Manager by HTTP/mikr.device.online[{#DEVID}])=0 and last(/MikroTik
          Manager by HTTP/mikr.device.reachable[{#DEVID}])=1
        name: 'Device {#NAME}: answers on the network but will not poll'
        priority: AVERAGE
        description: The address is TCP-reachable, so this is credentials, a wedged SSH session, or a
          disabled service - not a dead device.
        dependencies:
        - name: 'Device {#NAME}: offline'
          expression: last(/MikroTik Manager by HTTP/mikr.device.online[{#DEVID}])=0
        tags:
        - tag: scope
          value: availability
      - uuid: 16761bedfc3d4fd2853ba8b9ff510685
        expression: min(/MikroTik Manager by HTTP/mikr.device.mem.pct[{#DEVID}],5m)>{$MIKR.RAM.WARN:"{#NAME}"}
        name: 'Device {#NAME}: high memory usage'
        priority: WARNING
        tags:
        - tag: scope
          value: performance
      - uuid: 08a74079aa124f32b4192b6d29ab4f6d
        expression: length(last(/MikroTik Manager by HTTP/mikr.device.ros.latest[{#DEVID}]))>0 and last(/MikroTik
          Manager by HTTP/mikr.device.ros.bare[{#DEVID}])<>last(/MikroTik Manager by HTTP/mikr.device.ros.latest[{#DEVID}])
        name: 'Device {#NAME}: RouterOS update available'
        priority: INFO
        description: Compares the bare version against the latest release the device knows about for its
          own channel. Both sides are empty until a "Check for updates" has run.
        tags:
        - tag: scope
          value: notice
      - uuid: 104e733fbda2490c899d82789e73eb20
        expression: length(last(/MikroTik Manager by HTTP/mikr.device.fw[{#DEVID}]))>0 and last(/MikroTik
          Manager by HTTP/mikr.device.fw[{#DEVID}])<>last(/MikroTik Manager by HTTP/mikr.device.fw.upgrade[{#DEVID}])
        name: 'Device {#NAME}: RouterBOARD firmware behind RouterOS'
        priority: INFO
        description: RouterOS was upgraded but the bootloader firmware was not; it needs a second reboot
          after /system routerboard upgrade.
        tags:
        - tag: scope
          value: notice
      - uuid: aebae072dd1f41d8ba45941a1feb7ef6
        expression: change(/MikroTik Manager by HTTP/mikr.device.ros[{#DEVID}])<>0
        name: 'Device {#NAME}: RouterOS version changed'
        priority: INFO
        manual_close: 'YES'
        tags:
        - tag: scope
          value: notice
      - uuid: a0d5e24a1101474d93f843478454176f
        expression: last(/MikroTik Manager by HTTP/mikr.device.lastseen[{#DEVID}])>{$MIKR.LASTSEEN.MAX}
        name: 'Device {#NAME}: monitoring data is stale'
        priority: WARNING
        description: The manager has not refreshed this device for longer than expected. Raise {$MIKR.LASTSEEN.MAX}
          for devices with a long per-device poll interval.
        dependencies:
        - name: 'Device {#NAME}: offline'
          expression: last(/MikroTik Manager by HTTP/mikr.device.online[{#DEVID}])=0
        tags:
        - tag: scope
          value: availability
      description: One host-level item set per enabled device, discovered from /api/devices. Disabled
        devices are filtered out.
    - uuid: f45d4dc4d6e648f899c366580b5e61aa
      name: CPU load discovery
      type: DEPENDENT
      key: mikr.sensor.cpu.discovery
      master_item:
        key: mikr.devices.raw
      lld_macro_paths:
      - lld_macro: '{#DEVID}'
        path: $.id
      - lld_macro: '{#NAME}'
        path: $.name
      - lld_macro: '{#SITEID}'
        path: $.siteId
      - lld_macro: '{#ENABLED}'
        path: $.enabled
      - lld_macro: '{#CPU}'
        path: $.status.cpuLoad
      filter:
        evaltype: AND
        conditions:
        - macro: '{#ENABLED}'
          value: 'true'
          formulaid: A
        - macro: '{#CPU}'
          value: ^-?[0-9]
          formulaid: B
      item_prototypes:
      - uuid: c683065c1b56416db365dc3225c39118
        name: 'Device {#NAME}: CPU load'
        type: DEPENDENT
        key: mikr.device.cpu[{#DEVID}]
        history: 31d
        value_type: UNSIGNED
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.cpuLoad.first()
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: '%'
      description: Only devices that report a number for CPU load.
      trigger_prototypes:
      - uuid: 008c497268224619855769e5c9e9f93f
        expression: min(/MikroTik Manager by HTTP/mikr.device.cpu[{#DEVID}],5m)>{$MIKR.CPU.WARN:"{#NAME}"}
        name: 'Device {#NAME}: high CPU load'
        priority: WARNING
        tags:
        - tag: scope
          value: performance
    - uuid: 9b7da63fbb1144d2b174e7641f90675c
      name: Temperature discovery
      type: DEPENDENT
      key: mikr.sensor.temp.discovery
      master_item:
        key: mikr.devices.raw
      lld_macro_paths:
      - lld_macro: '{#DEVID}'
        path: $.id
      - lld_macro: '{#NAME}'
        path: $.name
      - lld_macro: '{#SITEID}'
        path: $.siteId
      - lld_macro: '{#ENABLED}'
        path: $.enabled
      - lld_macro: '{#TEMP}'
        path: $.status.temperature
      filter:
        evaltype: AND
        conditions:
        - macro: '{#ENABLED}'
          value: 'true'
          formulaid: A
        - macro: '{#TEMP}'
          value: ^-?[0-9]
          formulaid: B
      item_prototypes:
      - uuid: 4660a94977b34fdcba3aa4ad3470e275
        name: 'Device {#NAME}: temperature'
        type: DEPENDENT
        key: mikr.device.temp[{#DEVID}]
        history: 31d
        value_type: FLOAT
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.temperature.first()
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: °C
      description: Only devices that report a number for temperature.
      trigger_prototypes:
      - uuid: 1d0dbe3cccc04d7f93a62c3a473c8c41
        expression: min(/MikroTik Manager by HTTP/mikr.device.temp[{#DEVID}],5m)>{$MIKR.TEMP.WARN:"{#NAME}"}
        name: 'Device {#NAME}: high temperature'
        priority: WARNING
        tags:
        - tag: scope
          value: performance
    - uuid: dbd7b340e5444eb8947eba01eda2ce6e
      name: Voltage discovery
      type: DEPENDENT
      key: mikr.sensor.voltage.discovery
      master_item:
        key: mikr.devices.raw
      lld_macro_paths:
      - lld_macro: '{#DEVID}'
        path: $.id
      - lld_macro: '{#NAME}'
        path: $.name
      - lld_macro: '{#SITEID}'
        path: $.siteId
      - lld_macro: '{#ENABLED}'
        path: $.enabled
      - lld_macro: '{#VOLTAGE}'
        path: $.status.voltage
      filter:
        evaltype: AND
        conditions:
        - macro: '{#ENABLED}'
          value: 'true'
          formulaid: A
        - macro: '{#VOLTAGE}'
          value: ^-?[0-9]
          formulaid: B
      item_prototypes:
      - uuid: 479fc3b9b2764666bb9c91eac4bfc73f
        name: 'Device {#NAME}: voltage'
        type: DEPENDENT
        key: mikr.device.voltage[{#DEVID}]
        history: 31d
        value_type: FLOAT
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.voltage.first()
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: V
      description: Only devices that report a number for voltage.
    - uuid: 65b2040bce5d4ff092e1e44538cc8cc0
      name: Power consumption discovery
      type: DEPENDENT
      key: mikr.sensor.power.discovery
      master_item:
        key: mikr.devices.raw
      lld_macro_paths:
      - lld_macro: '{#DEVID}'
        path: $.id
      - lld_macro: '{#NAME}'
        path: $.name
      - lld_macro: '{#SITEID}'
        path: $.siteId
      - lld_macro: '{#ENABLED}'
        path: $.enabled
      - lld_macro: '{#POWER}'
        path: $.status.powerConsumption
      filter:
        evaltype: AND
        conditions:
        - macro: '{#ENABLED}'
          value: 'true'
          formulaid: A
        - macro: '{#POWER}'
          value: ^-?[0-9]
          formulaid: B
      item_prototypes:
      - uuid: ffef115d91154630a504c79ecb5b2ae3
        name: 'Device {#NAME}: power consumption'
        type: DEPENDENT
        key: mikr.device.power[{#DEVID}]
        history: 31d
        value_type: FLOAT
        master_item:
          key: mikr.devices.raw
        preprocessing:
        - type: JSONPATH
          parameters:
          - $[?(@.id == "{#DEVID}")].status.powerConsumption.first()
        tags:
        - tag: component
          value: device
        - tag: device
          value: '{#NAME}'
        - tag: siteid
          value: '{#SITEID}'
        units: W
      description: Only devices that report a number for power consumption.
    macros:
    - macro: '{$MIKR.URL}'
      value: https://mikr.example.com
      description: Base URL of the manager, no trailing slash.
    - macro: '{$MIKR.API.KEY}'
      value: ''
      type: SECRET_TEXT
      description: API key from Settings - API keys. A viewer key with access to every site is enough
        for this template.
    - macro: '{$MIKR.CPU.WARN}'
      value: '80'
      description: 'Per-device override: {$MIKR.CPU.WARN:"device name"}.'
    - macro: '{$MIKR.TEMP.WARN}'
      value: '75'
    - macro: '{$MIKR.RAM.WARN}'
      value: '90'
    - macro: '{$MIKR.OFFLINE.MAX}'
      value: '2'
    - macro: '{$MIKR.RSS.MAX}'
      value: 512M
    - macro: '{$MIKR.DB.MAX}'
      value: 2G
    - macro: '{$MIKR.LASTSEEN.MAX}'
      value: '600'
      description: Seconds. Devices with a long per-device poll interval need a higher value.
    - macro: '{$MIKR.FEED.MAX.AGE}'
      value: '604800'
      description: Seconds before the CVE feed counts as stale.
    - macro: '{$MIKR.LICENSE.MIN.FREE}'
      value: '3'
    - macro: '{$MIKR.LICENSE.MIN.DAYS}'
      value: '30'
    - macro: '{$MIKR.IDS.MAX.NEW}'
      value: '10'
      description: New brute-force sources within an hour before alerting.
    - macro: '{$MIKR.DEVICE.MATCHES}'
      value: .*
      description: Discover only devices whose name matches.
    - macro: '{$MIKR.DEVICE.NOT_MATCHES}'
      value: CHANGE_IF_NEEDED
      description: Skip devices whose name matches.
    valuemaps:
    - uuid: 987811353d9f4a56880991dd88872122
      name: Service state
      mappings:
      - value: '0'
        newvalue: Down
      - value: '1'
        newvalue: Up
    - uuid: d1f2e7e8969144baa46324114ff29414
      name: Enabled
      mappings:
      - value: '0'
        newvalue: 'No'
      - value: '1'
        newvalue: 'Yes'
  triggers:
  - uuid: 66cf17d674ab427b851bc05e9b70a16a
    expression: nodata(/MikroTik Manager by HTTP/mikr.health.status,5m)=1
    name: 'mikr: manager is unreachable'
    priority: HIGH
    description: /api/health stopped answering. Every device trigger depends on this one, so a dead manager
      raises one problem, not N.
    tags:
    - tag: scope
      value: availability
  - uuid: 5f900f3e97a949aeb37070ec15a07cde
    expression: last(/MikroTik Manager by HTTP/mikr.health.status)=0
    name: 'mikr: service reports a degraded status'
    priority: HIGH
    tags:
    - tag: scope
      value: availability
  - uuid: fa5da278d42c4bfa8b182a2b3945dc69
    expression: nodata(/MikroTik Manager by HTTP/mikr.devices.count,10m)=1 and nodata(/MikroTik Manager
      by HTTP/mikr.health.status,10m)=0
    name: 'mikr: API key is not working'
    priority: AVERAGE
    description: 'Health is answering but the authenticated endpoint is not: the key in {$MIKR.API.KEY}
      was revoked, expired, or lost its site scope.'
    dependencies:
    - name: 'mikr: manager is unreachable'
      expression: nodata(/MikroTik Manager by HTTP/mikr.health.status,5m)=1
    tags:
    - tag: scope
      value: availability
  - uuid: d6710d5498be42a598b18ba27bd43ace
    expression: last(/MikroTik Manager by HTTP/mikr.devices.offline)>{$MIKR.OFFLINE.MAX}
    name: 'mikr: more than {$MIKR.OFFLINE.MAX} devices are offline'
    priority: AVERAGE
    description: Fleet-wide signal. Which devices are down comes from the per-device triggers.
    dependencies:
    - name: 'mikr: manager is unreachable'
      expression: nodata(/MikroTik Manager by HTTP/mikr.health.status,5m)=1
    tags:
    - tag: scope
      value: availability
  - uuid: d7d2b62e1bda49b6af66ac6fcf563052
    expression: min(/MikroTik Manager by HTTP/mikr.mem.rss,15m)>{$MIKR.RSS.MAX}
    name: 'mikr: manager memory usage is high'
    priority: WARNING
    tags:
    - tag: scope
      value: performance
  - uuid: df6098e9f61b48ebb0653caaf1d09c4a
    expression: last(/MikroTik Manager by HTTP/mikr.db.bytes)>{$MIKR.DB.MAX}
    name: 'mikr: database is larger than {$MIKR.DB.MAX}'
    priority: INFO
    description: Usually syslog retention. Settings has per-device row caps and a retention period.
    tags:
    - tag: scope
      value: capacity
  - uuid: 7a8df55bd45f49629ff0b2711cf4e4a5
    expression: last(/MikroTik Manager by HTTP/mikr.uptime)<600
    name: 'mikr: manager restarted'
    priority: INFO
    manual_close: 'YES'
    tags:
    - tag: scope
      value: notice
  - uuid: 25948000b3d04f5cb749ea3d81893d45
    expression: change(/MikroTik Manager by HTTP/mikr.version)<>0
    name: 'mikr: version changed'
    priority: INFO
    manual_close: 'YES'
    tags:
    - tag: scope
      value: notice
  - uuid: d145c1f7c4634cdca0249e67fee4ea66
    expression: last(/MikroTik Manager by HTTP/mikr.update.available)=1
    name: 'mikr: a newer manager release is published'
    priority: INFO
    tags:
    - tag: scope
      value: notice
  - uuid: 39dd1ec78adf4eaba6555915a9b81b1b
    expression: last(/MikroTik Manager by HTTP/mikr.cve.critical)>0
    name: 'mikr: critical CVEs affect the fleet'
    priority: HIGH
    tags:
    - tag: scope
      value: security
  - uuid: 6e7a3065b0e943918695855563f2d0c6
    expression: last(/MikroTik Manager by HTTP/mikr.cve.high)>0
    name: 'mikr: high-severity CVEs affect the fleet'
    priority: AVERAGE
    dependencies:
    - name: 'mikr: critical CVEs affect the fleet'
      expression: last(/MikroTik Manager by HTTP/mikr.cve.critical)>0
    tags:
    - tag: scope
      value: security
  - uuid: 89962ac884584fbda71ca087bd4c1a8f
    expression: last(/MikroTik Manager by HTTP/mikr.cve.age)>{$MIKR.FEED.MAX.AGE}
    name: 'mikr: CVE feed has not refreshed'
    priority: WARNING
    description: A stale feed reads as "no vulnerabilities" on every CVE item above, which is the dangerous
      failure mode.
    tags:
    - tag: scope
      value: security
  - uuid: 86bb458dbf984407a7860f19c4913794
    expression: last(/MikroTik Manager by HTTP/mikr.patchgaps.affected)>0
    name: 'mikr: devices are missing security-flagged RouterOS releases'
    priority: WARNING
    tags:
    - tag: scope
      value: security
  - uuid: 59bfd03fd069467c9efbb6c2b4040b1f
    expression: last(/MikroTik Manager by HTTP/mikr.license.free)>=0 and last(/MikroTik Manager by HTTP/mikr.license.free)<{$MIKR.LICENSE.MIN.FREE}
    name: 'mikr: running out of licensed device slots'
    priority: WARNING
    description: Unlimited tiers report -1 and never fire.
    tags:
    - tag: scope
      value: capacity
  - uuid: 28faba3507694dca84ef6cde35773bdf
    expression: last(/MikroTik Manager by HTTP/mikr.license.updates.days)>=0 and last(/MikroTik Manager
      by HTTP/mikr.license.updates.days)<{$MIKR.LICENSE.MIN.DAYS}
    name: 'mikr: license updates period is ending'
    priority: INFO
    description: Lifetime-update tiers report -1 and never fire.
    tags:
    - tag: scope
      value: capacity
  - uuid: ac72ca91f3fa4bd1821deb5f1e456bed
    expression: last(/MikroTik Manager by HTTP/mikr.features.syslog)=1 and last(/MikroTik Manager by HTTP/mikr.syslog.devices)=0
    name: 'mikr: syslog receiver is enabled but nothing is arriving'
    priority: WARNING
    description: Usually the devices point at the old collector address, or UDP 5514 is filtered.
    tags:
    - tag: scope
      value: notice
  - uuid: f299586dbf4541a4900724cc68ea1057
    expression: (last(/MikroTik Manager by HTTP/mikr.ids.candidates)-min(/MikroTik Manager by HTTP/mikr.ids.candidates,1h))>{$MIKR.IDS.MAX.NEW}
    name: 'mikr: a burst of new addresses is brute-forcing devices'
    priority: AVERAGE
    description: The candidate list only grows, so a threshold on its size would fire once and stay lit.
      This looks at how many appeared in the last hour.
    tags:
    - tag: scope
      value: security
  - uuid: b7b78ff7b9114fcfa84a8e579fbc8936
    expression: last(/MikroTik Manager by HTTP/mikr.tasks.failed)>0
    name: 'mikr: a task finished with errors'
    priority: WARNING
    manual_close: 'YES'
    tags:
    - tag: scope
      value: notice
