Skip to content

Instantly share code, notes, and snippets.

@kenwdelong
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwdelong/5145f72dd1f7ba437faf to your computer and use it in GitHub Desktop.
Save kenwdelong/5145f72dd1f7ba437faf to your computer and use it in GitHub Desktop.
Create a Graphite and Statsd server with Chef and Vagrant. This one provisions the VM and starts the services.

Creating a Graphite and Statsd Server

First install the pre-reqs

  • Install VirtualBox
  • Install Vagrant
  • gem install librarian-chef
  • librarian-chef install
  • vagrant plugin install vagrant-vbguest
  • vagrant plugin install vagrant-omnibus

Sometimes I have to log in and start uwsgi. ps aux | grep uwsgi sudo service uwsgi start

For troubleshooting, start in /etc/graphite/local_settings.py Graphite should appear on http://localhost:2880/content

Alternative

It might be easier to use this... https://github.com/hopsoft/docker-graphite-statsd

Correction

It's even easier to use the cooniur/graphana_graphite docker container at https://registry.hub.docker.com/u/cooniur/grafana_graphite/.

site "https://supermarket.getchef.com/api/v1"
cookbook "apt"
cookbook "vim"
cookbook 'apache2', '~> 2.0.0'
cookbook 'python', '~> 1.4.6'
cookbook "statsd", :git => "https://github.com/hectcastro/chef-statsd", :ref => "v1.1.10"
cookbook "oc-graphite", :git => "https://github.com/opscode-cookbooks/oc-graphite", :ref => "0.0.3"
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# These two for Virtual Box
#config.vm.box = "vagrant-graphite"
#config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.box = "ubuntu/trusty64"
config.vm.box_url = "https://vagrantcloud.com/ubuntu/boxes/trusty64"
# This one for AWS
#config.vm.box= "dummy"
config.vm.network :forwarded_port, guest: 80, host: 2280
config.vm.network :forwarded_port, guest: 8080, host: 2880
config.vm.network :forwarded_port, guest: 2003, host: 2003
config.vm.network :forwarded_port, guest: 8125, host: 8125, :protocol => 'udp'
config.vm.network :forwarded_port, guest: 8126, host: 8126, :protocol => 'tcp'
# config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network :public_network
config.vm.provider :virtualbox do |vb|
# Don't boot with headless mode
# vb.gui = true
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
config.vm.provider :aws do |aws, override|
aws.access_key_id = "xxx"
aws.secret_access_key = "xxx"
aws.keypair_name = "MyKeyPair"
aws.ami = "ami-3d50120d"
#aws.ami = "ami-99bef1a9"
aws.instance_type = "t2.small"
aws.associate_public_ip = "true"
aws.region = "us-west-2"
aws.subnet_id = "subnet-0a46ab7d"
override.ssh.username = "ubuntu"
override.ssh.private_key_path = "~/.ssh/MyKeyPair.pem"
end
# You need to ensure you have the right version of Chef installed on the box
# vagrant plugin install vagrant-omnibus
config.omnibus.chef_version = "11.6.0"
# in addition to the very basics, we also have vbguest installed
# vagrant plugin install vagrant-vbguest
config.vbguest.auto_update = true
# Chef Solo
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "apache2"
chef.add_recipe "apache2::mod_wsgi"
chef.add_recipe "python"
chef.add_recipe "oc-graphite::graphite_carbon"
chef.add_recipe "oc-graphite::graphite_web"
chef.add_recipe "statsd"
chef.add_recipe "vim"
chef.json = {
:graphite => {
:version => '0.9.9',
:python_version => '2.7',
:twisted_version => '13.1.0',
:password => 'admin',
:carbon => {
:line_receiver_interface => '0.0.0.0'
},
:whisper => {
},
:graphite_web => {
}
},
:statsd => {
:graphite => {
:global_prefix => 'statsd'
},
:nodejs_bin => '/usr/bin/node'
},
'oc-graphite' => {
:web => {
:secret_key => 'IHateGraphite'
}
}
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment