Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Infrastructure as Code & Monitoring
Search
portertech
September 16, 2015
Programming
6
1.7k
Infrastructure as Code & Monitoring
Automacon 2015 talk: Infrastructure as Code & monitoring, sharing the same development workflow.
portertech
September 16, 2015
Tweet
Share
More Decks by portertech
See All by portertech
Monitoring Event Pipelines
portertech
0
130
Scaling Sensu Go
portertech
0
190
Understanding Habitat & Kube - A Home Lab Experiment
portertech
0
93
Today's Challenges of Big Infra Monitoring
portertech
1
54
Monitoring with Sensu Go
portertech
2
390
7 Years Of Sensu
portertech
1
92
Chef and Sensu - Delightful Monitoring
portertech
0
86
What is Sensu?
portertech
1
120
Ignite - The Art Of Monitoring
portertech
0
220
Other Decks in Programming
See All in Programming
Google's Recipe for Scaling (Web) Security – LocoMocoSec 2024
lweichselbaum
0
170
DMMプラットフォームにおけるTiDBの導入から運用まで
pospome
7
3k
20240706_CDKConf
takuyay0ne
0
1.2k
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
最近追加した型の紹介とその振り返り
aki19035vc
0
170
はしめてのプログラミングとロボット制御
watawatavoltage
0
290
I/O Extended Android in Korea 2024 ~ Whats new in Android development tools
pluu
0
250
わかりやすい正解を捨てて、コトに向き合う - スクラムフェス金沢2024 スポンサーセッション
yusukekokubo
0
170
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
Javaの現状2024夏 / Java current status 2024 summer
kishida
4
1.4k
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
Namespace on read
tagomoris
2
370
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
224
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
248
20k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
245
1.2M
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
90
47k
The Cost Of JavaScript in 2023
addyosmani
31
4.7k
Scaling GitHub
holman
458
140k
From Idea to $5000 a Month in 5 Months
shpigford
377
46k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
78
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
26
2.1k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
Ruby is Unlike a Banana
tanoku
96
10k
Transcript
Infrastructure as Code & Monitoring Sharing the same development workflow.
Sean Porter @PorterTech
FOCUS • The Sensu origin story - where it came
from • What makes Sensu different • IaC development workflows • Testing & monitoring in an IaC workflow • Chef & Sensu in practice
None
THE SENSU ORIGIN STORY • I started at Sonian ~
2010 ◦ Chef 0.7 with AWS #YOLO infrastructure ◦ Several traditional monitoring tools: Nagios, Ganglia, Collectd, & Graphite
~ 50 alerts a day Mostly noise.
THE SENSU ORIGIN STORY Triggered @lusis to write: “Why Monitoring
Sucks”
Wanted MOAR!
Build it. Automatic (de)registration Config Management friendly Secure connectivity REST
API Elastic scalability UNIX
July 11th, 2011
What makes Sensu different? What makes it better for CM
driven environments?
None
JSON CONFIGURATION { "checks": { "mysql_replication": { "command": "check-mysql-replication.rb", "subscribers":
["mysql"], "interval": 30, "playbook": "http://wiki.example.com/mysql-replication-playbook" } } }
CHECK EXECUTION METHODS • Pub/Sub (central orchestration) ◦ e.g. execute
http check on all API nodes • Standalone ◦ Define checks while provisioning node(s) ◦ Scheduled by the local Sensu client
LOCAL CLIENT SOCKET echo '{ \ "name": "mysql_backup", \ "output":
"could not connect to mysql", \ "status": 2, \ "ttl": 90000 }' | nc localhost 3030
None
Let’s talk about IaC workflows “The sequence of processes through
which a piece of work passes from initiation to completion” - Google.
BASIC IaC WORKFLOW “It’s all software.”
BASIC IaC WORKFLOW
BASIC IaC WORKFLOW “It’s all software.”
BASIC IaC WORKFLOW Use tests. Still need to review tests
& code quality.
BASIC IaC WORKFLOW TEST ≈ MONITOR
BASIC IaC WORKFLOW Shorten the feedback loop.
Writing IaC tests “A procedure intended to establish the quality,
performance, or reliability of something, especially before it is taken into widespread use” - Google.
TESTING TOOLS • Serverspec ◦ RSpec tests for your servers
◦ serverspec.org • Bats ◦ Bash Automated Testing System ◦ Bash script with special syntax for defining test cases
SERVERSPEC require 'spec_helper' describe service('httpd'), :if => os[:family] == 'redhat'
do it { should be_enabled } it { should be_running } end describe port(80) do it { should be_listening } end
BATS #!/usr/bin/env bats @test "httpd should be running" { run
service httpd status [ "$status" -eq 0 ] } @test "httpd should be listening for connections" { [ "$(netstat -plant | grep httpd)" ] }
RUNNING TESTS • Test Kitchen ◦ kitchen.ci • Vagrant plugins
◦ github.com/jvoorhis/vagrant-serverspec • Serverspec SSH • … choose your own adventure!
RUNNING TESTS AS SENSU CHECKS • Use the Sensu Serverspec
check plugin ◦ gem install sensu-plugins-serverspec check-serverspec.rb \ -d /etc/sensu/serverspec -t '*_spec.rb' • Run Bats scripts
Chef & Sensu In practice.
SENSU CHEF COOKBOOK supermarket.chef.io/cookbooks/sensu • Recipes to install & manage
services • LWRPs for configuring handlers, checks, etc. • Intended to be used by wrapper cookbook ◦ e.g. recipe['monitor::haproxy']
EXAMPLE CHEF RESOURCES sensu_handler 'default' do # recipe['monitor::_handlers'] type 'pipe'
command 'pagerduty.rb' end sensu_check 'redis_process' do # recipe['monitor::redis'] command 'check-procs.rb -p redis-server -w 2 -c 3 -C 1' standalone true interval 30 end
USING DATA BAGS # recipe['monitor::pubsub'] data_bag('sensu_checks').each do |data_bag_item| check =
data_bag_item('sensu_checks', data_bag_item) sensu_check check['id'] do check.each do |key, value| send(key.to_sym, value) if respond_to?(key.to_sym) end end end
SENSU SERVERSPEC CHECKS # recipe['monitor::serverspec'] sensu_gem 'sensu-plugins-serverspec' sensu_check 'serverspec' do
command 'check-serverspec.rb -d /etc/sensu/serverspec -t \*_spec.rb ' standalone true interval 30 end # e.g. CheckServerspec CRITICAL: 12 examples, 2 failures
BASIC IaC WORKFLOW TEST ≈ MONITOR
Questions? Sean Porter (@PorterTech) sensuapp.org