SlideShare a Scribd company logo
Performance Tuning 
Your (Puppet) 
Infrastructure 
Nic Benders 
OWNING 
http://nicbenders.com/presentations/puppetconf-2014
I work at New Relic. 
! 
This is a story about treating 
your infrastructure the same 
way you treat your applications. 
! 
This is also a story about how 
we use New Relic, 
at New Relic. 
http://nicbenders.com/presentations/puppetconf-2014
Managing Our Applications 
• Source Control 
• Continuous Deployment 
• Performance Monitoring 
• Operational Analytics 
• Log Collection 
GitHub with Pull Requests 
Jenkins + Capistrano 
New Relic APM 
New Relic Insights 
Heka + ElasticSearch + Kibana
Managing Our Infrastructure 
• Source Control 
• Continuous Deployment 
• Performance Monitoring 
• Operational Analytics 
• Log Collection 
GitHub with Pull Requests 
Jenkins + Capistrano 
New Relic APM 
New Relic Insights 
Heka + ElasticSearch + Kibana
Source Control
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Continuous 
Deployment
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance 
Monitoring
DON’T PANIC 
• These example are for Puppet Enterprise 3.1, but this will work with Puppet 
Open Source, or with newer versions. You’ll just need to make a few changes 
here and there. 
• If you don’t have a New Relic account, you can sign-up for a free “Lite” account. 
• All of the examples are up in a more useful format at the URL below. 
(The URL will also be shown at the end of the presentation.) 
http://nicbenders.com/presentations/puppetconf-2014
Instrumenting the 
Puppet Master 
• Install newrelic_rpm using the 
Puppet’s Ruby interpreter 
• Modify the config.ru in the Puppet 
Master root dir 
• Create a newrelic.yml in the same 
directory 
# 
/var/opt/lib/pe-­‐puppetmaster/config.ru 
! 
# 
Setup 
the 
New 
Relic 
Ruby 
Agent 
before 
anything 
else 
require 
'rubygems' 
require 
'newrelic_rpm' 
# 
END 
New 
Relic 
Ruby 
Agent 
setup 
# 
/var/opt/lib/pe-­‐puppetmaster/newrelic.yml 
! 
common: 
&default_settings 
license_key: 
'000-­‐your-­‐license-­‐key-­‐here-­‐000' 
app_name: 
"Puppet 
Master" 
log_level: 
info 
log_file_path: 
'/var/log/pe-­‐puppet/' 
ssl: 
false 
capture_params: 
true 
transaction_tracer: 
enabled: 
true 
error_collector: 
enabled: 
true 
ignore_errors: 
"ActionController::RoutingError" 
production: 
<<: 
*default_settings 
monitor_mode: 
true
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Getting good 
transaction names 
• Use set_transaction_name in a 
Rack Middleware to tell the Ruby 
Agent how we are going to name 
the “web transactions” for the 
Puppet Master 
• Use add_custom_parameters to 
pass the environment and other 
useful data along 
# 
# 
We 
don't 
want 
every 
transaction 
to 
just 
say 
"call", 
so 
define 
a 
# 
Transaction 
"namer" 
for 
the 
Ruby 
Agent 
based 
on 
the 
URL 
structure 
# 
class 
CoolNamer 
def 
initialize(app, 
opts 
= 
{}) 
@app 
= 
app 
end 
def 
call(env) 
req 
= 
Rack::Request.new(env) 
_, 
environment, 
kind_of_thing, 
resource 
= 
req.path.split('/',4) 
NewRelic::Agent.set_transaction_name(kind_of_thing, 
:category 
=> 
:rack) 
NewRelic::Agent.add_custom_parameters(:puppet_env 
=> 
environment) 
NewRelic::Agent.add_custom_parameters(:puppet_resource 
=> 
resource) 
@app.call(env) 
end 
end 
use 
CoolNamer 
# 
END 
Transaction 
"namer"
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Getting more detail 
• The Ruby Agent’s MethodTracer 
allows us to get details of what is 
going on inside a Transaction. 
• By hooking into Puppet’s built-in 
Profiler calls, we can quickly 
instrument all the most important 
things. 
• This example is for Puppet 3.3.1. In 
newer versions it is much easier. 
require 
"puppet/util/profiler" 
module 
Puppet::Util::Profiler 
include 
::NewRelic::Agent::MethodTracer 
self.profile(message, 
&block) 
if 
/^Processed 
request 
def 
/ 
=== 
message 
# 
Top 
level 
trace, 
skip 
for 
now 
yield 
else 
metric_name 
= 
self.message_to_metric(message) 
trace_execution_scoped([metric_name]) 
do 
yield 
end 
end 
end 
def 
self.message_to_metric(message) 
message.chomp! 
message.gsub!(/^(Compiled 
catalog) 
for 
.*/, 
'1') 
message.gsub!(/^(Filtered 
result 
for 
catalog) 
.*/, 
'1') 
message.gsub!(/(d+) 
/, 
'') 
message.gsub!(/^(Evaluated 
resource) 
/, 
'1/') 
message.gsub!(/[.*]/,'') 
message.gsub!(/:s/,'/') 
message.gsub!(/^(Called) 
/, 
'1/') 
"Custom/Puppet/#{message}" 
end 
end
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Instrumenting the 
Puppet DB 
• Download the Java Agent from 
your “Account Settings” page. 
• Create an /opt/puppet/newrelic 
dir and place the newrelic.jar and 
newrelic.yaml file into it. 
• Modify the newrelic.yaml 
• Modify JAVA_ARGS 
# 
/etc/syslog/pe-­‐puppetdb 
! 
# 
Enable 
the 
New 
Relic 
Java 
Agent 
by 
adding 
this 
# 
to 
the 
bottom 
of 
the 
file 
JAVA_ARGS="-­‐javaagent:/opt/puppet/newrelic/newrelic.jar 
${JAVA_ARGS}" 
# 
/opt/puppet/newrelic/newrelic.yml 
! 
common: 
&default_settings 
license_key: 
'000-­‐your-­‐license-­‐key-­‐here-­‐000' 
! 
app_name: 
'Puppet 
DB' 
log_level: 
info 
log_file_path: 
/var/log/pe-­‐puppetdb/ 
ssl: 
false 
transaction_tracer: 
enabled: 
true 
transaction_threshold: 
apdex_f 
record_sql: 
obfuscated 
stack_trace_threshold: 
0.2 
explain_enabled: 
true 
explain_threshold: 
0.2 
browser_monitoring: 
auto_instrument: 
false 
production: 
<<: 
*default_settings
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Operational Analytics
Log Collection
Puppet Agent already goes into Syslog 
• Agent syslogs have a ton of useful 
information. We just need to get it 
to a useful place. 
• Our application and syslog data is 
collected by a Heka process on 
each server. It then makes its way 
to ElasticSearch, where it can be 
queried by Kibana.
Send run reports to the same place 
• Add your log system as a 
Report processor! 
• We use https://github.com/ 
logstash/puppet-logstash-reporter 
• To get the data into Heka, we had 
to write some Lua, but it was 
pretty straightforward.
pe_puppet::master::config_hash: 
reports: 
'http,puppetdb,logstash' 
! 
logstash_reporter::logstash_host: 
'our-­‐heka-­‐server' 
# 
Logstash-­‐style 
report 
processer 
through 
Heka 
class 
{ 
'logstash_reporter': 
logstash_port 
=> 
'22253', 
logstash_host 
=> 
hiera('logstash_reporter::logstash_host'), 
}
Managing Our Infrastructure 
• Source Control 
• Continuous Deployment 
• Performance Monitoring 
• Operational Analytics 
• Log Collection 
GitHub with Pull Requests 
Jenkins + Capistrano 
New Relic APM 
New Relic Insights 
Heka + ElasticSearch + Kibana
We’re Hiring 
Site Reliability Engineers 
MySQL Experts 
Engineering Managers 
Data Pipeline Engineers 
newrelic.com/about/careers
http://nicbenders.com/presentations/puppetconf-2014 
nic@newrelic.com

