Compute Services

New Relic performance monitoring for Node.js apps

The SDK for Node.js buildpack now contains better integration with the New Relic service in Bluemix.

When an app is bound to an instance of the New Relic service, the buildpack recognizes this based on the VCAP_SERVICES environment variable. It will then set the NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY environment variables, which are recognized by the New Relic agent, for you. If you manually set these environment variables the buildpack will not override them.

Follow the steps below and you’ll be monitoring an app in no time!

Create the app

    1. Change to an empty directory and copy the following code into a file named package.json. This adds a dependency on the New Relic agent’s npm module.
          "name": "myapp",
          "version": "0.0.1",
          "private": true,
          "scripts": {
              "start": "node app.js"
          "dependencies": {
              "express": "4.13.x",
              "cfenv": "1.0.x",
              <b>"newrelic": "1.30.3"</b>
          "engines": {
              "node": "4.x"


    1. Then copy the following code into a file named app.json. This is a simple Express-based app. Notice how the first thing we do is load the newrelic module.
      var express = require('express');
      var cfenv = require('cfenv');
      var app = express();
      var appEnv = cfenv.getAppEnv();
      app.get('/', function (req, res) {
        res.send('Hello World');
      app.listen(appEnv.port, '', function() {
        console.log("server starting on " + appEnv.url);


  1. Optionally use environment variables or a newrelic.js file in the root of the application to change the default agent configuration options.
    exports.config = {
      logging: {
        level: 'trace',
        filepath: 'stdout'


    See config.default.js for all the configuration options.

  2. Finally, push your app to Bluemix.
    $ cf push &lt;app name&gt;
    $ cf create-service newrelic standard &lt;service instance name&gt;
    $ cf bind-service &lt;app name&gt; &lt;service instance name&gt;
    $ cf restage &lt;app name&gt;

Monitor the app

Wait a few minutes after your app starts for the data it generates to be reported, then open the New Relic Dashboard from within the Bluemix UI. From here you will automatically be logged in to the New Relic UI.

In the New Relic UI click on your application and you will be able to see your metrics like the web transaction time.


For a good summary of what the different metrics are see A Quick Guide to Getting Started with New Relic.

Share this post:

Share on LinkedIn

Add Comment
No Comments

Leave a Reply

Your email address will not be published.Required fields are marked *

More Compute Services Stories

Build a smarter supply chain with LoopBack

Bluemix dev advocates are working on a project called Logistics Wizard. It is an end-to-end, smart supply chain management solution that showcases how to execute hybrid cloud, microservices, and predictive data analytics. This post presents the ERP service component, which provides access to the ERP system data, and explains how LoopBack was used to implement this API.

Understanding and using Docker actions in IBM Bluemix OpenWhisk

The latest Apache OpenWhisk offering on IBM Bluemix has several new enhancements. We'll show you how to use them.

Announcing Liberty buildpack & WAS V9

Liberty buildpack v3.0 with the latest version of WebSphere Liberty is now deployed in Bluemix. It will be part of next week’s WebSphere Application Server V9 release and is now deployed in Bluemix. This makes the Liberty v9 runtime available in Bluemix first and a week ahead of the official release date!