4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Grafana + GraphiteでAnnotationsを使ってイベントを可視化する

Posted at

GrafanaにはAnnotationsという、イベントをグラフ上へ表示する機能があります。

Annotationsの取得元はいくつか利用可能ですが、データソースとしてGraphiteのEvent
を使う方法について解説します。

Event

GraphiteにはEventと言う情報を保存する仕組みがあります。
しかし探してみても、データを格納する方法については公式ドキュメントで見つからない。

ただ、データの取り出し方については書かれています。
http://graphite.readthedocs.org/en/stable/functions.html?highlight=event#graphite.render.functions.events

こちらのブログで登録方法が書かれているので、そちらを参考に進めます。

Eventの登録

最低限のデータで登録する場合は、以下の様にデータをPostしてあげればいいです。

curl -X POST "http://graphitehost.com/events/" -d '{"what": "fugafuga", "tags": "hoge"}'

Eventの情報が格納されるテーブルはevents_eventで、このテーブルの構造を見ると以下のように定義されてます。

CREATE TABLE "events_event" (
    "id" integer NOT NULL PRIMARY KEY,
    "when" datetime NOT NULL,
    "what" varchar(255) NOT NULL,
    "data" text NOT NULL,
    "tags" varchar(255) NOT NULL
);

テーブル構造から分かるように、さらにwhendataを指定することが可能です。

  • whenは、デフォルトでシステム日付が設定されます
  • dataは、デフォルトでからが設定されます

例えばこんな感じで

curl -X POST "http://graphitehost.com/events/" -d '{"what": "Deploy apps 5", "tags": "deploy", "data": "ここには長い文章が指定できます。"}'

Grafanaの設定

Graphiteに登録されているEventをグラフ上に表示するには、Dashboardの設定から登録します。
Dashboardで設定するように、グラフ単位では指定できないみたいです。
スクリーンショット 2015-04-29 12.14.08.png

取得するEventの情報を登録します。
スクリーンショット 2015-04-29 13.48.01.png

  • Name: Annotationの名称
  • Datasource: Graphiteのデータソース
  • Graphite event tags: イベントを登録した時のtag名

登録すると、こんな感じで表示されます。
スクリーンショット 2015-04-29 13.12.48.png

先ほどのdataに指定した場合は、以下のように表示されます。
スクリーンショット 2015-04-29 13.37.03.png

Dashboardには複数のAnnotationが登録でき、チェックボックスのON/OFFで表示非表示の切り替えができるので、デプロイ、サーバ追加と言った複数のイベントを登録して表示することで、どのような出来事がきっかけでリソースに変化があったかが一目瞭然となります。

このエントリーは私のブログで公開した情報のクローンです

4
3
0

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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?