LoginSignup
6
7

More than 5 years have passed since last update.

RabbitMQのデータをTelegraf経由でInfluxDBに入れてみる

Posted at

はじめに

最近ログやリソース状況を把握するためにInfluxDBを利用しようと考えていて、@takaidohigasiの紹介もありInfluxDB社が提供しているメトリックス収集ツールであるTelegrafを使ったのでメモしておく。

より詳細なTelegrafの紹介は以下を参照してください。
http://qiita.com/takaidohigasi/items/fdc81db8336aa7601fc9

Telegrafとは

この辺は以下を参照してください。
http://qiita.com/takaidohigasi/items/fdc81db8336aa7601fc9
http://qiita.com/akito1986/items/3d5b99b0674af8f0050e

環境

  • OS: CentOS7.1
  • InfluxDB: 0.9.3
  • Telegraf: 0.1.7
  • RabbitMQ: 3.5.0

Install

ここも以下を参照。
http://qiita.com/akito1986/items/3d5b99b0674af8f0050e

RabbitMQプラグインの設定

telegrafの便利な機能として各種プラグインについての設定方法は以下のコマンドで確認出来る。

$ /opt/telegraf/telegraf -usage rabbitmq
# Read metrics from one or many RabbitMQ servers via the management API
[rabbitmq]
# Specify servers via an array of tables
    [[rabbitmq.servers]]
    # url = "http://localhost:15672"
    # username = "guest"
    # password = "guest"

    # A list of nodes to pull metrics about. If not specified, metrics for
    # all nodes are gathered.
    # nodes = ["rabbit@node1", "rabbit@node2"][root@influxdb-1 ~]$

^を参考にして以下のように設定ファイルを作成。
事前にRabbitmqのrabbitmq_managementというプラグインを作成し、管理者画面にアクセス可能なユーザーを作成しておく必要あり。
おそらくnodesはクラスタリングしたときに設定すればいいのかなと思うが、今回はクラスタリングしていないのでコメントアウトしたままとしている。

telegraf.toml
# Telegraf configuration

# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared plugins.

# Even if a plugin has no configuration, it must be declared in here
# to be active. Declaring a plugin means just specifying the name
# as a section with no variables. To deactivate a plugin, comment
# out the name and any variables.

# Use 'telegraf -config telegraf.toml -test' to see what metrics a config
# file would generate.

# One rule that plugins conform to is wherever a connection string
# can be passed, the values '' and 'localhost' are treated specially.
# They indicate to the plugin to use their own builtin configuration to
# connect to the local system.

# NOTE: The configuration has a few required parameters. They are marked
# with 'required'. Be sure to edit those to make this configuration work.

# Tags can also be specified via a normal map, but only one form at a time:
[tags]
    # dc = "us-east-1"

# Configuration for telegraf itself
[agent]
    interval = "10s"
    # debug = false
    hostname = "telegraf01"
# Read metrics of haproxy, via socket or csv stats page


###############################################################################
#                                  OUTPUTS                                    #
###############################################################################

[outputs]

# Configuration for influxdb server to send metrics to
[outputs.influxdb]
    # The full HTTP endpoint URL for your InfluxDB instance
    url = "http://localhost:8086" # required.

    # The target database for metrics. This database must already exist
    database = "telegraf" # required.

    # Connection timeout (for the connection with InfluxDB), formatted as a string.
    # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
    # If not provided, will default to 0 (no timeout)
    # timeout = "5s"

    # username = "telegraf"
    # password = "metricsmetricsmetricsmetrics"

    # Set the user agent for the POSTs (can be useful for log differentiation)
    # user_agent = "telegraf"


###############################################################################
#                                  PLUGINS                                    #
###############################################################################

[rabbitmq]
# Specify servers via an array of tables
    [[rabbitmq.servers]]
    url = "http://localhost:15672"
    username = "admin"
    password = "admin"

    # A list of nodes to pull metrics about. If not specified, metrics for
    # all nodes are gathered.
    # nodes = ["rabbit@node1", "rabbit@node2"][root@influxdb-1 ~]

起動してみる

以下のコマンドでforegroudで起動してやる。

$ /opt/telegraf/telegraf -config=telegraf.toml
2015/09/01 13:13:11 Starting Telegraf (version 0.1.7)
2015/09/01 13:13:11 Loaded outputs: influxdb
2015/09/01 13:13:11 Loaded plugins: rabbitmq
2015/09/01 13:13:11 Tags enabled: host=telegraf01

しばらくたってinfluxDBで確認するとtelegrafというDBに各種measurementsが入っていることがわかる。

influxdb_rabbitmq.png

Grafanaで見てみる

DatasourceにtelegrafというDBを追加してDashboardでrabbitmqのchannel数などを表示してやれば以下のように表示される。

grafana_rabbitmq.png

これは使えそうですね。

おしまい。

6
7
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
6
7