This guide describes how to send user definitive logs that uses in Hive Analytics v2 via fluentd.
Fluentd Install
– We recommend installing the td–agent version 1.x.
– The td–agent libraries are provided for each languages. (https://docs.fluentd.org/language-bindings)
Installing td–agent
- http://docs.fluentd.org/articles/install-by-rpm
1$ curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh - Edit the td–agent settings file
1$ vim /etc/td-agent/td-agent.conf
Fluentd Default Settings
- Log file: The default path of log file is
/var/log/td-agent
, and the td–agent.log file is located the sub folder. - Event: Event in fluentd means record and log.
- <source>: <source> enables to receive various
input
and many plugins are able to use by using @ type. - <match>: It handles the
input
event that sent via <source>.
Fluentd Plugin
- Check and install the plugin: Install the plugin you need after checking the list of plugins.
(The plugins such astail
,forward
andstdout
are provided in default, but others likeforest
need to be install separately.)12345$ td-agent-gem list #Check the list of plugin# Available to install a plugin as the formatted td-agent-gem install [plugin you want]$ td-agent-gem install fluent-plugin-forest # Install the fluent-plugin-forest plugin - tag: Tag is a value that consists of Event, and the
<match>
section handles the value matched with tag.123456789101112# Usage example for tag<source>@type tailtag ha2union.game.com2us # Attached this tag to an event that sent using in_tailpath /var/log/sample.log</source># An input event transferred through sources is sent to a match tag mapped with an event tag.<match ha2union.game.com2us>@type stdout<match>
[Input Plugin]
- in_tail: The in_tail plugin reads data by using the
tail
command.
1234567<source>@type tailpath /var/log/com2us.log # Reading path such as filespos_file /var/log/fluent/com2us_posfile.log.pos # Records the last reading parttag ha2union.game.com2us # Event tag. Attached the tag to the sending event.</source># pos_file: When re-executing fluentd, handle the file from the last reading part. - in_forward: Generally, it is used for receiving the data from other fluentd nodes.
12345<source>@type forwardport 24224 # Port to send ( default : 24224 )bind 0.0.0.0 # Bind address to send ( default : 0.0.0.0(all of address))</source>
[Output Plugin]
The output plugin defined in the <match> section defines the settings for buffering and flushing as the <buffer> sub section of the <match> section.
- output_stdout: Exports event logs with
stdout
and mainly uses for debugging.
123<match **>@type stdout</match> - output_forward: Uses when sending event logs to other fluentd nodes.
123456789101112131415<match **>@type forward<server>name com2us.fluentd1host [Server1's IP or domain for receiving]port 24224weight 50 # Set up the load balancing weight in the <server> section</server><server>name com2us.fluentd2host [Server2's IP or domain for receiving]port 24224weight 50 # Set up the load balancing weight in the <server> section</server></match> - fluent–plugin–forest : Enables to save the log files using a tag name. (By setting as below, logs can be saved in local.)
1234567891011<store>@type forestsubtype file<template>time_slice_format %Y%m%d%Htime_slice_wait 10spath /com2us/log/td-agent/data/${tag}/${tag}.*.logcompress gzformat json</template></store>
Usage examples of fluentd
Using fluentd enables to send logs with the methods as below. For more details, click the links below.
Edit settings
- Check the td–agent.conf context
1$ td-agent -c /etc/td-agent/td-agent.conf - Re-start td–agent
1$ service td-agent restart