LoginSignup
15

More than 5 years have passed since last update.

fluentd で MySQL のレプリケーションを監視

Last updated at Posted at 2013-05-28

設定

mysql_slave.conf
<source>
  type            mysql_query
  host            127.0.0.1
  port            3306
  username        watch
  interval        1m
  tag             mysql.slave
  query           SHOW SLAVE STATUS
  record_hostname yes
</source>

<match mysql.slave>
  type notifier
  <def>
    pattern     replication_stopped
    check       string_find
    warn_regexp ^$
    crit_regexp ^$
    target_keys Seconds_Behind_Master
  </def>
  <def>
    pattern        replication_delay
    check          numeric_upward
    warn_threshold 2
    crit_threshold 10
    target_keys    Seconds_Behind_Master
  </def>
</match>

<match notification.**>
  type     mail
  host     localhost
  port     25
  from     FROM
  to       TO
  subject  fluentd notification
  out_keys pattern,target_tag,target_key,level,value,message_time
</match>

アラートメール例

レプリケーション停止

pattern: replication_stopped
target_tag: mysql.slave
target_key: Seconds_Behind_Master
level: crit
value:
message_time: 2013-05-28 12:52:14 +0900

レプリケーション遅延

pattern: replication_delay
target_tag: mysql.slave
target_key: Seconds_Behind_Master
level: crit
value: 40.0
message_time: 2013-05-28 13:01:14 +0900

利用プラグイン

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
15