Gathering detailed insights and metrics for pmx
Gathering detailed insights and metrics for pmx
Gathering detailed insights and metrics for pmx
Gathering detailed insights and metrics for pmx
@toolisticon/oc-routes-prometheus-exporter
[](LICENSE) [](https://github.com/toolisticon/oc-routes-prometheus-exporter/act
@toolisticon/ssl-hostinfo-prometheus-exporter
[](LICENSE) [](https://github.com/toolisticon/ssl-hostinfo-prometheus-export
pmx-overlay
Module to generate an overlay and trap focus on the active element
pmx-dataapi
Module to define components through a data-* API
(DEPRECATED) use @pm2/io instead (drop-in replacement) https://github.com/keymetrics/pm2-io-apm
npm install pmx
Typescript
Module System
Node Version
NPM Version
JavaScript (96.51%)
HTML (3.49%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
264 Stars
454 Commits
32 Forks
20 Watchers
8 Branches
23 Contributors
Updated on Jan 02, 2025
Latest Version
1.6.7
Package Id
pmx@1.6.7
Size
54.11 kB
NPM Version
5.5.1
Node Version
9.0.0
Published on
Jun 14, 2018
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
PMX allows you to create advanced interactions with PM2 and Keymetrics.io.
Install pmx with npm:
1$ npm install pmx --save
PMX allows you to expose code metrics from your code to the PM2 monit command or the Keymetrics Dashboard, in realtime and over time.
4 measurements are available:
This allow to expose values that can be read instantly.
1var probe = pmx.probe(); 2 3// Here the value function will be called each second to get the value 4// returned by Object.keys(users).length 5var metric = probe.metric({ 6 name : 'Realtime user', 7 value : function() { 8 return Object.keys(users).length; 9 } 10}); 11 12// Here we are going to call valvar.set() to set the new value 13var metric_2 = probe.metric({ 14 name : 'Realtime Value' 15}); 16 17metric_2.set(23);
Things that increment or decrement.
1var probe = pmx.probe(); 2 3// The counter will start at 0 4var counter = probe.counter({ 5 name : 'Current req processed' 6}); 7 8http.createServer(function(req, res) { 9 // Increment the counter, counter will eq 1 10 counter.inc(); 11 req.on('end', function() { 12 // Decrement the counter, counter will eq 0 13 counter.dec(); 14 }); 15});
Things that are measured as events / interval.
1var probe = pmx.probe(); 2 3var meter = probe.meter({ 4 name : 'req/sec', 5 samples : 1 // This is per second. To get per min set this value to 60 6}); 7 8http.createServer(function(req, res) { 9 meter.mark(); 10 res.end({success:true}); 11});
Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution.
1var probe = pmx.probe(); 2 3var histogram = probe.histogram({ 4 name : 'latency', 5 measurement : 'mean' 6}); 7 8var latency = 0; 9 10setInterval(function() { 11 latency = Math.round(Math.random() * 100); 12 histogram.update(latency); 13}, 100);
sum
, max
, min
, avg
(default) or none
. It will impact the way the probe data are aggregated within the Keymetrics backend. Use none
if this is irrelevant (eg: constant or string value).Meter
and Counter
probes. Creates an alert object (see below).Remotely trigger functions from Keymetrics. These metrics takes place in the main Keymetrics Dashboard page under the Custom Action section.
Simple action allows to trigger a function from Keymetrics. The function takes a function as a parameter (reply here) and need to be called once the job is finished.
Example:
1var pmx = require('pmx'); 2 3pmx.action('db:clean', function(reply) { 4 clean.db(function() { 5 /** 6 * reply() must be called at the end of the action 7 */ 8 reply({success : true}); 9 }); 10});
Scoped Actions are advanced remote actions that can be also triggered from Keymetrics.
Two arguments are passed to the function, data (optional data sent from Keymetrics) and res that allows to emit log data and to end the scoped action.
Example:
1pmx.scopedAction('long running lsof', function(data, res) { 2 var child = spawn('lsof', []); 3 4 child.stdout.on('data', function(chunk) { 5 chunk.toString().split('\n').forEach(function(line) { 6 res.send(line); // This send log to Keymetrics to be saved (for tracking) 7 }); 8 }); 9 10 child.stdout.on('end', function(chunk) { 11 res.end('end'); // This end the scoped action 12 }); 13 14 child.on('error', function(e) { 15 res.error(e); // This report an error to Keymetrics 16 }); 17 18});
(Specific to Keymetrics)
This alert system can monitor a Probe value and launch an exception when hitting a particular value.
Example for a cpu_usage
variable:
1var metric = probe.metric({ 2 name : 'CPU usage', 3 value : function() { 4 return cpu_usage; 5 }, 6 alert : { 7 mode : 'threshold', 8 value : 95, 9 msg : 'Detected over 95% CPU usage', // optional 10 func : function() { //optional 11 console.error('Detected over 95% CPU usage'); 12 }, 13 cmp : "<" // optional 14 } 15});
threshold
, threshold-avg
.<
, >
, =
to Threshold value the exception is launched. Can also be a function used for exception check taking 2 arguments and returning a bool.threshold-avg
mode. Sample length for monitored value (180 seconds default).threshold-avg
mode. Time after which mean comparison starts (30 000 milliseconds default).(Specific to Keymetrics)
By default once PM2 is linked to Keymetrics, you will be alerted of any uncaught exception. These errors are accessible in the Issue tab of Keymetrics.
If you need to alert about any critical errors you can do it programmatically:
1var pmx = require('pmx'); 2 3pmx.notify({ success : false }); 4 5pmx.notify('This is an error'); 6 7pmx.notify(new Error('This is an error'));
When an uncaught exception is happening you can track from which routes it has been thrown.
To do that you have to attach the middleware pmx.expressErrorHandler
at then end of your routes mounting:
1var pmx = require('pmx'); 2 3// All my routes 4app.get('/' ...); 5app.post(...); 6// All my routes 7 8// Here I attach the middleware to get more verbosity on exception thrown 9app.use(pmx.expressErrorHandler());
Emit events and get historical and statistics. This is available in the Events page of Keymetrics.
1var pmx = require('pmx'); 2 3pmx.emit('user:register', { 4 user : 'Alex registered', 5 email : 'thorustor@gmail.com' 6});
You can monitor the network usage of a specific application by adding the option network: true
when initializing PMX. If you enable the flag ports: true
when you init pmx it will show which ports your app is listenting on.
These metrics will be shown in the Keymetrics Dashboard in the Custom Metrics section.
Example:
1pmx.init({ 2 [...] 3 network : true, // Allow application level network monitoring 4 ports : true // Display ports used by the application 5});
1var pmx = require('pmx').init({ 2 network : true, // (default: false) Network monitoring at the application level 3 ports : true, // (default: false) Shows which ports your app is listening on 4 // can be 'express', 'hapi', 'http', 'restify' 5 excludedHooks: [] 6});
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 5/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More