Getting Started with Keymetrics and PM2. Part 2
by Alexandre Strzelewicz -


This tutorial is the second part.
If you didn't read the first part, take a look at this one :

As we did in the previous article for linking and creating a communication between PM2 and Keymetrics, go back to your dashboard.

How to setup Keymetrics


If you followed all steps in the first tutorial, your dashboard should look like this :

As you can see, multiples actions on the application are availables. Thoses actions are represented by a blue button.

I invit you to going through the app.js in the app-playground directory for understand how custom actions are set up.

Using pmx

It's easily and simple to configure and create interaction with Keymetrics.
In our example, pmx module is already installed.
Further informations are available here :

Decrement and increment

You can add a counter like in this example.
the "decrement" button will decreased by 1 the value of "Downloads" while other one doing the oposite (+1).

Throw error

By clicking on the "throw error" button, An error will be generated as you can see here :

Get env

The outcome of this one will be an object containing the user environment displayed in the feedback column.

Modules version

As we did in the previous button, this one will display also an object containing this time a version of node and its dependencies.

http request

If you press the "do:http:query", pmx will create an action that hit the HTTP server. So we can see how the meter probe behaves.

Versionning and process

Some actions are also availables for git and pm2. Wrong version ? Well, it's possible to Rollback, Pull and Upgrade your git version.

You can also perform action on your application like the restart.

That's all for the dashboard, let's moving to another page.

Servers Signs

All informations relating to your server can be found here.
You can also delete your server by clicking on the top right.

Apps Signs

This section is an important feature because it's show you how much ressources (CPU, MEM) are consumes by your applications. If you use a Free Plan, CPU and MEM graphics only are available.

Activating Premium Plan will unlock probe graphic feature.


All your errors or exceptions will be caught in this section.
When a problem is fixed, just click on the button "Set as fixed".
Supposing you want more informations, you can "Inspect" through errors.
Otherwise, delete all exceptions.

Slow routes

For this example, we will updated our code.
We need to add some parts into the app.js.

First step, install express with this command.

$ npm install express

Once, express installed, add this line at the top of your app.js like here.

var pmx = require('pmx').init();  
var express = require('express');  
var app = express();  

The variable pmx already exists, it's just for show you the order used.

Adding a route with this code.

app.get('/test-route', function(req, res) {  
    var count = 0

    setTimeout( function () {
    }, 300);


Now, if your application is not --watch restart it.

$ pm2 restart app

Finally, use curl for transfering data to the new route we created.

$ curl localhost:3000/test-route
$ test-route%

The route /test-route has been build into the slow routes page (Refresh the page).

Check out the Keymetrics documentation to discover the other features!