Git Product home page Git Product logo

pmx's Introduction


PM2 programmatic integration



PMX allows you to create advanced interactions with PM2 and Keymetrics.io.

Table of Contents

Installation

Install pmx with npm:

$ npm install pmx --save

Expose Metrics: Measure anything

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:

  • Simple metrics: Values that can be read instantly
    • eg. Monitor variable value
  • Counter: Things that increment or decrement
    • eg. Downloads being processed, user connected
  • Meter: Things that are measured as events / interval
    • eg. Request per minute for a http server
  • Histogram: Keeps a reservoir of statistically relevant values biased towards the last 5 minutes to explore their distribution
    • eg. Monitor the mean of execution of a query into database

Metric: Simple value reporting

This allow to expose values that can be read instantly.

var probe = pmx.probe();

// Here the value function will be called each second to get the value
// returned by Object.keys(users).length
var metric = probe.metric({
  name    : 'Realtime user',
  value   : function() {
    return Object.keys(users).length;
  }
});

// Here we are going to call valvar.set() to set the new value
var metric_2 = probe.metric({
  name    : 'Realtime Value'
});

metric_2.set(23);

Options

  • name: Probe name
  • value: (optional) function that allows to monitor a global variable

Counter: Sequential value change

Things that increment or decrement.

var probe = pmx.probe();

// The counter will start at 0
var counter = probe.counter({
  name : 'Current req processed'
});

http.createServer(function(req, res) {
  // Increment the counter, counter will eq 1
  counter.inc();
  req.on('end', function() {
    // Decrement the counter, counter will eq 0
    counter.dec();
  });
});

Options

  • name: Probe name

Meter: Average calculated values

Things that are measured as events / interval.

var probe = pmx.probe();

var meter = probe.meter({
  name      : 'req/sec',
  samples   : 1  // This is per second. To get per min set this value to 60
});

http.createServer(function(req, res) {
  meter.mark();
  res.end({success:true});
});

Options

  • name: Probe name
  • samples: (optional)(default: 1) Rate unit. Defaults to 1 sec.
  • timeframe: (optional)(default: 60) timeframe over which events will be analyzed. Defaults to 60 sec.

Histogram

Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution.

var probe = pmx.probe();

var histogram = probe.histogram({
  name        : 'latency',
  measurement : 'mean'
});

var latency = 0;

setInterval(function() {
  latency = Math.round(Math.random() * 100);
  histogram.update(latency);
}, 100);

Options

  • name: Probe name
  • agg_type : (optional)(default: none) Can be 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).
  • alert : (optional)(default: null) For Meter and Counter probes. Creates an alert object (see below).

Expose Functions: Trigger Functions remotely

Remotely trigger functions from Keymetrics. These metrics takes place in the main Keymetrics Dashboard page under the Custom Action section.

Simple actions

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:

var pmx = require('pmx');

pmx.action('db:clean', function(reply) {
  clean.db(function() {
    /**
     * reply() must be called at the end of the action
     */
     reply({success : true});
  });
});

Scoped actions (beta)

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:

pmx.scopedAction('long running lsof', function(data, res) {
  var child = spawn('lsof', []);

  child.stdout.on('data', function(chunk) {
    chunk.toString().split('\n').forEach(function(line) {
      res.send(line); // This send log to Keymetrics to be saved (for tracking)
    });
  });

  child.stdout.on('end', function(chunk) {
    res.end('end'); // This end the scoped action
  });

  child.on('error', function(e) {
    res.error(e);  // This report an error to Keymetrics
  });

});

Alert System for Custom Metrics