More Related Content

PPTX
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet
 
PDF
The Puppet Master on the JVM - PuppetConf 2014
Puppet
 
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Puppet
 
PDF
SaltConf14 - Anita Kuno, HP & OpenStack - Using SaltStack for event-driven or...
SaltStack
 
PDF
Test Driven Development with Puppet - PuppetConf 2014
Puppet
 
PDF
Experiences from Running Masterless Puppet - PuppetConf 2014
Puppet
 
PDF
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Puppet
 
PPTX
Integration testing for salt states using aws ec2 container service
SaltStack
 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet
 
The Puppet Master on the JVM - PuppetConf 2014
Puppet
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Puppet
 
SaltConf14 - Anita Kuno, HP & OpenStack - Using SaltStack for event-driven or...
SaltStack
 
Test Driven Development with Puppet - PuppetConf 2014
Puppet
 
Experiences from Running Masterless Puppet - PuppetConf 2014
Puppet
 
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Puppet
 
Integration testing for salt states using aws ec2 container service
SaltStack
 

What's hot (20)

PDF
OpenNebula and SaltStack - OpenNebulaConf 2013
databus.pro
 
PDF
Puppet Performance Profiling
ripienaar
 
PDF
Intelligent infrastructure with SaltStack
Love Nyberg
 
