Skip to main content

Monitoring

ReSolve includes an inbuilt monitoring mechanism that allows a reSolve application to collect and publish various metrics during its execution.

Monitoring Adaptersā€‹

Monitoring adapters define how the metrics are collected are published. The following adapters are included:

Module NameDescription
@resolve-js/monitoring-consolePrints the collected metrics to the text console output.
@resolve-js/monitoring-aws-cloudwatchPublishes the collected metrics to AWS CloudWatch.

An application's monitoring adapters are specified in the application's configuration files:

/app-config.js
monitoringAdapters: {
console: {
module: '@resolve-js/monitoring-console',
options: {
publishMode: 'processExit',
},
},
...
}

Refer to the monitoringAdapters section of the Application Configuration topic for more information on monitoring adapter options.

On a local machine or a standalone server, you need to explicitly specify the monitoring adapter to enable monitoring.

In the reSolve Cloud environment, the default monitoring adapter always exists. If this adapter is not explicitly specified in the application's configuration files, it defaults to @resolve-js/monitoring-aws-cloudwatch.

You can implement your own monitoring adapter based on the @resolve-js/monitoring-base package. Refer to the Monitoring Adapter API reference topic for information on how to achieve this.

Monitoring APIā€‹

You can access the monitoring API through the reSolve context object. For example, the following code sample demonstrates how to access the monitoring API in an API handler function:

const myHandler = async (req, res) => {
const {resolve: { monitoring } } = req
const metrics = monitoring.getMetrics('default')
...
}

To learn about the API exposed by this object, see the Monitoring Interface article.