environment-variables - Fluentd 环境变量未在进程中提取
问题描述
我正在使用 FluentD ( td-agent3
) + Elastic Beanstalk ( ruby 2.6
)。我使用环境变量FLUENTD_HOST
来设置主机 ip,但是当我启动 Fluentd 时,主机不存在。
要启动服务,我使用:sudo systemctl start td-agent.service
.
但是,一旦服务启动,该host
字段为""
.
2020-09-30 21:34:39 +0000 [warn]: #0 detached forwarding server 'dg-fluentd-1' host="" port=24224 phi=16.030025667476114 phi_threshold=16
配置文件
# /etc/td-agent/td-agent.conf
<source>
type debug_agent
bind 127.0.0.1
port 24230
</source>
<source>
@type tail
path /var/log/secure
pos_file /var/log/td-agent/secure.log.pos
tag system.web.access
format syslog
</source>
<source>
@type tail
path /var/log/nginx/*.log
pos_file /var/log/td-agent/nginx.log.pos
tag system.web.nginx
format nginx
</source>
# ------ Destination directives
<match system.**>
@type forward
send_timeout 10s
recover_wait 10s
<server>
name dg-fluentd-1
host "#{ENV['FLUENTD_HOST']}"
port 24224
heartbeat_type tcp
</server>
<secondary>
@type file
path /var/log/td-agent/forward-failed.log
compress gzip
</secondary>
</match>
## match tag=debug.** and dump to console
<match debug.**>
type stdout
</match>
# /usr/lib/systemd/system/td-agent.service
[Unit]
Description=td-agent: Fluentd based data collector for Treasure Data
Documentation=https://docs.treasuredata.com/articles/td-agent
After=network-online.target
Wants=network-online.target
[Service]
User=root
Group=td-agent
LimitNOFILE=65536
Environment=LD_PRELOAD=/opt/td-agent/embedded/lib/libjemalloc.so
Environment=GEM_HOME=/opt/td-agent/embedded/lib/ruby/gems/2.4.0/
Environment=GEM_PATH=/opt/td-agent/embedded/lib/ruby/gems/2.4.0/
Environment=FLUENT_CONF=/etc/td-agent/td-agent.conf
Environment=FLUENT_PLUGIN=/etc/td-agent/plugin
Environment=FLUENT_SOCKET=/var/run/td-agent/td-agent.sock
Environment=TD_AGENT_LOG_FILE=/var/log/td-agent/td-agent.log
Environment=TD_AGENT_OPTIONS=
EnvironmentFile=-/etc/sysconfig/td-agent
PIDFile=/var/run/td-agent/td-agent.pid
RuntimeDirectory=td-agent
Type=forking
ExecStart=/opt/td-agent/embedded/bin/fluentd --log $TD_AGENT_LOG_FILE --daemon /var/run/td-agent/td-agent.pid $TD_AGENT_OPTIONS
ExecStop=/bin/kill -TERM ${MAINPID}
ExecReload=/bin/kill -HUP ${MAINPID}
Restart=always
TimeoutStopSec=120
[Install]
WantedBy=multi-user.targe
# /etc/sysconfig/td-agent
export FLUENTD_HOST="<my-ip>"
我试过设置Environment=TD_AGENT_OPTIONS="--use-v1-config"
,但没有选择环境变量。
我也试过更新相同的设置/etc/init.d/td-agent
,也没有运气。
任何想法或想法表示赞赏!
解决方案
推荐阅读
- python - 使用 'loc' 选择多个列
- audiokit - 我已经从源代码为 macOS Xcode 10.2 构建了库,但我无法让 MIDI 正常工作。MIDI 输入看起来不错
- firebase - 如何从firebase获取多条记录?
- java - 在 android studio 中存储凭据的更好方法是什么?
- mysql - 如何拥有一个可以独立于 azure 独立运行的完全独立的应用程序?
- android - 配置“编译”已过时,已替换为“实施”和“API”。怎么修?
- reactjs - 当 Chrome 选项卡处于非活动状态时,内存堆会增加
- python - 为什么我不能在 Alpine 3.9 Docker 容器中以 root 身份安装 py-setuptools
- xml - 如何不在 xslt 中显示列标题
- angular - 如何从 ngrx 存储中获取数据并将其更新到 Observable 变量中?