
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
express-performance-monitor
Advanced tools
Monitoring tooling agnostic Express Application Server in-process performance monitoring middleware and agent
Monitoring tooling agnostic Express Application Server in-process performance monitoring middleware and agent
With express-monitor
provides node application server developers with a flexible way of implementing service specific monitoring over a
unified interface. You can monitor your current express app, internals, add new monitoring fields and extend the exposed monitoring data
In this simplified example we
var Manager = require("express-performance-monitor").Manager;
var app = require("express")();
var manager = new monitor.Manager({
maxRetention: 1000 * 60 * 5,
aggregate: 60,
apis: ["web"],
server: {
"web": {
port: 3001,
listen: "0.0.0.0"
}
});
var middleware = require("express-performance-monitor").middleware(manager);
// IMPORTANT: to make sure we see everythin add this as the first middleware in your middleware stack
app.use(middleware);
app.get("/", function(req, res) {
res.sendStatus(200);
});
app.listen(3000, function() {
console.log("Listening on localhost:3000");
});
Out of the box you will get statistics for:
for each network request sent through your express app.
The middleware will store aggregated performance data specific to the type of data you wish to collect.
Depending on the metrics you are interested in different types of aggregation can be applied. Here are a few examples we already provide:
{
"name": "memory",
"type": "avg",
"aggregate": 60
}
Example usage:
var pidusage = require("pidusage");
pidusage.stat(process.pid, function(err, stat) {
if (err) {
return;
}
manager.addDataPoint("memory", stat.memory);
});
Averaged over each event and collected data this will store the last minute of memory and aggregate the metric
{
"name": "requestCount",
"type": "count",
"aggregate": 60
}
Example usage:
manager.addDataPoint("requestCount");
Count-style aggregation with a configuration like this will provide a counter that will reset every minute and have a histogram for the last minute of the counter.
{
"name": "transferredBytes",
"type": "cumulative",
"aggregate": 60
}
Example usage:
manager.addDataPoint("transferredBytes", data.length);
This is a special type of the Counter where the value added to the counter is not affixed to the a single increment but the value passed into the datapoint addition call.
Interacting with the Manager instance during your express applications lifecycle is possible using the express Request object parameter passed into every callback.
You can find it under the req.monitor.manager
object in your callback:
app.get("/status", function(req, res) {
res.json(req.monitor.manager.getState());
});
Please review the API documentation for more information on how to interact with the Manager instance.
Using the API Module infrastructure you are free to either use the provided API endpoint modules provided out of the box with this package
or write your own module. Have a look at the lib/apis/example.js
for a simple example of how to implement your own API endpoints applicable
for your environment.
FAQs
Monitoring tooling agnostic Express Application Server in-process performance monitoring middleware and agent
We found that express-performance-monitor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.