PDF
Tp install anything
Alessandro Franceschi
 
PPTX
Deployment with capistrano
sagar junnarkar
 
PDF
Salt conf 2014 - Using SaltStack in high availability environments
Benjamin Cane
 
PPT
Capistrano
Jason Noble
 
PDF
A user's perspective on SaltStack and other configuration management tools
SaltStack
 
PDF
Cookbook testing with KitcenCI and Serverrspec
Daniel Paulus
 
PPT
Capistrano - Deployment Tool
Nyros Technologies
 
KEY
Background Jobs with Resque
homanj
 
PPTX
Capistrano - automate all the things
John Cleary
 
PDF
Designing net-aws-glacier
Workhorse Computing
 
KEY
Php resque
Chaitanya Kuber
 
PDF
Background processing with Resque
Nicolas Blanco
 
PDF
Real-time Infrastructure Management with SaltStack - OpenWest 2013
SaltStack
 
PDF
The SaltStack Pub Crawl - Fosscomm 2016
effie mouzeli
 
PPTX
Getting Started with Capistrano
LaunchAny
 
PDF
Spot Trading - A case study in continuous delivery for mission critical finan...
SaltStack
 
PDF
Managing Puppet using MCollective
Puppet
 
OpenNebula and SaltStack - OpenNebulaConf 2013
databus.pro
 
Puppet Performance Profiling
ripienaar
 
Intelligent infrastructure with SaltStack
Love Nyberg
 
Tp install anything
Alessandro Franceschi
 
Deployment with capistrano
sagar junnarkar
 
Salt conf 2014 - Using SaltStack in high availability environments
Benjamin Cane
 
Capistrano
Jason Noble
 
A user's perspective on SaltStack and other configuration management tools
SaltStack
 
Cookbook testing with KitcenCI and Serverrspec
Daniel Paulus
 
Capistrano - Deployment Tool
Nyros Technologies
 
Background Jobs with Resque
homanj
 
Capistrano - automate all the things
John Cleary
 
Designing net-aws-glacier
Workhorse Computing
 
Php resque
Chaitanya Kuber
 
Background processing with Resque
Nicolas Blanco
 
Real-time Infrastructure Management with SaltStack - OpenWest 2013
SaltStack
 
The SaltStack Pub Crawl - Fosscomm 2016
effie mouzeli
 
Getting Started with Capistrano
LaunchAny
 
Spot Trading - A case study in continuous delivery for mission critical finan...
SaltStack
 
Managing Puppet using MCollective
Puppet
 
Ad

Viewers also liked (7)

PDF
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Puppet
 
PDF
To the Future! - Goals for Puppet 4 - PuppetConf 2014
Puppet
 
PDF
Puppet Language 4.0 - PuppetConf 2014
Puppet
 
PDF
Killer R10K Workflow - PuppetConf 2014
Puppet
 
PDF
Puppet at GitHub - PuppetConf 2013
Puppet
 
PPTX
MAPEH (ARTS) Grade 8-NARRA, Wayang Kulit
Angelica Rose Manzano
 
PDF
Grade 8 Music and Arts Module
Andrew Cabugason
 
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Puppet
 
