特定日志文件
从特定文件夹发送日志¶
示例¶
- 本地 JSON 文件中的登录示例
{
"dateTime": "2022-04-15 13:02:45",
"timezone": "GMT+09:00",
"channel": "C2S",
"source": "Web",
"serverId": "1",
"osVer": "4.3.1",
"appId": "com.gcp2.hivesdk.android.google.global.normal",
"company": "C2S",
"model": "SHW-M250S",
"lang": "ko",
"class": "sample value of class",
"os": "A",
"appVer": "1.0",
"cpu": "armeabi-v7a",
"market": "GO",
"clientIp": "127.0.0.1",
"guid": "4314nbh31211234ld",
"sdkVer": "2.0.1",
"serverIp": "127.0.0.2",
"category": "hive_login_log",
"newUser": "N",
"hiveSnsType": "FB",
"deviceName": "SM-G935",
"osVersionFixed": "9.2.1",
"serverUid": "QA-2",
"level": "7",
"isEmulator": "1"
}
- 如何在日志文件中堆叠日志
- 按照下面所示配置 td-agent.conf,您可以在日志文件中实现日志堆叠。
<source>
@type tail
path /game/sample/log/com2us.log
pos_file /var/log/td-agent/com2us_filelog.pos
tag ha2union.game.sample.com2us_log
format json
</source>
<source>
@type tail
path /game/sample/log/com2usHoldings.log
pos_file /var/log/td-agent/com2usHoldings_filelog.pos
tag ha2union.game.sample.com2usHoldings_log
format json
</source>
<source>
@type tail
path /game/sample/log/com2usPlatform.log
pos_file /var/log/td-agent/com2usPlatform_filelog.pos
tag ha2union.game.sample.com2usPlatform_log
format json
</source>
<match ha2union.** >
@type copy
@include td-agent-forest.conf # fluentd-plugin-forest
<store>
@type forward
send_timeout 60s
recover_wait 10s
heartbeat_interval 1s
#heartbeat_type tcp
transport tcp
phi_threshold 16
hard_timeout 60s
require_ack_response true # at-least-once
buffer_type file
buffer_chunk_limit 8m # 허용되는 최대 청크의 크기
buffer_queue_limit 10240 # 출력 큐의 최대길이
buffer_path /data/log/td-agent/buffer/forward.buffer
flush_interval 1s # 다음 버퍼를 호출하기 전에 대기하는 간격
<server>
name hiveanalyticslog-server-03
host analytics-hivelog-03.withhive.com
port 24224
weight 50
</server>
<server>
name hiveanalyticslog-server-04
host analytics-hivelog-04.withhive.com
port 24224
weight 50
</server>
<secondary>
@type file
path /var/log/td-agent/forward-failed # 각자 환경에 따라 변경
</secondary>
</store>
</match>
<source>
@type forward
</source>
-
secondary: 备份选项。当由于发生错误而无法使用服务器时,可以使用 secondary,并将日志备份到 path 作为文件格式。
-
缓冲插件 : 缓冲是一个块的集合。块会定期刷新到输出队列,并转移到指定目标。下图显示了操作顺序。