Docker Splunk日志记录驱动程序-Splunk的日志有时会延迟

时间:2018-07-06 18:02:15

标签: docker logging splunk

我正在使用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主机上,来自/var/log/messages的Docker消息在日志最终发送到Splunk的同时发生:

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的日志,如果有什么我可以做的,以避免延迟。

1 个答案:

答案 0 :(得分:1)

很有可能这是Splunk Logging Driver中的错误,它没有在http.Client https://github.com/moby/moby/blob/master/daemon/logger/splunk/splunk.go#L224上设置超时,请参见https://golang.org/pkg/net/http/#Client

您可以修补它。

作为替代方案,我建议您使用我们的监视docker和转发日志https://www.outcoldsolutions.com/

的解决方案
相关问题