To the Future! - Goals for Puppet 4 - PuppetConf 2014
Puppet
 
Puppet Language 4.0 - PuppetConf 2014
Puppet
 
Killer R10K Workflow - PuppetConf 2014
Puppet
 
Puppet at GitHub - PuppetConf 2013
Puppet
 
MAPEH (ARTS) Grade 8-NARRA, Wayang Kulit
Angelica Rose Manzano
 
Grade 8 Music and Arts Module
Andrew Cabugason
 
Ad

Similar to Performance Tuning Your Puppet Infrastructure - PuppetConf 2014 (20)

PDF
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
Puppet
 
PDF
SCM Puppet: from an intro to the scaling
Stanislav Osipov
 
PDF
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
Puppet
 
PPTX
Puppetizing Your Organization
Robert Nelson
 
ODP
Puppet slides for intelligrape
Sharad Aggarwal
 
PDF
Creating a mature puppet system
rkhatibi
 
PDF
Creating a Mature Puppet System
Puppet
 
PDF
State of Puppet London
Puppet
 
PDF
State of Puppet - London
Puppet
 
PDF
Our Puppet Story (GUUG FFG 2015)
DECK36
 
PDF
Puppet Camp Berlin 2015: Nigel Kersten | Puppet Keynote
NETWAYS
 
PDF
Puppet Camp Berlin 2015: Puppet Keynote
Puppet
 
PDF
One-Man Ops
Jos Boumans
 
PPTX
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Nicolas Brousse
 
PDF
Using Puppet - Real World Configuration Management
James Turnbull
 
PPT
Rapid scaling in_the_cloud_with_puppet
Carl Caum
 
PDF
Puppet getting started by Dirk Götz
NETWAYS
 
PDF
Islands: Puppet at Bulletproof Networks
Lindsay Holmwood
 
PPTX
Managing and Scaling Puppet - PuppetConf 2014
Puppet
 
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
Puppet
 
SCM Puppet: from an intro to the scaling
Stanislav Osipov
 
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
Puppet
 
Puppetizing Your Organization
Robert Nelson
 
Puppet slides for intelligrape
Sharad Aggarwal
 
Creating a mature puppet system
rkhatibi
 
Creating a Mature Puppet System
Puppet
 
State of Puppet London
Puppet
 
State of Puppet - London
Puppet
 
Our Puppet Story (GUUG FFG 2015)
DECK36
 
Puppet Camp Berlin 2015: Nigel Kersten | Puppet Keynote
NETWAYS
 
Puppet Camp Berlin 2015: Puppet Keynote
Puppet
 
One-Man Ops
Jos Boumans
 
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Nicolas Brousse
 
Using Puppet - Real World Configuration Management
James Turnbull
 
Rapid scaling in_the_cloud_with_puppet
Carl Caum
 
Puppet getting started by Dirk Götz
NETWAYS
 
Islands: Puppet at Bulletproof Networks
Lindsay Holmwood
 
Managing and Scaling Puppet - PuppetConf 2014
Puppet
 

More from Puppet (20)

PPTX
Puppet Community Day: Planning the Future Together
Puppet
 
PPTX
The Evolution of Puppet: Key Changes and Modernization Tips
Puppet
 
PPTX
Can You Help Me Upgrade to Puppet 8? Tips, Tools & Best Practices for Your Up...
Puppet
 
PPTX
Bolt Dynamic Inventory: Making Puppet Easier
Puppet
 
PPTX
Customizing Reporting with the Puppet Report Processor
Puppet
 
PPTX
Puppet at ConfigMgmtCamp 2025 Sponsor Deck
Puppet
 
PPTX
The State of Puppet in 2025: A Presentation from Developer Relations Lead Dav...
Puppet
 
PPTX
Let Red be Red and Green be Green: The Automated Workflow Restarter in GitHub...
Puppet
 
PDF
Puppet camp2021 testing modules and controlrepo
Puppet
 
PPTX
Puppetcamp r10kyaml
Puppet
 
PDF
2021 04-15 operational verification (with notes)
Puppet
 
PPTX
Puppet camp vscode
Puppet
 
PDF
Modules of the twenties
Puppet
 
