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.

Alias

monitor

Actions

Events

none

Registering the plugin

How to register the monitor plugin with the blockchain application.

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);
  });

Default configuration

The monitor plugin can be configured in the configuration of the blockchain application under plugins.monitor.

The application will use the default values, in case there is no plugin configuration provided.
Monitor options in the configuration
const { Application, HTTPAPIPlugin, genesisBlockDevnet, configDevnet } = require('lisk-sdk');

const appConfig = utils.objects.mergeDeep({}, configDevnet, {
  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)
		},
	},
  }
});

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

app.registerPlugin(HTTPAPIPlugin);

app
  .run()
  .then(() => app.logger.info('App started...'))
  .catch(error => {
    console.error('Faced error in application', error);
    process.exit(1);
  });
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 CORS, (Cross-Origin Resource Sharing).
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.

Actions

monitor:getBlockStats

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

Input

none

Returns

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

monitor:getForkStats

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

Input

none

Returns

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

monitor: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
  }
}

monitor:getTransactionStats

Returns various statistics about transactions in the network.

Input

none

Returns

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