(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:

var metric = probe.metric({
  name  : 'CPU usage',
  value : function() {
    return cpu_usage;
  },
  alert : {
    mode  : 'threshold',
    value : 95,
    msg   : 'Detected over 95% CPU usage', // optional
    func  : function() { //optional
      console.error('Detected over 95% CPU usage');
    },
    cmp   : "<" // optional
  }
});

Options

  • mode : threshold, threshold-avg.
  • value : Value that will be used for the exception check.
  • msg : String used for the exception.
  • func : optional. Function declenched when exception reached.
  • cmp : optional. If current Probe value is not <, >, = to Threshold value the exception is launched. Can also be a function used for exception check taking 2 arguments and returning a bool.
  • interval : optional, threshold-avg mode. Sample length for monitored value (180 seconds default).
  • timeout : optional, threshold-avg mode. Time after which mean comparison starts (30 000 milliseconds default).

Report Alerts: Errors / Uncaught Exceptions

(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.

Custom alert notification

If you need to alert about any critical errors you can do it programmatically:

var pmx = require('pmx');

pmx.notify({ success : false });

pmx.notify('This is an error');

pmx.notify(new Error('This is an error'));

Add Verbosity to an Alert: Express Error handler

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:

var pmx = require('pmx');

// All my routes
app.get('/' ...);
app.post(...);
// All my routes

// Here I attach the middleware to get more verbosity on exception thrown
app.use(pmx.expressErrorHandler());

Emit Events

Emit events and get historical and statistics. This is available in the Events page of Keymetrics.

var pmx = require('pmx');

pmx.emit('user:register', {
  user : 'Alex registered',
  email : '[email protected]'
});

Application level network traffic monitoring / Display used ports

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:

pmx.init({
  [...]
  network : true, // Allow application level network monitoring
  ports   : true  // Display ports used by the application
});

Advanced PMX configuration

var pmx = require('pmx').init({
  network       : true, // (default: false) Network monitoring at the application level
  ports         : true, // (default: false) Shows which ports your app is listening on
  // can be 'express', 'hapi', 'http', 'restify'
  excludedHooks: []
});

License

MIT

GA

pmx's People

Contributors

anthonyttaylor avatar apercu avatar arkotek avatar jiangzhuo avatar jorge-d avatar jshkurti avatar kulakowka avatar lino-silva avatar lklepner avatar lupino3 avatar nathanhinish avatar nickclaw avatar paulguo avatar robixxu avatar toddwong avatar unitech avatar vmarchaud avatar vpotseluyko avatar wallet77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pmx's Issues

Error: Cannot find module 'connect-flash'

Trying to add PMX to an Express 4.9.8 app running under pm2 15.10 I get an error that connect-flash cannot be found.

The full error reads -
Error: Cannot find module 'connect-flash'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function. (/myapp/node_modules/pmx/lib/transaction.js:47:40)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /myapp/app.js:99:17
at /myapp/node_modules/mongodb/lib/mongo_client.js:455:11
at process._tickDomainCallback (node.js:381:11)

"connect-flash": "^0.1.1" is present in the present in the package.json and node_modules folder.

Any ideas what might be wrong?

Thanks,
Lou

integration with angularjs

I've been using pm2 for management processing tool of my angularjs project it's a great tool !.. the question is really simple.. could I integrate this component on my angularjs project ? so basically I want to include this component when I do a login for example

$scope.login = function(form) {
   if (form.$valid) {
      pmx.emit('user:register', {
         user : 'Alex registered',
         email : '[email protected]'
      });
   }
}

could I do this ?

Auto pull

  • Module for auto pull all applications automatically (call pm2 pullAnd[Reload/Restart] for each app)

[PMX] Action stop data stream will be binded once linked to Keymetrics

I've had a PMX action running ok for several months,but just today I started seeing the messages above. When this occurs it screws up my program as it seems to execute and set okToStream false which causes the task fail.

The code I use is:

pmx.action('stop data stream', function (reply) {
    okToStream = false;
    reply("Data stream stopped");
});

What does the error message mean?

interval is preventing application to gracefully shutdown

Test app:

require('pmx').init({
  http: false
});

var interval = setInterval(function(){
    console.log('working...');
}, 500);

process.on('SIGINT', function(){
    console.log('SIGINT received. Shutting down...');
    setTimeout(function(){
        console.log('Now ready to shutdown. Exiting');
        clearInterval(interval);
    }, 1000);
});

This application cannot shutdown because an active interval in pmx is preventing it.
This is the causing code snippet (/lib/pm2_module.js:18)

Options.configureModule = function(opts) {
  if (!this.running) {
    this.running = true;
    /* Avoid automatic exit of the script */

    setInterval(function() {}, 1000);
  }

  Transport.send({
    type : 'axm:option:configuration',
    data : opts
  }, false);
};

It creates the same issue in PM2 :(
Is it possible to take a different solution here?

Thanks in advance
Igor

How to set a new probe to the Dashboard

Hello,

I have a 'free plan' account.
I've added below codes. I can see on Probes debug page. However, I wasn't able to put my probe on my Dashboard. Actually I don't know whether I can see on my dashboard or not. What should I do?

var pmx = require('pmx'),
    probe = pmx.probe(),
    meter = probe.meter({ name: 'req/min', agg_type: 'avg', seconds: 60 });
app.use(function(req, res, next){ meter.mark() })
pmx.init()

Process disconnected from parent and json type error

Hi,

please take a look at the following:

server-0 (err): Process disconnected from parent !
server-0 (err): TypeError: Converting circular structure to JSON
server-0 (err):     at Object.stringify (native)
server-0 (err):     at process.target.send (child_process.js:461:23)
server-0 (err):     at ipcSend (.../node_modules/pmx/lib/utils/transport.js:21:13)
server-0 (err):     at Object.Transport.send (.../node_modules/pmx/lib/utils/transport.js:32:3)
server-0 (err):     at process.catchException (.../node_modules/pmx/lib/notify.js:39:15)
server-0 (err):     at process.g (events.js:180:16)
server-0 (err):     at process.emit (events.js:95:17)
server-0 (err):     at process._fatalException (node.js:272:26)
PM2: 2015-04-20 09:46:33: App closed with code: 1

The converting circular structure error seems to be coming from pmx itself, in transport.js

try {
    process.send(args);
} catch(e) {
    console.error('Process disconnected from parent !');
    console.error(e.stack || e);
    process.exit(1);
}

The error that caused this is an TypeError: undefined is not a function error

Shouldn't this error get logged to keymetrics instead of pmx itself breaking? The error stack that seems to cause the problem doesn't seem interesting at all, just a normal stack.

Can't get the latency working with node cluster

Hey,

i'm trying to use pm2 with pmx but I can't get the HTTP Latency working. (Basically, no routes are working)

I use node-cluster to spawn 4 processes.
var pmx = require('pmx').init();
is the first line of my program and I spawn the different processes after.

Any suggestions ?

user count with pmx

hi

we are develop monitoring service.
we are testing many user connections.
our purpose about 7,000 user.

so, there is the bug.

some process not show user count, forever.
we are use with pmx.

why not show??
somebody help me, please.

under image link.
_2015_07_02_11_19_36_25

Show transactions/latency shows no results

Hi,
I'm having issues with pmx transactions/latency monitoring

On the dashboard I've started to see HTTP avg. metric, which currently shows 288ms

And the configuration is the following

require('pmx').init({
      http          : true,
      errors        : true,
      custom_probes : true,
      network       : true,
      ports         : true
   });

But when I click on inspect it shows no results
Great! Not any routes are taking more than 200ms!

I've tried different options such as http_latency: 100 and lower in an attempt to see any result.
And I've tried http_codes: 200 which, according to the code, should record all the requests (just to test the functionality)
but no results are shown

Am I doing something wrong?

PS. Just in case, my server is working over https

trouble integrating with restify (require order, module not found error)

i wanted to set up pmx with restify (4.0.3) and i understood i need to include pmx before inclusion of any http related stuff happens. so since i want to make pmx optional (external config file) i happen to include it within an async waterfall during setup.

so when i include restify before pmx everything works (except for catching routes with pmx, i guess).

but when i include it like this:

// ...
        }, function (cb) {
            if (config.get.api_server.usePmx) {
                pmx = require('pmx').init({
                    http: true, // HTTP routes logging (default: true)
                    ignore_routes: [/socket\.io/, /notFound/], // Ignore http routes with this pattern (Default: [])
                    errors: true, // Exceptions loggin (default: true)
                    custom_probes: true, // Auto expose JS Loop Latency and HTTP req/s as custom metrics
                    network: true, // Network monitoring at the application level
                    ports: true,  // Shows which ports your app is listening on (default: false)
                    alert_enabled: true  // Enable alert sub field in custom metrics   (default: false)
                });
            }
            cb();
        }, function (cb) {
            var restify = require('restify'),
                server = restify.createServer({
// ...

i get this weird stacktrace and error:

/usr/local/bin/node --harmony app.js
Error: Cannot find module 'restify'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Function._load (/Users/anton/WebstormProjects/piecemeta-api/node_modules/pmx/lib/transaction.js:62:21)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /Users/anton/WebstormProjects/piecemeta-api/app.js:68:27
    at fn (/Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:717:34)
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:1170:16
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:172:37
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:677:43
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:173:37
    at Immediate._onImmediate (/Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:1163:34)
    at processImmediate [as _immediateCallback] (timers.js:368:17)

Process finished with exit code 255

so it is some load action in pmx/lib/transaction but i have no idea what it is supposed to be doing exactly. am i doing something wrong here?

EDIT: using node 4.2.1 on mac os x 10.11 with pmx version 0.5.5

"ReferenceError: Alert is not defined"

2015-08-03 11:29:22: App name:did-ui-bundler id:1 online
/data/apps/prod/did-ui-bundler/bin/pm2/node_modules/pmx/lib/utils/alert.js:23
Alert = function(opts) {
      ^
ReferenceError: Alert is not defined
    at Object.<anonymous> (/data/apps/prod/did-ui-bundler/bin/pm2/node_modules/pmx/lib/utils/alert.js:23:7)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/data/apps/prod/did-ui-bundler/bin/pm2/node_modules/pmx/lib/Probe.js:5:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
2015-08-03 11:29:22: App name:did-ui-bundler id:1 exited
2015-08-03 11:29:22: Script /data/apps/prod/did-ui-bundler/index.js had too many unstable restarts (15). Stopped. "errored"

conf.module_conf.password not correct value in module

Within pm2 modules (such as pm2-mysql) it uses conf.module_conf.password which is set to "Password hidden" instead of the actual conf value.

Should these modules being use conf.password or should the hiddent text not be set by pmx?

Versioning module: set a git repo programmatically

Hi, I have deployed an app on Heroku which uses PM2 as a module that programmatically starts my NodeJS app and communicates with keymetrics.io. I would like to enable the Versioning module of keymetrics.io but, as I know, it requires a .git repo in the folder of the app. Is there any way to programmatically specify the git repo to pull of? Thanks

TypeError: Converting circular structure to JSON

Our production app is being restarted frequently because of the following exception from pmx (v0.3.5), so we were forced to disable this module. If you need more information or logs just let me know.

TypeError: Converting circular structure to JSON
    at Object.stringify (native)
    at process.target.send (child_process.js:461:23)
    at ipcSend (/home/sl-node/extractor/node_modules/pmx/lib/utils/transport.js:21:13)
    at Object.Transport.send (/home/sl-node/extractor/node_modules/pmx/lib/utils/transport.js:32:3)
    at errorHandler (/home/sl-node/extractor/node_modules/pmx/lib/notify.js:109:15)
    at Layer.handle_error (/home/sl-node/extractor/node_modules/express/lib/router/layer.js:58:5)
    at trim_prefix (/home/sl-node/extractor/node_modules/express/lib/router/index.js:300:13)
    at /home/sl-node/extractor/node_modules/express/lib/router/index.js:270:7
    at Function.proto.process_params (/home/sl-node/extractor/node_modules/express/lib/router/index.js:321:12)
    at next (/home/sl-node/extractor/node_modules/express/lib/router/index.js:261:10)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1693:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:122:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1588:20)
    at CleartextStream.read [as _read] (tls.js:514:12)
    at CleartextStream.Readable.read (_stream_readable.js:341:10)
    at EncryptedStream.write [as _write] (tls.js:369:25)
    at doWrite (_stream_writable.js:226:10)
    at writeOrBuffer (_stream_writable.js:216:5)
    at EncryptedStream.Writable.write (_stream_writable.js:183:11)
    at write (_stream_readable.js:602:24)
    at flow (_stream_readable.js:611:7)
    at Socket.pipeOnReadable (_stream_readable.js:643:5)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:427:10)
    at emitReadable (_stream_readable.js:423:5)
    at readableAddChunk (_stream_readable.js:166:9)
    at Socket.Readable.push (_stream_readable.js:128:10)
    at TCP.onread (net.js:529:21)

Remote action - restrict access.

Remote actions, are cool. I want to give some of my bosses access to the KeyMetrics page, but i'm uncomfortable with them having access to remote acttions and being able to restart the server. Something they might hit accidentally. I've tried changing them from 'Admin' to 'User' and 'Developer' but it doesn't restrict their access. Is there a way i can restrict access to via a user type, so they can't invoke remote actions or restart the server?

Cannot convert undefined or null to object

When I using it with pm2 I get such error
pm2 1.1.3
node v5.11.1
Is it possible to disable this module?
TypeError: Cannot convert undefined or null to object
at getOwnPropertyNames (native)
at Function.assign (/home/mihail/blue-vending/node_modules/traceur/bin/traceur-runtime.js:163:19)
at process.target.send (internal/child_process.js:518:22)
at ipcSend (/usr/lib/node_modules/pm2/node_modules/pmx/lib/utils/transport.js:22:13)
at Object.Transport.send (/usr/lib/node_modules/pm2/node_modules/pmx/lib/utils/transport.js:33:3)
at Timeout._repeat (/usr/lib/node_modules/pm2/node_modules/pmx/lib/Probe.js:120:17)
at Timeout.wrapper as _onTimeout
at Timer.unrefdHandle (timers.js:445:14)
Process disconnected from parent !

pmx.emit('label', object) modifies object.

I was trying to use pmx.emit to log out customer onboards before they are inserted into my database.
I have json filtering in place so I can insert my req.body directly into the database. I was just doing pmx.emit('customer:creation', req.body), then inserting it into my database. This fails. If I remove pmx.emit from the equation, it succeeds. somehow simply logging the object is modifying the object. Bad mojo.

https://github.com/keymetrics/pmx/blob/master/lib/events.js#L14

This is our offending line of code, it apparently appends an __name as the event name to the object, but why is that necessary? Wouldn't it posit that these objects would be reused later possibly?

Cannot find module socket.io

Our app uses socket.io, which has been installed and is available, however when including pmx (0.3.28), it's reporting 'Error: Cannot find module \'socket.io\'' at the location we're requiring it. Without pmx, everything is fine, it's definitely there. Could be an issue with pmx wrapping and the . in the name?

Error: Cannot find module '<LOCAL MODULE>'

After update from 0.3.9 to 0.3.16 I get an error that my app dependency cannot be found. I solve this problem by require all my modules at the top instead after require('pmx').init();

Error: Cannot find module 'good'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.<anonymous> (E:\Vagrant\Ubuntu1404\webapp\node_modules\pmx\lib\transaction.js:62:21)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at E:\Vagrant\Ubuntu1404\webapp\index.js:93:15
    at E:\Vagrant\Ubuntu1404\webapp\node_modules\glue\lib\index.js:148:9
    at done (E:\Vagrant\Ubuntu1404\webapp\node_modules\glue\node_modules\items\lib\index.js:30:25)
    at done (E:\Vagrant\Ubuntu1404\webapp\node_modules\glue\node_modules\items\lib\index.js:30:25)
    at done (E:\Vagrant\Ubuntu1404\webapp\node_modules\hapi\node_modules\items\lib\index.js:30:25)
    at E:\Vagrant\Ubuntu1404\webapp\api\lib\index.js:165:9
    at E:\Vagrant\Ubuntu1404\webapp\api\lib\db.js:81:5
    at E:\Vagrant\Ubuntu1404\webapp\api\node_modules\mongodb\lib\mongo_client.js:403:11
    at process._tickDomainCallback (node.js:381:11)

Node 0.12 pmx did not self register Errors?

hi all, recently updated from 0.10.39 to 0.12.7 and my apps are constantly restarting or failing. only thing showing in error logs is the following:

Error: Module did not self-register.
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.<anonymous> (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ec2-user/node/qa-app/versions/20150819-101531/app/node_modules/cld/index.js:2:12)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)

any ideas?

ive tried many uninstall / reinstalls and npm rebuilds etc. no luck.

downgrading to 0.10 has no problems, but issue is i am moving to 0.12

Provide production pmx.expressErrorHandler() example

It would be nice to see a production example of the recommended use of pmx.expressErrorHandler().

For example, positioning. Before your own 4-arity functions? After them?

Given that it potentially modifies res.statusCode, I would presume 'after', but I think that a small example here would be very beneficial.

How to call action??

i made axm.action
good operation in the keymetrics.io

So i wish call in my server

axm.emit...????

how to call action and reply

axm.action('test', function(reply) {
console.log('Action test called from external process');
reply({ res : 'hello moto'});
});

Remote actionas allways return {success : true}

I am using pm2 0.14.0 and pmx 0.3.17

Seeing this example :

pmx.action('get:phrases', { comment : 'Return all the phrases' }, function(reply) {
  reply({phrases : phrases});
});

On the console of keymetrics I am inspectionating the response for the remote action and I'm only getting this response :

{ success : true }

Application restart on trivial errors

Since I enabled pmx on my application, to monitor error on keymetrics.io, the app restart on every trivial errors, which force users to login every time. Is there a way to not restart the application automatically on errors?

Smart mode bug

Question from intercom
"I enabled some 'smart' Alert mode for all categories of a linux server. I just received emails telling me an exception had occurred "Probe Zombie processes has reached value null" and "Probe Used memory has reached value null". Are these normal exceptions or bugs in the monitor?"

BUG: pmx lib transaction

dscms-5 (err): at Function.Module._load (module.js:310:12)
dscms-5 (err): at Function. (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
dscms-5 (err): at /usr/lib/node_modules/pm2/lib/ProcessContainer.js:210:23
dscms-5 (err): at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
dscms-5 (err): at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:1166:30
dscms-5 (err): at WriteStream. (/usr/lib/node_modules/pm2/lib/Utility.js:124:13)
dscms-5 (err): /usr/bin/nodejs:1
dscms-5 (err): (function (exports, require, module, __filename, __dirname) { �ELF���
dscms-5 (err): ^
dscms-5 (err): SyntaxError: Unexpected token ILLEGAL
dscms-5 (err): at exports.runInThisContext (vm.js:73:16)
dscms-5 (err): at Module._compile (module.js:443:25)
dscms-5 (err): at Object.Module._extensions..js (module.js:478:10)
dscms-5 (err): at Module.load (module.js:355:32)
dscms-5 (err): at Function.Module._load (module.js:310:12)
dscms-5 (err): at Function. (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
dscms-5 (err): at /usr/lib/node_modules/pm2/lib/ProcessContainer.js:210:23
dscms-5 (err): at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
dscms-5 (err): at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:1166:30
dscms-5 (err): at WriteStream. (/usr/lib/node_modules/pm2/lib/Utility.js:124:13)

error handler no longer reports message/stack

Change 655af14 causes error messages reported to keymetrics to be without stack/message leaving the reported error almost useless (It at least still tells you that something happened). Unless the user is aware of what is going on they may even dismiss a potentially serious issue as a bug in keymetrics reporting, since the message is not obviously an error or fault message, but looks like a log message.

The culprit lies here: https://github.com/keymetrics/pmx/blob/master/lib/notify.js#L111 added back in June.

The new object created, while still having the stack/message props, does not have them on instance itself but on it's prototype.

Later on, getOwnPropertyNames is used here to create yet another new object and the stack/message is lost.

There are several possible fixes to this. The easiest is to get rid of the line added in 655af14, and instead call jsonize first, than add the addition properties (url, component, etc...).

Notify.expressErrorHandler = function() {
  var self = this;

  Options.configureModule({
    error : true
  });

  return function errorHandler(err, req, res, next) {
    if (res.statusCode < 400) res.statusCode = 500;

    err =  jsonize(err);

    //debug(err.stack || err);

    err.url = req.url;
    err.component = req.url;
    err.action = req.method;
    err.params = req.body;
    err.session = req.session;

    Transport.send({
      type  : 'process:exception',
      data  : err
    }, true);
    return next(err);
  };
};

Cannot find module 'pm2'

Tis is my log:

Error: Cannot find module 'pm2'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)

OS: OS X 10.11.5
npm -v : 2.15.1
node -v : 4.4.4
pm2 -v : 1.1.3

pm2 is installed globally with npm install pm2 -g. Instance is up and running with pm2 start script.js, so pm2 is globally visible 100%. Further more I can reach the instance over the localhost, but on this part of the code:

var pm2 = require('pm2');

instance is crashed and log from the above is shown in console. I tried to install pmx as a global module version 0.6.2 and to delete it locally from node_modules in pm2, but error remains.

Any idea what could be wrong?

Support of koa

I gave it a try pmx a try with our koa server but it doesn't seem to show up in the http routes? Is this something that pmx will or should support

Unicode support

Can I emit data with not ascii string?
When I try to emit data with Chinese, the text has converted to .

Alert system enhancement

  • Implement thresold-avg that does exactly what the thresold do but based on an average (+ allow the average interval to be configurable)
  • Implement value configuration via Keymetrics
  • Implement alert thresold and thresold-avg on counter

Add unrefs

Add unref() on setTimeout/setInterval

HTTPS support

This doesn't seem to be monitoring HTTPS routes, any plans to support this or could this be a bug?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.