1.1.5.1. Fluentdをインストールする

  1. 以下のコマンドを実行してFluentdをインストールします。
    ※インターネット接続可能な環境で実行してください。
    # curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent4.sh | sh
    
  2. 以下のコマンドを実行し、Fluentd(td-agent)のバージョンが表示されることを確認します。
    # td-agent --version
    

1.1.5.2. Fluentdを設定する

  1. 以下のコマンドを実行し、設定ファイルを編集します。
    ※記載のない行は、初期値のままとします。
    # vi /usr/lib/systemd/system/td-agent.service
    [Service]
    User=root
    Group=root
    
  2. 以下のコマンドを実行します。
    ※エラーが表示されないことを確認してください。
    # systemctl daemon-reload
    
  3. 以下のコマンドを実行し、設定ファイルを編集します。
    # vi /etc/td-agent/td-agent.conf
    ######################################
    # FRAからのSYSLOG受信                #
    ######################################
    <source>
      @type syslog
      port 514
      bind 0.0.0.0
      tag FRA
      <transport tcp>
      </transport>
      <parse>
        message_format auto
        with_priority true
      </parse>
    </source>
    
    ######################################
    # 受信ログをサーバー別にタグで分類    #
    ######################################
    <match FRA.**>
      @type rewrite_tag_filter
    # 0系用タグ
      <rule>
        key      host
        pattern  0系のホスト名
        tag      "0系のホスト名.${tag}"
      </rule>
    # 1系用タグ
      <rule>
        key      host
        pattern  1系のホスト名
        tag      "1系のホスト名.${tag}"
      </rule>
    </match>
    
    ##########################################################
    # サーバー+ファシリティ別にログファイルへログを書き込み    #
    ##########################################################
    # 0系
    # トラフィックログ
    <match 0系のホスト名.FRA.local0.**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.traffic.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # 脅威ログ
    <match 0系のホスト名.FRA.local1.**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.threat.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # URLフィルタリングログ
    <match 0系のホスト名.FRA.local2.**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.url.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # HIPログ
    <match 0系のホスト名.FRA.local3.**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.hip.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # GlobalProtectログ
    <match 0系のホスト名.FRA.local4.**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.gplog.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # その他ログ
    <match 0系のホスト名.FRA**>
      @type file
      path /var/log/FRA/FRA.0系のホスト名.others.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # 1系
    # トラフィックログ
    <match 1系のホスト名.FRA.local0.**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.traffic.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # 脅威ログ
    <match 1系のホスト名.FRA.local1.**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.threat.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # URLフィルタリングログ
    <match 1系のホスト名.FRA.local2.**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.url.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # HIPログ
    <match 1系のホスト名.FRA.local3.**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.hip.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # GlobalProtectログ
    <match 1系のホスト名.FRA.local4.**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.gplog.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
    # その他ログ
    <match 1系のホスト名.FRA**>
      @type file
      path /var/log/FRA/FRA.1系のホスト名.others.*.log
      append true
      <buffer>
        timekey       1d       # 1day
        timekey_wait 10m       # 10mins deley for flush
        timekey_use_utc false  # local
      </buffer>
    </match>
    
  4. 以下のコマンドを実行し、エラーが表示されないことおよびサービスの状態が「active(running)」であることを確認します。
    # systemctl enable td-agent.service
    # systemctl start td-agent.service
    # systemctl status td-agent.service