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.
Join the DZone community and get the full member experience.
Join For Freein 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.
-
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
-
then create a new file in that folder called
deploy_hooks.yml
and add the following:production: first_thing: - snippet: cloud66/newrelic target: any sudo: true execute: true apply_during: all
ifapply_during
is set toall
, this will run on every deployment. set this value tobuild_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 thenewrelic_key
environment variable to be set on a stack. this snippet is open source and can be found here . -
then add this file to the git repository with:
git add deploy_hooks.yml
-
check that is has been added:
git status
-
and then commit to the repository and push:
git commit -m 'deploy hook - initial commit'git push origin master
-
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.
Published at DZone with permission of Andreas Galanomatis, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments