WEBモニタリングシリーズ第三編:graphiteガイド

4275 ワード

使用説明
以下はデータを与える方法ですが、実際の使用ではstatsdを使用してデータを与えるので、私の4番目の文章を参照してください:statsdガイド
データを与えるには3つの方法があります.
There are three main methods for sending data to Graphite: Plaintext, Pickle, and AMQP.
Choosing the right transfer method for you is dependent on how you want to build your application or script to send data:
  • For a singular script, or for test data, the plaintext protocol is the most straightforward method.
  • For sending large amounts of data, you’ll want to batch this data up and send it to Carbon’s pickle receiver.
  • Finally, Carbon can listen to a message bus, via AMQP.

  • The plaintext protocol
    The plaintext protocol is the most straightforward protocol supported by Carbon.
    The data sent must be in the following format: . Carbon will then help translate this line of text into a metric that the web interface and Whisper understand.
    On Unix, the nc program can be used to create a socket and send data to Carbon (by default, ‘plaintext’ runs on port 2003):
    PORT=2003
    SERVER=graphite.your.org
    echo "local.random.diceroll 4 `date +%s`" | nc ${SERVER} ${PORT};
    

    The pickle protocol
    The pickle protocol is a much more efficient take on the plaintext protocol, and supports sending batches of metrics to Carbon in one go.
    The general idea is that the pickled data forms a list of multi-level tuples:
    [(path, (timestamp, value)), ...]
    

    Once you’ve formed a list of sufficient size (don’t go too big!), send the data over a socket to Carbon’s pickle receiver (by default, port 2004). You’ll need to pack your pickled data into a packet containing a simple header:
    payload = pickle.dumps(listOfMetricTuples)
    header = struct.pack("!L", len(payload))
    message = header + payload
    

    You would then send the message object through a network socket.
    Using AMQP
    高度なメッセージキュープロトコル(AMQP)は、非同期メッセージングに使用されるアプリケーション層プロトコル仕様である.API(例えばJMS)ではなく、回線層プロトコルとして、AMQPクライアントは、メッセージのソースを無視して任意に情報を送信および受信することができる.
    これは使いにくいはずです.
    質問:
    1 y軸の単位と送信の不一致
    二使用方法
    まとめて言えば、たまに観察するならgraphite(server:8080)全体を直接開けて見ればいい.長期使用であればdashboardの方が便利です.
    しかし、私のパソコンでワイルドカードが使えない場合はurl apiを使ってワイルドカードを得ることができます.dashboardならすべてを1枚の図に引き寄せることができます
    参照先:http://www.jsxubar.info/graphite-dashboard.html
    仮想ホストへのアクセス方法はserver:8080です.
    変数の使用説明:変数名はcarbonのようなツリーの構造で展開されます.agents.Alg-1-a.cpuUsageはcpuUsageという変数がcarbonにあることを表す.agents.alg-1-a.この経路で.
    1 dashboard
    名前の通り、パネルで表示されます.
    この方法では、プロジェクトを選択して図形を描き、最後にページの形式に保存することができます.再確認時に直接ページを開くことができます.
    server:8080/dashboardオープンパネル
  • データソースを選択するときに「*」というワイルドカードを使うと便利です.例えば、複数のホストの空きコンテンツを比較するには、*を使用します.meminfo.freeによるフィルタリング
  • データソースの最下層情報を見つけてクリックすると、太字が表示され、データソースが選択されていることを示す図
  • が表示されます.
    データを選択し、グラフィックを生成してdashboardとして保存します.CPUのグラフィック情報をcpuとして保存し、このブラウザウィンドウを閉じます.次回の表示時にserver:8080/dashboard/#cpuを使用して表示できます.
    次にパネルを開くとき、以前に作成したパネルを覚えていないので、「Finder」でパネルリストを選択できます.
    自分がやっている間に、ワイルドカードが効かないことに気づき、反応が遅い感じがします.???
    2 cli
    コマンドラインアクション
    上記のjsxubarブログまたは公式サイトを参照してください.http://graphite.wikidot.com/cli-reference
    3  Url Api
    Webサイトを使用して、必要なグラフィックを直接取得します.
    たとえば、http://127.0.0.1:8080/render?target=*.test&target=*.bigboy&from=-60min
    上記のjsxubarブログまたは公式サイトを参照してください.http://graphite.wikidot.com/url-api-reference
    小さな点
    yStepの設定
    Default: Calculated automatically
    Manually set the value step between Y-axis labels and grid lines
    主な参考:
    graphiteドキュメント:https://graphite.readthedocs.orgほとんどすべてを調べることができます