Install statsd and graphite on CentOS or RHEL

From ezUnix
Jump to: navigation, search
                                    pdf_icon.png Download this article as a single PDF document 

Introduction

Graphite is a highly scalable real-time graphing system.
As a user, you write an application that collects numeric time-series data that you are interested in graphing, and send it to Graphite's processing backend, carbon, which stores the data in Graphite's specialized database.
The data can then be visualized through graphite's web interfaces.


Software

  • CentOS 6.0


Installation

  • Add Epel repositories to yum and update it.
# rpm -i http://ftp.uninett.no/linux/epel/6/x86_64/epel-release-6-5.noarch.rpm
# yum update
  • Install necessary packages
# yum install python-devel.x86_64 python-pip.noarch mod_wsgi.x86_64 mod_python.x86_64 python-sqlite2.x86_64 \
       bitmap.x86_64 pycairo.x86_64 python-zope-interface.x86_64 python-simplejson.x86_64 django-tagging.noarch \
       python-pip.noarch python-twisted-web.x86_64 bitmap bitmap-fonts gcc-c++.x86_64  \
       openssl-devel.x86_64 git.x86_64 make.x86_64

Use pyton's package manager - pip to install some of the software

# pip-python install carbon
# pip-python install graphite-web
# pip-python install whisper


Configure carbon

Copy example configs to .conf

# pushd /opt/graphite/conf
# cp carbon.conf.example carbon.conf
# cp storage-schemas.conf.example storage-schemas.conf

Edit storage-schemas.conf

[stats]
priority = 110
pattern = ^stats\..*
retentions = 10:2160,60:10080,600:262974

This will retain all stats* stuff for:

  • 6 hours of 10 second data
  • 1 week of 1 minute data
  • 5 years of 10 minute data

Edit storage-aggregation.conf

[counters]
pattern = stats.counts.*
xFilesFactor = 0.0
aggregationMethod = sum

graphTemplates.conf

# cp graphTemplates.conf.example graphTemplates.conf

Copy important file

# cp graphite.wsgi.example graphite.wsgi

Make wsgi directory

  • Red Hat:
# mkdir /etc/httpd/wsgi


Configure apache2

Add this to /etc/httpd/conf/httpd.conf :

Include "/etc/httpd/vhosts/*.conf"

Create the new directory

# mkdir /etc/httpd/vhosts

Edit

# /etc/httpd/vhosts/graphite-vhost.conf


# On Red Hat
 WSGISocketPrefix /etc/httpd/wsgi/

 <VirtualHost *:80>
        ServerName graphite
        DocumentRoot "/opt/graphite/webapp"
        ErrorLog /opt/graphite/storage/log/webapp/error.log
        CustomLog /opt/graphite/storage/log/webapp/access.log common

        # I've found that an equal number of processes & threads tends
        # to show the best performance for Graphite (ymmv).
        WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
        WSGIProcessGroup graphite
        WSGIApplicationGroup %{GLOBAL}
        WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}

        # XXX You will need to create this file! There is a graphite.wsgi.example
        # file in this directory that you can safely use, just copy it to graphite.wgsi
        WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi 

        Alias /content/ /opt/graphite/webapp/content/
        <Location "/content/">
                SetHandler None
        </Location>

        # XXX In order for the django admin site media to work you
        # must change @DJANGO_ROOT@ to be the path to your django
        # installation, which is probably something like:
        # /usr/lib/python2.6/site-packages/django
        Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
        <Location "/media/">
                SetHandler None
        </Location>
        # The graphite.wsgi file has to be accessible by apache. It won't
        # be visible to clients because of the DocumentRoot though.
        <Directory /opt/graphite/conf/>
                Order deny,allow
                Allow from all
        </Directory>

 </VirtualHost>


Let the Apache user be the owner of /opt/graphite/storage/

# chown -R apache:apache /opt/graphite/storage/


Configure graphite web

Do:

# cd /opt/graphite/webapp/graphite
# sudo python manage.py syncdb

You will be prompted to create an admin user; most people will want to do this.


Start Carbon

(the data aggregator)
# cd /opt/graphite/
# ./bin/carbon-cache.py start


Install Node.js

# cd /tmp
# git clone http://github.com/joyent/node.git
# cd node
# git checkout v0.4.9
# ./configure && make && make install

Install npm

# cd /tmp
# wget http://npmjs.org/install.sh
# sh install.sh
# /usr/local/bin/npm install express


Install statsd

# cd /tmp
# git clone http://github.com/etsy/statsd.git
# cp -R /tmp/statsd /opt/graphite


Start Node.js/statsd

# cd /opt/graphite/statsd
# cp exampleConfig.js local.js

Edit local.js so it looks similar to this:

{
  graphitePort: 2003
, graphiteHost: "127.0.0.1"
, port: 8125
}

Start it

# nohup /usr/local/bin/node stats.js local.js &


That's all folks.
Marcin


<comments />

Granado said ...

<comment date="2012-07-12T01:44:09Z" name="Granado"> Hi,Just found your website, very iettresend in Siege, sountds great. As a Perl programmer, I also wanted to check out your Perl modules, they sound good too. Just wanted to mention that the download links point use an ftp protocol address which does not work. I used http to thewww address and it worked fine.Thanks for sharing! </comment>

