Collecting GlusterFS Logs with Fluentd

https://github.com/keithseahus/fluent-plugin-glusterfs

插件地址

This article shows how to use Fluentd to collect GlusterFS logs for analysis (search, analytics, troubleshooting, etc.)

Table of Contents

Background

GlusterFS is an open source, distributed file system commercially supported by Red Hat, Inc. Each node in GlusterFS generates its own logs, and it’s sometimes convenient to have these logs collected in a central location for analysis (e.g., When one GlusterFS node went down, what was happening on other nodes?).

Fluentd is an open source data collector for high-volume data streams. It’s a great fit for monitoring GlusterFS clusters because:

  1. Fluentd supports GlusterFS logs as a data source.
  2. Fluentd supports various output systems (e.g., Elasticsearch, MongoDB, Treasure Data, etc.) that can help GlusterFS users analyze the logs.

The rest of this article explains how to set up Fluentd with GlusterFS. For this example, we chose Elasticsearch as the backend system.

Setting up Fluentd on GlusterFS Nodes

Step 1: Installing Fluentd

First, we’ll install Fluentd using the following command:

$ curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh

Next, we’ll install the Fluentd plugin for GlusterFS:

$ sudo /usr/sbin/td-agent-gem install fluent-plugin-glusterfs
Fetching: fluent-plugin-glusterfs-1.0.0.gem (100%)
Successfully installed fluent-plugin-glusterfs-1.0.0
1 gem installed
Installing ri documentation for fluent-plugin-glusterfs-1.0.0...
Installing RDoc documentation for fluent-plugin-glusterfs-1.0.0...

Step 2: Making GlusterFS Log Files Readable by Fluentd

By default, only root can read the GlusterFS log files. We’ll allow others to read the file.

$ ls -alF /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
-rw------- 1 root root 1385  Feb  3 07:21 2014 /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
$ sudo chmod +r /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
$ ls -alF /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
-rw-r--r-- 1 root root 1385  Feb  3 07:21 2014 /var/log/glusterfs/etc-glusterfs-glusterd.vol.log

Now, modify Fluentd’s configuration file. It is located at /etc/td-agent/td-agent.conf.

 `td-agent` is Fluentd's rpm/deb package maintained by [Treasure Data](http://docs.treasuredata.com/articles/td-agent)

This is what the configuration file should look like:

$ sudo cat /etc/td-agent/td-agent.conf

<source>
  @type glusterfs_log
  path /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
  pos_file /var/log/td-agent/etc-glusterfs-glusterd.vol.log.pos
  tag glusterfs_log.glusterd
  format /^(?<message>.*)$/
</source>

<match glusterfs_log.**>
  @type forward
  send_timeout 60s
  recover_wait 10s
  heartbeat_interval 1s
  phi_threshold 8
  hard_timeout 60s

  <server>
    name logserver
    host 172.31.10.100
    port 24224
    weight 60
  </server>

  <secondary>
    @type file
    path /var/log/td-agent/forward-failed
  </secondary>
</match>
 the ... section is for failover (when the aggregator instance at 172.31.10.100:24224 is unreachable).

Finally, start td-agent. Fluentd will started with the updated setup.

$ sudo service td-agent start
Starting td-agent:                                         [  OK  ]

Step 3: Setting Up the Aggregator Fluentd Server

We’ll now set up a separate Fluentd instance to aggregate the logs. Again, the first step is to install Fluentd.

$ curl -L https://toolbelt.treasuredata.com/sh/install-redhat.sh | sh

We’ll set up the node to send data to Elasticsearch, where the logs will be indexed and written to local disk for backup.

First, install the Elasticsearch output plugin as follows:

$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-glusterfs

Then, configure Fluentd as follows:

$ sudo cat /etc/td-agent/td-agent.conf
<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

<match glusterfs_log.glusterd>
  @type copy

  #local backup
  <store>
    @type file
    path /var/log/td-agent/glusterd
  </store>

  #Elasticsearch
  <store>
    @type elasticsearch
    host ELASTICSEARCH_URL_HERE
    port 9200
    index_name glusterfs
    type_name fluentd
    logstash_format true
  </store>
</match>

That’s it! You should now be able to search and visualize your GlusterFS logs with Kibana.

Acknowledgement

This article is inspired by Daisuke Sasaki’s article on Classmethod’s website. Thanks Daisuke!

Learn More

s is a fascinating hobby for many people, particularly those interested in studying insects and their behavior. However, it's crucial to follow ethical and legal guidelines, and to ensure that bugs are collected and handled humanely. Here are some tips for collecting bugs: 1. Check local regulations: Before you start collecting bugs, check your local regulations to make sure it is legal to do so. Some areas may have restrictions on collecting certain species or collecting bugs in protected areas. 2. Use ethical and humane methods: It's important to use ethical and humane methods when collecting bugs. Avoid using harmful chemicals, and instead use gentle methods such as nets or traps. Handle the bugs carefully and avoid injuring them. 3. Respect the environment: When collecting bugs, make sure to respect the environment and the other creatures that live there. Avoid damaging plants or other habitats, and leave the area as you found it. 4. Keep accurate records: Keep accurate records of the species you collect, when and where you collected them, and any other relevant information. This can be helpful for scientific research and for tracking changes in insect populations over time. 5. Release the bugs: After you have collected and observed the bugs, release them back into their natural habitat. Make sure to do so in a safe and appropriate location, and handle them carefully to avoid injury. Remember that collecting bugs can be a fun and educational hobby, but it's important to do so responsibly and ethically. By following these guidelines, you can enjoy the hobby while also helping to protect these fascinating creatures and their habitats.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值