djoos-cookbooks / newrelic

Development repository for the newrelic cookbook
https://supermarket.chef.io/cookbooks/newrelic
MIT License
143 stars 247 forks source link

Build Status

newrelic cookbook

Description

This cookbook provides an easy way to install various New Relic application monitoring agents and the New Relic Infrastructure agent.

The agent installs are being converted into libraries, currently the following agents are now resources:

More information?

Requirements

Chef version:

Make sure you run Chef >= 12.1

Cookbooks:

Platforms:

Attributes

default.rb:

BASIC

ADVANCED

repository.rb:

python_agent.rb:

dotnet_agent.rb:

java_agent.rb:

nodejs_agent.rb

e.g.

[
   { 'app_name' => 'My Application', 'app_path' => "/path/to/app/root" }
]

You then need to modify your application "main" file to add the following on the first line:

javascript
require('newrelic');

ruby_agent.rb:

MeetMe plugin

To make sure the cookbook is focussed on getting New Relic server and application monitoring, no plugin logic is provided here. The New Relic MeetMe plugin-logic is still available, in a separate cookbook: newrelic_meetme_plugin.

Resources / Providers

newrelic_server_monitor

This cookbook includes an LWRP for installing the server monitor agent

The newrelic_server_monitor resource will handle the requirements to configure server monitoring.

Actions

Attribute parameters

Advanced parameters

Example

newrelic_server_monitor 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
end

newrelic_agent_php

This cookbook includes an LWRP for installing the php agent

The newrelic_agent_php resource will handle the requirements to install php application monitoring.

Actions

Attribute parameters

Advanced parameters

Example

newrelic_agent_php 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
  app_name 'php_test_app'
  service_name 'httpd'
  config_file '/etc/php.d/newrelic.ini'
end

newrelic_agent_ruby

This cookbook includes an LWRP for installing the ruby agent

The newrelic_agent_ruby resource will handle the requirements to install ruby application monitoring.

Actions

Attribute parameters

Advanced parameters

Example

newrelic_agent_ruby 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
  app_name 'ruby_test_app'
end

newrelic_agent_java

This cookbook includes an LWRP for installing the java agent

The newrelic_agent_java resource will handle the requirements to install java application monitoring.

Actions

Attribute parameters

Advanced parameters

Example

newrelic_agent_java 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
  install_dir '/opt/newrelic/java'
  app_name 'java_test_app'

newrelic_agent_python

This cookbook includes an LWRP for installing the newrelic python agent

The newrelic_agent_python resource will handle the requirements to install python application monitoring.

Actions

Attribute parameters

See https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-configuration#general-settings for an explanation on each attribute.

Advanced parameters

Example

include_recipe 'python'

newrelic_agent_python 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
  app_name 'my_python_app'
end

newrelic_agent_nodejs

This cookbook includes an LWRP for installing the newrelic nodejs agent The newrelic_agent_nodejs resource will handle the requirements to install nodejs application monitoring.

Actions

Attribute parameters

https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration for an explanation on each attribute.

Advanced parameters

Example

newrelic_agent_nodejs '/var/my_node_approot' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
  app_name 'my_nodejs_app'
end

newrelic_agent_dotnet

This cookbook includes an LWRP for installing the dotnet agent

The newrelic_agent_dotnet resource will handle the requirements to install .Net application monitoring.

Actions

Attribute parameters

Example

newrelic_agent_dotnet 'Install' do
  license '0000ffff0000ffff0000ffff0000ffff0000ffff'
end

newrelic_agent_infrastructure

This cookbook includes an LWRP for installing the infrastructure agent

The newrelic_agent_infrastructure resource will handle the requirements to set up the infrastructure agent.

Actions

Attribute parameters

newrelic_deployment

This cookbook includes an LWRP for notifying New Relic of a deployment

Actions

Attribute parameters

Example(s)

newrelic_deployment "my-application" do
    key_type "license_key"
    key "yourlicensekey"
    app_id 1234567
    description "some description"
    revision "some revision"
    changelog "some changelog"
    user "chef-client"
    action :notify
end

This cookbook includes an LWRP for generating the newrelic.yml configuration file in a specific path, which can be used to generate multiple configurations when deploying multiple different applications

newrelic_yml

Actions

Example usage - Java agent

  1. Install the Java Agent: add the newrelic::java_agent recipe to your run list. A newrelic.yml will be generated but not linked to anything.
  2. In your application cookbook, generate the newrelic.yml for this application:
yml_path = "#{my_app_path}/newrelic.yml"
newrelic_yml yml_path do
  app_name 'my-super-duper-application'
  agent_type 'java'
end
  1. Configure your app for newrelic using your config file and newrelic.jar:
 java -Dnewrelic.config.file=#{newrelicyml}  -javaagent:#{node['newrelic']['install_dir']}/newrelic.jar [rest of your args]

Usage

  1. include recipe[newrelic] in a run list to implicly run recipe[newrelic::server_monitor_agent] --- OR --- include the bits and pieces explicitly in a run list:
    `recipe[newrelic::repository]`
    `recipe[newrelic::server_monitor_agent]`
    `recipe[newrelic::dotnet_agent]`
    `recipe[newrelic::java_agent]`
    `recipe[newrelic::nodejs_agent]`
    `recipe[newrelic::php_agent]`
    `recipe[newrelic::python_agent]`
    `recipe[newrelic::ruby_agent]`
    `recipe[newrelic::infrastructure_agent]`
  2. change the node['newrelic']['license'] attribute to your New Relic license keys --- OR --- override the attributes on a higher level

References

License and Authors

Author: David Joos development@davidjoos.com Copyright: 2016, David Joos

Author: David Joos david.joos@escapestudios.com Author: Escape Studios Development dev@escapestudios.com Copyright: 2012-2015, Escape Studios

Unless otherwise noted, all files are released under the MIT license, possible exceptions will contain licensing information in them.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.