【发布时间】:2022-07-15 19:21:20
【问题描述】:
我有 2 个 ec2 实例 可用区 a 中的第一个实例,可用区 b 中的第二个实例 第一个实例必须将日志转发到第二个实例,但我有一个错误
2022-01-10 20:15:42 +0000 [warn]: detached forwarding server '3.12.161.218:24224' host="3.12.161.218" port=24224 phi=16.01073005960133
3.12.161.218 - 公共 IP 我在配置中尝试了私有 ip
2022-01-10 20:20:25 +0000 [warn]: detached forwarding server '172.31.13.116:24224' host="172.31.13.116" port=24224 phi=16.39846510698621
但是还是不行
我的配置第一个实例(前锋):
<match td.*.*>
@type tdlog
apikey YOUR_API_KEY
auto_create_table
buffer_type file
buffer_path /var/log/td-agent/buffer/td
<secondary>
@type file
path /var/log/td-agent/failed_records
</secondary>
</match>
## match tag=debug.** and dump to console
<match debug.**>
@type stdout
</match>
## built-in TCP input
## @see http://docs.fluentd.org/articles/in_forward
<source>
@type forward
port 24224
</source>
<source>
@type http
port 8888
</source>
## live debugging agent
<source>
@type debug_agent
bind 127.0.0.1
port 24230
</source>
<source>
@type tail
path /var/log/myapp.log
pos_file /var/log/td-agent/myorg.log.pos
tag myorg.myapp
format /^(?<level>[^ ]*)[ \t]+\[(?<time>[^\]]*)\] \[(?<thread>[^\]]*)\] \[(?<request>[^\]]*)\] (?<class>[^ ]*): (?<message>.*)$/
time_format %Y-%m-%d %H:%M:%S,%L %z
timezone +0530
time_key time
keep_time_key true
types time:time
</source>
<match myorg.**>
@type copy
<store>
@type file
path /var/log/td-agent/forward.log
</store>
<store>
@type forward
heartbeat_type tcp
#aggregator IP
host 172.31.13.116
flush_interval 30s
</store>
</match>
聚合器也有问题,它必须将数据传输到 aws 弹性搜索云 配置聚合器:
<source>
@type forward
port 24224
</source>
<match myorg.**>
@type copy
<store>
@type file
path /var/log/td-agent/forward.log
</store>
<store>
@type elasticsearch_dynamic
#elasticsearch host IP/domain
host ec2-3-13-147-36.us-east-2.compute.amazonaws.com
port 9200
index_name fluentd-${tag_parts[1]+ "-" + Time.at(time).getlocal("+05:30").strftime(@logstash_dateformat)}
#logstash_format true
#logstash_prefix fluentd
time_format %Y-%m-%dT%H:%M:%S
#timezone +0530
include_timestamp true
flush_interval 10s
</store>
</match>
我不明白如何建立连接以确保一切正常
【问题讨论】:
-
看起来
tag中缺少source来路由事件。见docs.fluentd.org/input/forward#tag。例如,在聚合器中,在source下添加tag myorg.**,然后对其进行测试。此外,这会有所帮助:docs.fluentd.org/quickstart/life-of-a-fluentd-event. -
可以开启td-agent的调试吗?另外,您是否在实例 b 上打开了端口 24224?首先尝试从服务器 a 远程登录到端口 24224 上。
标签: amazon-web-services amazon-ec2 fluentd aws-elasticsearch