【发布时间】:2018-07-06 18:02:15
【问题描述】:
我正在使用 Splunk 日志记录驱动程序通过以下命令行将日志发送到 splunk:docker run -d -p 443:8443 --log-driver=splunk --log-opt splunk-token=REDACTED --log-opt splunk-url=https://myloghost.example.net:8088 --log-opt splunk-sourcetype=idp --log-opt splunk-index=auth_idp --log-opt splunk-insecureskipverify=1 --log-opt splunk-format=raw --log-opt splunk-gzip=true --name shib --restart always --health-cmd 'curl -k -f https://127.0.0.1:8443/idp/status || exit 1' --health-interval=2m --health-timeout=30s
容器正常运行,日志流入Splunk。一切都很好。这是在测试环境中,所以它并不总是在使用,但容器保持运行。有时,当我开始使用容器提供的服务时,不会立即将任何内容记录到 Splunk。如果我等待 10-15 分钟,日志最终会显示正确的时间戳等。
我注意到在 docker 主机上 netstat -tpn | grep -e 8088 给了我类似这样的输出:
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 947 xxx.xxx.x.xxx:49010 xxx.xxx.x.xx:8088 ESTABLISHED 12682/dockerd-curre
在 Splunk 主机上,相同的命令在 Recv-Q 和 Send-Q 列中显示为零。 Splunk 分布式管理控制台不显示在延迟时间内收到的任何事件。在 Docker 主机上,在日志最终发送到 Splunk 的同时,Docker 的/var/log/messages 中有一条消息:
Jul 6 13:14:19 idpdock0-0 dockerd-current: time="2018-07-06T13:14:19.428396282-04:00" level=error msg="Post https://myloghost.example.net:8088/services/collector/event/1.0: read tcp xxx.xxx.x.xxx:49010->xxx.xxx.x.xx:8088: read: connection timed out"
在我看来,日志驱动程序在尝试执行某些 I/O 操作时卡住了,当它最终超时时,它会再次尝试并发送日志。但是,我不知道导致它卡住的条件是什么,也不知道有什么方法可以调整超时时间。
我想知道为什么有时日志需要这么长时间才能到达 Splunk,以及我是否可以做些什么来避免延迟。
【问题讨论】: