Monitor plugin

@liskhq/lisk-framework-monitor-plugin is a plugin for the Lisk Framework that provides network statistics of the running node.

The monitor plugin offers Prometheus endpoints, which are reachable under the endpoint /api/prometheus/metrics.

Name Property

Alias

monitor

Actions

getTransactionStats, getBlockStats, getNetworkStats, getForkStats

Events

none

Default configuration

Forger options in the configuration
{
  //[...]
  plugins: {
    monitor: { (1)
		port: 4003, (2)
		whiteList: ['127.0.0.1'], (3)
		cors: { (4)
			origin: '*', (5)
			methods: ['GET', 'POST', 'PUT'], (6)
		},
		limits: { (7)
			max: 0, (8)
			delayMs: 0, (9)
			delayAfter: 0, (10)
			windowMs: 60000, (11)
			headersTimeout: 5000, (12)
			serverSetTimeout: 20000, (13)
		},
	},
  }
}
1 monitor: Contains options for the monitor plugin.
2 port: HTTP port which the monitor plugin listens on.
3 whiteList: This parameter allows connections to the monitor plugin by IP.
4 cors: Contain options for cross-origin ressource sharing (CORS).
5 origin: Defines the domains that the resource can be accessed by in a cross-site manner. Defaults to all domains.
6 methods(optional): Defines the allowed methods for CORS.
7 limits: Contains options about time limits.
8 max: Maximum amount of connections.
9 delayMs: Minimum delay between API calls in ms.
10 delayAfter: Minimum delay after an API call in ms.
11 windowMs: Minimum delay between API calls from the same window.
12 headersTimeout: Indicates the minimum amount of time an idle connection has to be kept opened, (in seconds).
13 serverSetTimeout: Time to wait for a response from the server before timing out.

Registering the plugin

const { Application, MonitorPlugin, genesisBlockDevnet, configDevnet } = require('lisk-sdk');

const app = Application.defaultApplication(genesisBlockDevnet, configDevnet);

app.registerPlugin(MonitorPlugin);

app
  .run()
  .then(() => app.logger.info('App started...'))
  .catch(error => {
    console.error('Faced error in application', error);
    process.exit(1);
  });

Actions

getBlockStats

Returns statistics about the blocks that occurred in the network so far.

Input

none

Returns

{
  "blocks": {},
  "averageReceivedBlocks": 0,
  "connectedPeers": 0
}

getForkStats

Returns statistics about the forks that occurred in the network so far.

Input

none

Returns

{
  "forkEventCount": 0,
  "blockHeaders": {}
}

getNetworkStats

Returns various statistics about the network the node is connected to.

Input

none

Returns

{
  "startTime": 1610646123535,
  "incoming": {
    "count": 0,
    "connects": 0,
    "disconnects": 0
  },
  "outgoing": {
    "count": 0,
    "connects": 0,
    "disconnects": 3
  },
  "banning": {
    "bannedPeers": {},
    "totalBannedPeers": 0
  },
  "totalErrors": 6,
  "totalPeersDiscovered": 0,
  "totalRemovedPeers": 3,
  "totalMessagesReceived": {},
  "totalRequestsReceived": {},
  "majorityHeight": {
    "height": 0,
    "count": 0
  },
  "totalPeers": {
    "connected": 0,
    "disconnected": 0
  }
}

getTransactionStats

Returns various statistics about transactions in the network.

Input

none

Returns

{
  "transactions": {},
  "connectedPeers": 0,
  "averageReceivedTransactions": 0
}