Skip to content

Commit

Permalink
Add AMQP configuration support - default attributes match default car…
Browse files Browse the repository at this point in the history
…bon-cache settings.
  • Loading branch information
Jeff Dutton committed Feb 5, 2013
1 parent 8e741d7 commit c7eaffd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions attributes/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@
default['graphite']['carbon']['service_type'] = "runit"
default['graphite']['carbon']['log_whisper_updates'] = "False"

# Default carbon AMQP settings match the carbon default config
default['graphite']['carbon']['enable_amqp'] = false
default['graphite']['carbon']['amqp_host'] = "localhost"
default['graphite']['carbon']['amqp_port'] = 5672
default['graphite']['carbon']['amqp_vhost'] = "/"
default['graphite']['carbon']['amqp_user'] = "guest"
default['graphite']['carbon']['amqp_password'] = "guest"
default['graphite']['carbon']['amqp_exchange'] = "graphite"
default['graphite']['carbon']['amqp_metric_name_in_body'] = false

default['graphite']['encrypted_data_bag']['name'] = nil
12 changes: 12 additions & 0 deletions recipes/carbon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
package "python-twisted"
package "python-simplejson"

if node['graphite']['carbon']['enable_amqp']
package "python-txamqp"
end

version = node['graphite']['version']
pyver = node['languages']['python']['version'][0..-3]

Expand Down Expand Up @@ -51,6 +55,14 @@
:cache_query_port => node['graphite']['carbon']['cache_query_port'],
:max_updates_per_second => node['graphite']['carbon']['max_updates_per_second'],
:log_whisper_updates => node['graphite']['carbon']['log_whisper_updates'],
:enable_amqp => node['graphite']['carbon']['enable_amqp'],
:amqp_host => node['graphite']['carbon']['amqp_host'],
:amqp_port => node['graphite']['carbon']['amqp_port'],
:amqp_vhost => node['graphite']['carbon']['amqp_vhost'],
:amqp_user => node['graphite']['carbon']['amqp_user'],
:amqp_password => node['graphite']['carbon']['amqp_password'],
:amqp_exchange => node['graphite']['carbon']['amqp_exchange'],
:amqp_metric_name_in_body => node['graphite']['carbon']['amqp_metric_name_in_body'],
:storage_dir => node['graphite']['storage_dir'])
notifies :restart, "service[carbon-cache]"
end
Expand Down
14 changes: 14 additions & 0 deletions templates/default/carbon.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,32 @@ LOG_UPDATES = <%= @log_whisper_updates %>


# Enable AMQP if you want to receve metrics using an amqp broker
<% if @enable_amqp %>
ENABLE_AMQP = True
<% else %>
# ENABLE_AMQP = False
<% end %>

# Verbose means a line will be logged for every metric received
# useful for testing
# AMQP_VERBOSE = False

<% if @enable_amqp %>
AMQP_HOST = <%= @amqp_host %>
AMQP_PORT = <%= @amqp_port %>
AMQP_VHOST = <%= @amqp_vhost %>
AMQP_USER = <%= @amqp_user %>
AMQP_PASSWORD = <%= @amqp_password %>
AMQP_EXCHANGE = <%= @amqp_exchange %>
AMQP_METRIC_NAME_IN_BODY = <%= @amqp_metric_name_in_body ? "True" : "False" %>
<% else %>
# AMQP_HOST = localhost
# AMQP_PORT = 5672
# AMQP_VHOST = /
# AMQP_USER = guest
# AMQP_PASSWORD = guest
# AMQP_EXCHANGE = graphite
<% end %>

# Patterns for all of the metrics this machine will store. Read more at
# http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol#Bindings
Expand Down

4 comments on commit c7eaffd

@eladroz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
On my machine, package "python-txamqp" bring over version 0.3.1 of the library (from the EPEL repo, as I'm on an RHEL 6 machine).

Unfortunately, that version has a known bug (https://bugs.launchpad.net/txamqp/+bug/741147), which prevents Graphite from connecting to any somewhat-up-to-date RabbitMQ successfully. However, installing this library via PIP brings over 0.6.1, which works ok - as suggested in http://stackoverflow.com/questions/11208645/using-amqp-with-graphite-9-9.

This hack-ish approach would also work, I guess: https://github.com/gosquared/graphite-cookbook/blob/master/recipes/txamqp.rb

Seems like ye olde v0.3.1 is what any Fedora/RH user would get, unless they're living on the edge: http://rpmfind.net/linux/rpm2html/search.php?query=python-txamqp&submit=Search+...&system=&arch=

I'm curious - can you share which version of the library did you get? which distro/repo?

Thanks,
Elad

@webframp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eladroz Instead of a hackish set of execute resources can you get it working using python_pip or does that break?

https://github.com/opscode-cookbooks/python/#python_pip

In the past, we encountered issues where python_pip install of graphite broke the web ui. I don't have quick access to RHEL 6 at the moment, but I will spin up a test vm this next week and take a look.

@eladroz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webframp I'd try to see if anything big breaks, but I hope the amqp package would be limited in its ability to break everything... ;-)

I see there's a centOS 6.3 box used for the testing, if you want to have a look (I'm using RHEL 6.3). Unfortunately I guess it's pretty much out of scope to test that AMQP works as part of the minimal test-set for this cookbook.

@webframp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eladroz I haven't had time yet, and don't want this to get lost so I created issue #27 for tracking. Let us know any more input there.

Thanks!

Please sign in to comment.