LoginSignup
1
1

More than 5 years have passed since last update.

Graphite + Ceres の環境構築

Last updated at Posted at 2016-12-21

はじめに

Graphite には標準のストレージエンジンのWhisperがありますが、Ceresという別のストレージエンジンもサポートしています。
Whisperは固定長のデータファイルを使用しますが、Ceresはツリー型のデータ構造となっており、必要以上のデータを持たないので、ディスクの節約になる場合があります。

Graphiteのインストール

まずは最新のGraphiteをインストールしましょう。CentOS 7を想定しています。

rootでの作業:

yum install python-virtualenv
yum install libffi-devel

一般ユーザでの作業:

virtualenv env
source env/bin/activate

pip install cffi
pip install cairocffi
pip install incremental
pip install Django==1.9.12 django-tagging==0.4.3
pip install constantly fadvise gunicorn mocker
pip install pycparser pyparsing==2.0.7 pytz python-memcached
pip install simplejson txAMQP uWSGI whitenoise zope.interface Twisted

pip install https://github.com/graphite-project/ceres/tarball/master
pip install https://github.com/graphite-project/whisper/tarball/master
git clone https://github.com/graphite-project/graphite-web.git

python setup.py install 
   --install-data=~/var/data/ \
   --install-lib=~/usr/graphite/webapp \
   --install-scripts=~/usr/graphite/bin

初期設定:

cd ~/usr/graphite/webapp/graphite
mv local_settings.py.example local_settings.py
vi local_settings.py
  # GRAPHITE_ROOTの修正(~/var/data/をフルパスで指定)

# DBの初期化
PYTHONPATH=~/usr/graphite/webapp django-admin.py migrate \
  --run-syncdb --settings=graphite.settings

ストレージエンジンの変更(Whisper->Ceres):
~/usr/graphite/webapp/graphite/settings.pyを以下のように修正

STORAGE_FINDERS = (
    'graphite.finders.ceres.CeresFinder',
)

Graphiteの起動

PYTHONPATH=~/usr/graphite/webapp uwsgi --http :8080 \
   --wsgi-file ~/usr/graphite/webapp/graphite/wsgi.py \
   --static-map=/static=$(pwd)/var/data/webapp/content/

テストデータの登録

ceres-node-create, ceres-node-write などのコマンドが使用できます。

# ツリーの作成
cd ~/var/data/storage/ceres/
ceres-tree-create test

# ノードの作成
ceres-node-create test/node1 
ceres-node-create test/node2 --step 60  (解像度を60秒に設定)

# データの登録
ceres-node-write test/node1 N:1
ceres-node-write test/node2 N:1
(Nを指定すると現在時刻になります)

# ランダムにいれてみる
ceres-node-write test/node1 1482304620:$RANDOM
ceres-node-write test/node1 1482304680:$RANDOM
ceres-node-write test/node1 1482304740:$RANDOM

Graphite-webからの確認

うまくデータが入っていれば、このように表示されるでしょう。

graphite.png

総括

Ceresはデータサイズの抑制には効果があり、パフォーマンスアップも期待できますが、(Whisperにもある)スケールアウトの問題は解決できません。ですがメトリックスが多い場合、それなりにメリットはあるでしょう。

一つ問題は、細かいファイルが大量に生成されるため、ディスクのブロックサイズの影響をうけて、特に実データが多い場合、Whisperと比較して何倍もディスクを消費する場合があります。
convert-wsp-to-ceresという付属ツールで変換もできるので、実際に検証したほうがいいでしょう。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1