PDF
Applying Roles and Profiles method to compliance code
Puppet
 
PPTX
KGI compliance as-code approach
Puppet
 
PDF
Enforce compliance policy with model-driven automation
Puppet
 
PDF
Keynote: Puppet camp compliance
Puppet
 
PPTX
Automating it management with Puppet + ServiceNow
Puppet
 
PPTX
Puppet: The best way to harden Windows
Puppet
 
PPTX
Simplified Patch Management with Puppet - Oct. 2020
Puppet
 
Puppet Community Day: Planning the Future Together
Puppet
 
The Evolution of Puppet: Key Changes and Modernization Tips
Puppet
 
Can You Help Me Upgrade to Puppet 8? Tips, Tools & Best Practices for Your Up...
Puppet
 
Bolt Dynamic Inventory: Making Puppet Easier
Puppet
 
Customizing Reporting with the Puppet Report Processor
Puppet
 
Puppet at ConfigMgmtCamp 2025 Sponsor Deck
Puppet
 
The State of Puppet in 2025: A Presentation from Developer Relations Lead Dav...
Puppet
 
Let Red be Red and Green be Green: The Automated Workflow Restarter in GitHub...
Puppet
 
Puppet camp2021 testing modules and controlrepo
Puppet
 
Puppetcamp r10kyaml
Puppet
 
2021 04-15 operational verification (with notes)
Puppet
 
Puppet camp vscode
Puppet
 
Modules of the twenties
Puppet
 
Applying Roles and Profiles method to compliance code
Puppet
 
KGI compliance as-code approach
Puppet
 
Enforce compliance policy with model-driven automation
Puppet
 
Keynote: Puppet camp compliance
Puppet
 
Automating it management with Puppet + ServiceNow
Puppet
 
Puppet: The best way to harden Windows
Puppet
 
Simplified Patch Management with Puppet - Oct. 2020
Puppet
 

Recently uploaded (20)

PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Software Development Methodologies in 2025
KodekX
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
The Future of Artificial Intelligence (AI)
Mukul
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 

