Over a million developers have joined DZone.

How to Install NewRelic on Docker Stacks

NewRelic is server performance monitoring that can track microservice performance. This tutorial shows you how to integrate monitoring via deploy hooks in a Docker stack.

Download Forrester’s “Vendor Landscape, Application Performance Management” report that examines the evolving role of APM as a key driver of customer satisfaction and business success, brought to you in partnership with BMC.

In this post, I'll be walking you through the steps needed to install NewRelic on your Docker stack using deploy hooks.

For any of you unfamiliar with NewRelic, they're a San Francisco based analytics software company, which helps you monitor your web server or mobile app's performance. They've got some pretty cool kits that do everything from monitoring critical transactions, to identifying performance bottlenecks across your microservices.

This guide will help you install the tools for monitoring your server. It's worth mentioning that to add monitoring to your application, you will need to apply some additional configuration, which is not covered in the scope of this post.

So to get started, first you'll need to create a new Docker stack, provide the relevant git information or the Docker image, and any databases your application might need. Once you go to the next step, your custom git repository will be created and on the side bar on the right you should see:

Since Docker stacks don't have a git repository by default, we create one for you to use for your deploy hooks amongst another things.

This of course applies to existing stacks as well. You can find your repository in Settings & Information > Information > CustomConfig git.

  1. The first thing to do is to clone this repository on your machine:git clone git@git1.cloud66.com:your_git_name_and_id.git
  2. Then create a new file in that folder called deploy_hooks.yml and add the following:
     - snippet: cloud66/newrelic
     target: any
     sudo: true
     execute: true
     apply_during: all

    If apply_during is set to all, this will run on every deployment. Set this value to build_only if you only want to run during the stack build process. The deploy hook will run the following code snippet to automate the installation of NewRelic, and requires the NEWRELIC_KEY environment variable to be set on a stack. This snippet is open source and can be found here.
  3. Then add this file to the git repository with:git add deploy_hooks.yml
  4. Check that is has been added:git status
  5. And then commit to the repository and push:git commit -m 'Deploy hook - initial commit'git push origin master
  6. Back on the Cloud 66 stack creation page, click on the: Add environment variables button on the right, to add a new one called NEWRELIC_KEY with your key from NewRelic.When you now deploy your stack, the snippet will be the first thing that will run on the server and will install everything that's needed.

See Forrester’s Report, “Vendor Landscape, Application Performance Management” to identify the right vendor to help IT deliver better service at a lower cost, brought to you in partnership with BMC.


Published at DZone with permission of Andreas Galanomatis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}