Craig said ...

<comment date="2012-07-14T04:01:32Z" name="Craig"> Sir,For 3.0,3.2First of all remove all other veisorns of exam, if anyand delete the folders, exam10,9,8 ,Images 10,9,8 etc.Copy the folder itexam-debs to the pen drive.Then paste it to the desktops of systems.Open it and right click itexam-6.0-itschool-3.0-3.2.deb. and install using G-Debi package manager.That's all. </comment>

Randy said ...

<comment date="2012-07-14T05:25:18Z" name="Randy"> ผมเคยสั่ง Headamp มาก็ไม่ได้คืนนะครับ คิดว่าไม่น่าได้คืนเหมือนกันครับ อันนี้เป็น link ที่ไป Copy มาของ Import Fees Deposit ครับ Each item in your order is sold by Amazon Export Sales, Inc. ( Amazon Export ) or the merchant that the item is spfeeiicd as sold by ( Merchant ). Those items for shipment to countries outside of the U.S. may be subject to taxes, customs duties and fees levied by the destination country ( Import Fees ). The recipient of the shipment is the importer of record in the destination country and is responsible for all Import Fees.With respect to each item for which Import Fees have been calculated, you authorize Amazon Export or Merchant (as applicable) to designate a carrier ( Designated Carrier ) to act as your agent with the relevant customs and tax authorities in the destination country, to clear your merchandise, process and remit your actual Import Fees for such item. Import Fees Deposit represents an estimate of the Import Fees that will be levied on the items in your order for shipment to countries outside of the US. By placing your order, you agree to allow Amazon Export and/or Merchant (as applicable) to collect the Import Fees Deposit for the applicable items in your order. This deposit will be used, on your behalf, to reimburse the Designated Carriers for the import fees that they have paid on your behalf to the appropriate authorities of the destination country.You further agree that the Designated Carriers may disclose to Amazon Export or Merchant (as applicable) the amount of actual Import Fees levied on the item you have purchased from Amazon Export and/or Merchant ( Actual Import Fees ). In the event that the Import Fees Deposit exceeds the Actual Import Fees, Amazon Export or Merchant (as applicable) will refund the difference to you.In the case of gifts or other purchases made on behalf of another recipient, you also agree to grant the foregoing authorizations on behalf of the recipient designated in your order.To obtain details regarding the Actual Import Fees, or to obtain documentation or receipts in connection with customs clearance, you may contact the Carrier spfeeiicd in your shipment confirmation e-mail.These terms and conditions are in addition to the standard Conditions of Use of the Amazon website. Pursuant to those terms, title and risk of loss for the items transfer to the recipient upon delivery to the common carrier in the United States.Please note that Merchants participating in the International Direct program may have policies that differ from Amazon Export's terms and conditions. For items you have purchased from a Merchant, please see the applicable Merchant's policies for any other terms and conditions that may apply to your purchase of such items.LimitationsFor products shipped internationally, please note that any manufacturer warranty may not be valid; manufacturer service options may not be available; product manuals, instructions and safety warnings may not be in destination country languages; the products (and accompanying materials) may not be designed in accordance with destination country standards, specifications, and labeling requirements; and the products may not conform to destination country voltage and other electrical standards (requiring use of an adapter or converter if appropriate). You are responsible for assuring that the product can be lawfully imported to the destination country. When ordering from Amazon.com, the recipient is the importer of record and must comply with all laws and regulations of the destination country. </comment>

Ree said ...

<comment date="2012-07-14T09:00:00Z" name="Ree"> With all the defunct land prjocets in the US right now that are located at the edge of rural areas, have you given any thought to supporting a fund to acquire that land and return it to farming. Perhaps you or Biological Capital could build an incubator model for small farmers to help them build the local business with the support from some of the local Agriculture Schools. Overtime, perhaps the farmer could purchase the land from the fund as the business grows and is successful. </comment>

Aris said ...

<comment date="2013-01-08T19:51:40Z" name="Aris"> Hi,Just found your website, very inetrested in Siege, sountds great. As a Perl programmer, I also wanted to check out your Perl modules, they sound good too. Just wanted to mention that the download links point use an ftp protocol address which does not work. I used http to thewww address and it worked fine.Thanks for sharing! </comment>

Valen said ...

<comment date="2013-01-09T04:24:33Z" name="Valen"> I noticed that pesret-files where not in a human readable format. For me (a bit of a nerdy person perhaps) it would be way cooler when files like this would be human readable; I could really make my pesret pixel-perfect'. Now it isn't. But still I will share it with you It is a Traktor mapping (perfect for 2 decks) . I'll have to wait till my girl comes home from her work, since she has our iPad with her at the mo ..greetinx . </comment>

Harald said ...

<comment date="2013-01-10T10:33:47Z" name="Harald"> There we go. Got all the posts on the third import. Now to start the long, lorobiaus process of customizing the blog. To include pointing the URL to the new site, updating the themes, updating the links, and on, and on </comment>