Performance Tuning Your Puppet Infrastructure - PuppetConf 2014

  • 1. Performance Tuning Your (Puppet) Infrastructure Nic Benders OWNING http://nicbenders.com/presentations/puppetconf-2014
  • 2. I work at New Relic. ! This is a story about treating your infrastructure the same way you treat your applications. ! This is also a story about how we use New Relic, at New Relic. http://nicbenders.com/presentations/puppetconf-2014
  • 3. Managing Our Applications • Source Control • Continuous Deployment • Performance Monitoring • Operational Analytics • Log Collection GitHub with Pull Requests Jenkins + Capistrano New Relic APM New Relic Insights Heka + ElasticSearch + Kibana
  • 4. Managing Our Infrastructure • Source Control • Continuous Deployment • Performance Monitoring • Operational Analytics • Log Collection GitHub with Pull Requests Jenkins + Capistrano New Relic APM New Relic Insights Heka + ElasticSearch + Kibana
  • 10. DON’T PANIC • These example are for Puppet Enterprise 3.1, but this will work with Puppet Open Source, or with newer versions. You’ll just need to make a few changes here and there. • If you don’t have a New Relic account, you can sign-up for a free “Lite” account. • All of the examples are up in a more useful format at the URL below. (The URL will also be shown at the end of the presentation.) http://nicbenders.com/presentations/puppetconf-2014
  • 11. Instrumenting the Puppet Master • Install newrelic_rpm using the Puppet’s Ruby interpreter • Modify the config.ru in the Puppet Master root dir • Create a newrelic.yml in the same directory # /var/opt/lib/pe-­‐puppetmaster/config.ru ! # Setup the New Relic Ruby Agent before anything else require 'rubygems' require 'newrelic_rpm' # END New Relic Ruby Agent setup # /var/opt/lib/pe-­‐puppetmaster/newrelic.yml ! common: &default_settings license_key: '000-­‐your-­‐license-­‐key-­‐here-­‐000' app_name: "Puppet Master" log_level: info log_file_path: '/var/log/pe-­‐puppet/' ssl: false capture_params: true transaction_tracer: enabled: true error_collector: enabled: true ignore_errors: "ActionController::RoutingError" production: <<: *default_settings monitor_mode: true
  • 13. Getting good transaction names • Use set_transaction_name in a Rack Middleware to tell the Ruby Agent how we are going to name the “web transactions” for the Puppet Master • Use add_custom_parameters to pass the environment and other useful data along # # We don't want every transaction to just say "call", so define a # Transaction "namer" for the Ruby Agent based on the URL structure # class CoolNamer def initialize(app, opts = {}) @app = app end def call(env) req = Rack::Request.new(env) _, environment, kind_of_thing, resource = req.path.split('/',4) NewRelic::Agent.set_transaction_name(kind_of_thing, :category => :rack) NewRelic::Agent.add_custom_parameters(:puppet_env => environment) NewRelic::Agent.add_custom_parameters(:puppet_resource => resource) @app.call(env) end end use CoolNamer # END Transaction "namer"
  • 15. Getting more detail • The Ruby Agent’s MethodTracer allows us to get details of what is going on inside a Transaction. • By hooking into Puppet’s built-in Profiler calls, we can quickly instrument all the most important things. • This example is for Puppet 3.3.1. In newer versions it is much easier. require "puppet/util/profiler" module Puppet::Util::Profiler include ::NewRelic::Agent::MethodTracer self.profile(message, &block) if /^Processed request def / === message # Top level trace, skip for now yield else metric_name = self.message_to_metric(message) trace_execution_scoped([metric_name]) do yield end end end def self.message_to_metric(message) message.chomp! message.gsub!(/^(Compiled catalog) for .*/, '1') message.gsub!(/^(Filtered result for catalog) .*/, '1') message.gsub!(/(d+) /, '') message.gsub!(/^(Evaluated resource) /, '1/') message.gsub!(/[.*]/,'') message.gsub!(/:s/,'/') message.gsub!(/^(Called) /, '1/') "Custom/Puppet/#{message}" end end
  • 17. Instrumenting the Puppet DB • Download the Java Agent from your “Account Settings” page. • Create an /opt/puppet/newrelic dir and place the newrelic.jar and newrelic.yaml file into it. • Modify the newrelic.yaml • Modify JAVA_ARGS # /etc/syslog/pe-­‐puppetdb ! # Enable the New Relic Java Agent by adding this # to the bottom of the file JAVA_ARGS="-­‐javaagent:/opt/puppet/newrelic/newrelic.jar ${JAVA_ARGS}" # /opt/puppet/newrelic/newrelic.yml ! common: &default_settings license_key: '000-­‐your-­‐license-­‐key-­‐here-­‐000' ! app_name: 'Puppet DB' log_level: info log_file_path: /var/log/pe-­‐puppetdb/ ssl: false transaction_tracer: enabled: true transaction_threshold: apdex_f record_sql: obfuscated stack_trace_threshold: 0.2 explain_enabled: true explain_threshold: 0.2 browser_monitoring: auto_instrument: false production: <<: *default_settings
  • 23. Puppet Agent already goes into Syslog • Agent syslogs have a ton of useful information. We just need to get it to a useful place. • Our application and syslog data is collected by a Heka process on each server. It then makes its way to ElasticSearch, where it can be queried by Kibana.
  • 24. Send run reports to the same place • Add your log system as a Report processor! • We use https://github.com/ logstash/puppet-logstash-reporter • To get the data into Heka, we had to write some Lua, but it was pretty straightforward.
  • 25. pe_puppet::master::config_hash: reports: 'http,puppetdb,logstash' ! logstash_reporter::logstash_host: 'our-­‐heka-­‐server' # Logstash-­‐style report processer through Heka class { 'logstash_reporter': logstash_port => '22253', logstash_host => hiera('logstash_reporter::logstash_host'), }
  • 26. Managing Our Infrastructure • Source Control • Continuous Deployment • Performance Monitoring • Operational Analytics • Log Collection GitHub with Pull Requests Jenkins + Capistrano New Relic APM New Relic Insights Heka + ElasticSearch + Kibana
  • 27. We’re Hiring Site Reliability Engineers MySQL Experts Engineering Managers Data Pipeline Engineers newrelic.com/about/careers