The basic configuration of Docker + Fluentd + MongoDB was completed in the previous article, "Using the MongoDB storage Docker log." However, in the actual use of the process, but found that Docker generated logs are not immediately written to the MongoDB, there are about 1 minutes of delay.
Consult the FLUENTD documentation to learn that there is a flush parameter that controls the write frequency of the log, and the default is 60s. Changing the Flush_interval parameter can increase the write frequency, as follows:
# # Match tag=docker.* and dump to console
<match docker.*>
@type MONGO
host 127.0.0.1
Port 22017< C4/>database Docker
Collection log
<buffer>
flush_mode interval flush_interval
1s
</ Buffer>
</match>
Just beginning to understand the document is not very thorough, increased the flush_interval parameters, and did not play a role, the first time the change, did not put Flush_mode and flush_interval in the buffer structure. Is
# # Match tag=docker.* and dump to console
<match docker.*>
@type MONGO
host 127.0.0.1
Port 22017
Database Docker
collection log
flush_mode interval
flush_interval 1s
</match>
The above configuration can also be seen from the log and does not work:
2018-01-19 14:33:32 +0800 [warn]: Parameter ' **flush_mode** ' in <match docker.*>
@type MONGO
Host " 1270.0.0.1 "
Port 22017
database" Docker "
Collection" Log "
flush_mode interval
1s
buffer_chunk_limit 8m
time_key time
<inject>
time_key time
time_format%y-%m-%d%h:%m: %s.%l
</inject>
</match> is not used.
It says Flush_mode doesn't work.