使用 Logspout 收集所有容器的

1.將所有容器的輸出路由到遠程 rsyslog 服務器

? ? ? ? 1.修改 rsyslog 配置文件/etc/rsyslog.conf, 從中找到 “# Provides UDP sysilog recepion"語句。并將該處的以下兩行配置代碼行首的“#”字符刪除(取消注釋)

[root@host1 ~]# vi /etc/rsyslog.conf
[root@host1 ~]# cat /etc/rsyslog.conf
# rsyslog configuration file# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html 
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html#### GLOBAL DIRECTIVES ##### Where to place auxiliary files
global(workDirectory="/var/lib/rsyslog")# Use default timestamp format
module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat")#### MODULES ####module(load="imuxsock"   # provides support for local system logging (e.g. via logger command)SysSock.Use="off") # Turn off message reception via local log socket; # local messages are retrieved through imjournal now.
module(load="imjournal"     # provides access to the systemd journalUsePid="system" # PID nummber is retrieved as the ID of the process the journal entry originates fromFileCreateMode="0644" # Set the access permissions for the state fileStateFile="imjournal.state") # File to store the position in the journal
#module(load="imklog") # reads kernel messages (the same are read from journald)
#module(load="immark") # provides --MARK-- message capability# Include all config files in /etc/rsyslog.d/
include(file="/etc/rsyslog.d/*.conf" mode="optional")# Provides UDP syslog reception
# for parameters see http://www.rsyslog.com/doc/imudp.html
module(load="imudp") # needs to be done just once
input(type="imudp" port="514")# Provides TCP syslog reception
# for parameters see http://www.rsyslog.com/doc/imtcp.html
#module(load="imtcp") # needs to be done just once
#input(type="imtcp" port="514")#### RULES ##### Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog# Log cron stuff
cron.*                                                  /var/log/cron# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log# ### sample forwarding rule ###
#action(type="omfwd"  
# # An on-disk queue is created for this action. If the remote host is
# # down, messages are spooled to disk and sent when it is up again.
#queue.filename="fwdRule1"       # unique name prefix for spool files
#queue.maxdiskspace="1g"         # 1gb space limit (use as much as possible)
#queue.saveonshutdown="on"       # save messages to disk on shutdown
#queue.type="LinkedList"         # run asynchronously
#action.resumeRetryCount="-1"    # infinite retries if host is down
# # Remote Logging (we use TCP for reliable delivery)
# # remote_host is: name/ip, e.g. 192.168.0.1, port optional e.g. 10514
#Target="remote_host" Port="XXX" Protocol="tcp")

? ? ? ? 2.保存該配置文件,執行 systemctl restart rsyslog 命令重啟 rsyslog, 然后檢查514端口是否
已開啟

[root@host1 ~]# systemctl restart rsyslog
[root@host1 ~]# netstat -antup | grep 514
udp        0      0 0.0.0.0:514             0.0.0.0:*                           418069/rsyslogd     
udp6       0      0 :::514                  :::*                                418069/rsyslogd  

? ? ? ? 3.啟動Logspout 容器,將日志轉發到 Docker 主機上的syslog日志系統中

[root@host1 ~]# docker run --rm --name="logspout" --volume=/var/run/docker.sock:/var/run/docker.sock 
gliderlabs/logspout syslog+udp://192.168.197.9:514
Unable to find image 'gliderlabs/logspout:latest' locally
latest: Pulling from gliderlabs/logspout
8572bc8fb8a3: Pull complete 
bd801371a862: Pull complete 
58100c398b34: Pull complete 
Digest: sha256:2d81c026e11ac67f7887029dbfd7d36ee986d946066b45c1dabd966278eb5681
Status: Downloaded newer image for gliderlabs/logspout:latest
2025/09/16 09:01:14 # logspout v3.2.14 by gliderlabs
2025/09/16 09:01:14 # adapters: udp multiline raw syslog tcp tls
2025/09/16 09:01:14 # options : 
2025/09/16 09:01:14 persist:/mnt/routes
2025/09/16 09:01:14 # jobs    : http[routes,health,logs]:80 pump routes
2025/09/16 09:01:14 # routes  :
#   ADAPTERADDRESSCONTAINERSSOURCESOPTIONS
#   syslog+udp192.168.197.9:514map[]

????????????????接下來進行實際測試。

? ? ? ? 4.打開另一個終端窗口(或者標簽頁,下同),執行tail-f/var/log/messages 命令使用 tail 工具實時監控系統日志文件/var/og/messages

[root@host1 ~]# tail -f /var/log/messages
Sep 16 17:01:14 host1 NetworkManager[1037]: <info>  [1758013274.5256] device (veth56301f4): carrier: link connected
Sep 16 17:01:14 host1 NetworkManager[1037]: <info>  [1758013274.5263] device (docker0): carrier: link connected
Sep 16 17:01:16 host1 avahi-daemon[1038]: Joining mDNS multicast group on interface veth56301f4.IPv6 with address fe80::f83d:e5ff:fed9:8a10.
Sep 16 17:01:16 host1 avahi-daemon[1038]: New relevant interface veth56301f4.IPv6 for mDNS.
Sep 16 17:01:16 host1 avahi-daemon[1038]: Registering new address record for fe80::f83d:e5ff:fed9:8a10 on veth56301f4.*.
Sep 16 17:02:24 host1 systemd-logind[1049]: New session 5 of user root.
Sep 16 17:02:24 host1 systemd[1]: Started Session 5 of User root.
Sep 16 17:02:25 host1 systemd[1]: Starting Hostname Service...
Sep 16 17:02:25 host1 systemd[1]: Started Hostname Service.
Sep 16 17:02:55 host1 systemd[1]: systemd-hostnamed.service: Deactivated successfully.

? ? ? ? 5.再打開另一個終端窗口,執行以下命令啟動一個Redis 容器

[root@host1 ~]# docker run --rm -d --name redis redis
638a1d615856362d3315b99e3d55d31ff8ac821376925c46ed88c8957fabd4b6

? ? ? ? 6.回到 tail 工具監控窗口,會發現該窗口顯示了該容器輸出的日志信息

Sep 16 17:04:56 host1 systemd[1]: Started libcontainer container 638a1d615856362d3315b99e3d55d31ff8ac821376925c46ed88c8957fabd4b6.
Sep 16 09:04:57 638a1d615856 redis[508446] Starting Redis Server
Sep 16 09:04:57 638a1d615856 redis[508446] 1:C 16 Sep 2025 09:04:57.222 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Sep 16 09:04:57 638a1d615856 redis[508446] 1:C 16 Sep 2025 09:04:57.222 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Sep 16 09:04:57 638a1d615856 redis[508446] 1:C 16 Sep 2025 09:04:57.223 * Redis version=8.2.1, bits=64, commit=00000000, modified=1, pid=1, just started
Sep 16 09:04:57 638a1d615856 redis[508446] 1:C 16 Sep 2025 09:04:57.223 * Configuration loaded
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.223 * monotonic clock: POSIX clock_gettime
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.228 * Running mode=standalone, port=6379.
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.231 * <bf> RedisBloom version 8.2.0 (Git=unknown)
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> Registering configuration options: [
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ bf-error-rate       :      0.01 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ bf-initial-size     :       100 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ bf-expansion-factor :         2 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ cf-bucket-size      :         2 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ cf-initial-size     :      1024 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ cf-max-iterations   :        20 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ cf-expansion-factor :         1 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> #011{ cf-max-expansions   :        32 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * <bf> ]
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.232 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.239 * <search> Redis version found by RedisSearch : 8.2.1 - oss
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.239 * <search> RediSearch version 8.2.1 (Git=dba8dd0)
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.239 * <search> Low level api version 1 initialized successfully
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.240 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results:  1000000, 
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.240 * <search> Initialized thread pools!
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.240 * <search> Disabled workers threadpool of size 0
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.240 * <search> Subscribe to config changes
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.240 * <search> Enabled role change notification
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.241 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.241 * <search> Register write commands
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.242 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> RedisTimeSeries version 80200, git_sha=1439d4a439ca9c063e6ef124a510abff09a5d493
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> Redis version found by RedisTimeSeries : 8.2.1 - oss
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> Registering configuration options: [
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-compaction-policy   :              }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-num-threads         :            3 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-retention-policy    :            0 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-duplicate-policy    :        block }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-chunk-size-bytes    :         4096 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-encoding            :   compressed }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-ignore-max-time-diff:            0 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> #011{ ts-ignore-max-val-diff :     0.000000 }
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> ]
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> Detected redis oss
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.243 * <timeseries> Enabled diskless replication
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.244 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.245 * <ReJSON> Created new data type 'ReJSON-RL'
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.245 * <ReJSON> version: 80200 git sha: unknown branch: unknown
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V1 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V2 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V3 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V4 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V5 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Enabled diskless replication
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Initialized shared string cache, thread safe: false.
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.246 * <search> Acquired RedisJSON_V5 API
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.247 * Server initialized
Sep 16 09:04:57 638a1d615856 redis[508446] 1:M 16 Sep 2025 09:04:57.247 * Ready to accept connections tcp
Sep 16 17:04:57 host1 kernel: docker0: port 2(veth98f6e8e) entered blocking state
Sep 16 17:04:57 host1 kernel: docker0: port 2(veth98f6e8e) entered disabled state
Sep 16 17:04:57 host1 kernel: veth98f6e8e: entered allmulticast mode
Sep 16 17:04:57 host1 kernel: veth98f6e8e: entered promiscuous mode
Sep 16 17:04:57 host1 NetworkManager[1037]: <info>  [1758013497.0074] manager: (veth98f6e8e): new Veth device (/org/freedesktop/NetworkManager/Devices/11)
Sep 16 17:04:57 host1 kernel: eth0: renamed from veth65d7b4f
Sep 16 17:04:57 host1 kernel: docker0: port 2(veth98f6e8e) entered blocking state
Sep 16 17:04:57 host1 kernel: docker0: port 2(veth98f6e8e) entered forwarding state
Sep 16 17:04:57 host1 NetworkManager[1037]: <info>  [1758013497.0394] device (veth98f6e8e): carrier: link connected
Sep 16 17:04:59 host1 avahi-daemon[1038]: Joining mDNS multicast group on interface veth98f6e8e.IPv6 with address fe80::88ee:d3ff:fee1:da20.
Sep 16 17:04:59 host1 avahi-daemon[1038]: New relevant interface veth98f6e8e.IPv6 for mDNS.
Sep 16 17:04:59 host1 avahi-daemon[1038]: Registering new address record for fe80::88ee:d3ff:fee1:da20 on veth98f6e8e.*.
Sep 16 17:05:15 host1 systemd[1]: Starting dnf makecache...
Sep 16 17:05:16 host1 dnf[516372]: CentOS Stream 9 - BaseOS (Aliyun)               5.3 kB/s | 3.9 kB     00:00
Sep 16 17:05:17 host1 dnf[516372]: CentOS Stream 9 - AppStream (Aliyun)            8.0 kB/s | 4.4 kB     00:00
Sep 16 17:05:18 host1 dnf[516372]: Docker CE Stable - x86_64                       3.8 kB/s | 2.0 kB     00:00
Sep 16 17:05:18 host1 dnf[516372]: 元數據緩存已建立。
Sep 16 17:05:18 host1 systemd[1]: dnf-makecache.service: Deactivated successfully.
Sep 16 17:05:18 host1 systemd[1]: Finished dnf makecache.
Sep 16 17:05:18 host1 systemd[1]: dnf-makecache.service: Consumed 1.607s CPU time.

????????7.切換到另一個終端窗口,使用 docker logs 命令獲取 Redis 容器的日志信息,會發現獲取的日志信息與Logspout 容器收集到的完全一致

[root@host1 ~]# docker logs redis
Starting Redis Server
1:C 16 Sep 2025 09:04:57.222 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:C 16 Sep 2025 09:04:57.222 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 16 Sep 2025 09:04:57.223 * Redis version=8.2.1, bits=64, commit=00000000, modified=1, pid=1, just started
1:C 16 Sep 2025 09:04:57.223 * Configuration loaded
1:M 16 Sep 2025 09:04:57.223 * monotonic clock: POSIX clock_gettime
1:M 16 Sep 2025 09:04:57.228 * Running mode=standalone, port=6379.
1:M 16 Sep 2025 09:04:57.231 * <bf> RedisBloom version 8.2.0 (Git=unknown)
1:M 16 Sep 2025 09:04:57.232 * <bf> Registering configuration options: [
1:M 16 Sep 2025 09:04:57.232 * <bf> { bf-error-rate       :      0.01 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { bf-initial-size     :       100 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { bf-expansion-factor :         2 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { cf-bucket-size      :         2 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { cf-initial-size     :      1024 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { cf-max-iterations   :        20 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { cf-expansion-factor :         1 }
1:M 16 Sep 2025 09:04:57.232 * <bf> { cf-max-expansions   :        32 }
1:M 16 Sep 2025 09:04:57.232 * <bf> ]
1:M 16 Sep 2025 09:04:57.232 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
1:M 16 Sep 2025 09:04:57.239 * <search> Redis version found by RedisSearch : 8.2.1 - oss
1:M 16 Sep 2025 09:04:57.239 * <search> RediSearch version 8.2.1 (Git=dba8dd0)
1:M 16 Sep 2025 09:04:57.239 * <search> Low level api version 1 initialized successfully
1:M 16 Sep 2025 09:04:57.240 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results:  1000000, 
1:M 16 Sep 2025 09:04:57.240 * <search> Initialized thread pools!
1:M 16 Sep 2025 09:04:57.240 * <search> Disabled workers threadpool of size 0
1:M 16 Sep 2025 09:04:57.240 * <search> Subscribe to config changes
1:M 16 Sep 2025 09:04:57.240 * <search> Enabled role change notification
1:M 16 Sep 2025 09:04:57.241 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
1:M 16 Sep 2025 09:04:57.241 * <search> Register write commands
1:M 16 Sep 2025 09:04:57.242 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
1:M 16 Sep 2025 09:04:57.243 * <timeseries> RedisTimeSeries version 80200, git_sha=1439d4a439ca9c063e6ef124a510abff09a5d493
1:M 16 Sep 2025 09:04:57.243 * <timeseries> Redis version found by RedisTimeSeries : 8.2.1 - oss
1:M 16 Sep 2025 09:04:57.243 * <timeseries> Registering configuration options: [
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-compaction-policy   :              }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-num-threads         :            3 }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-retention-policy    :            0 }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-duplicate-policy    :        block }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-chunk-size-bytes    :         4096 }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-encoding            :   compressed }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-ignore-max-time-diff:            0 }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> { ts-ignore-max-val-diff :     0.000000 }
1:M 16 Sep 2025 09:04:57.243 * <timeseries> ]
1:M 16 Sep 2025 09:04:57.243 * <timeseries> Detected redis oss
1:M 16 Sep 2025 09:04:57.243 * <timeseries> Enabled diskless replication
1:M 16 Sep 2025 09:04:57.244 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
1:M 16 Sep 2025 09:04:57.245 * <ReJSON> Created new data type 'ReJSON-RL'
1:M 16 Sep 2025 09:04:57.245 * <ReJSON> version: 80200 git sha: unknown branch: unknown
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V1 API
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V2 API
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V3 API
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V4 API
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Exported RedisJSON_V5 API
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Enabled diskless replication
1:M 16 Sep 2025 09:04:57.246 * <ReJSON> Initialized shared string cache, thread safe: false.
1:M 16 Sep 2025 09:04:57.246 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
1:M 16 Sep 2025 09:04:57.246 * <search> Acquired RedisJSON_V5 API
1:M 16 Sep 2025 09:04:57.247 * Server initialized
1:M 16 Sep 2025 09:04:57.247 * Ready to accept connections tcp

? ? ? ? 8.實驗完畢,停止 Redis 容器和 Logspout 容器(切換該容器運行的終端窗口,按CultC組合鍵),它們會被自動刪除。

[root@host1 ~]# docker stop redis  
redis
[root@host1 ~]# docker stop logspout
Error response from daemon: No such container: logspout
[root@host1 ~]# docker ps -a
CONTAINER ID   IMAGE                          COMMAND                   CREATED        STATUS                      PORTS                                     NAMES
96632885a463   lagoudocker/cadvisor:v0.37.0   "/usr/bin/cadvisor -…"   18 hours ago   Exited (0) 18 hours ago                                               cadvisor-stdout
62b9981bf08e   php-nginx-supervisor:v1        "/usr/bin/supervisor…"   30 hours ago   Exited (255) 27 hours ago   0.0.0.0:8080->80/tcp, [::]:8080->80/tcp   php-web-app
7ecac05c7dac   centos-with-nginx:1.0          "nginx -g 'daemon of…"   5 days ago     Exited (255) 4 days ago     0.0.0.0:8080->80/tcp, [::]:8080->80/tcp   test-nginx
0dbf7ea2178e   registry                       "/entrypoint.sh /etc…"   6 days ago     Exited (2) 39 minutes ago                                             myregistry
c8efe28b118e   busybox                        "sh"                      6 days ago     Exited (137) 6 days ago                                               stoic_raman
65a371a8cacb   httpd                          "httpd-foreground"        6 days ago     Exited (0) 6 days ago                                                 testweb
7ab5ac9bc007   ubuntu                         "/bin/bash"               6 days ago     Exited (0) 6 days ago                                                 inspiring_joliot
b97f426e8369   ubuntu                         "/bin/echo"               6 days ago     Exited (0) 6 days ago                                                 friendly_chaplygin
9ac8245b5b08   img-layers-test                "python /app/app.py"      8 days ago     Exited (0) 8 days ago                                                 crazy_kowalevski
49e91767b48d   ubuntu                         "/bin/bash"               8 days ago     Exited (0) 8 days ago                                                 frosty_lichterman
38b001022f7a   hello-world                    "/hello"                  8 days ago     Exited (0) 8 days ago                                                 intelligent_brahmagupta
[root@host1 ~]# 

2.通過 HTTP 查看 Logspout 收集的日志

? ? ? ? 1.只需讀取 HTTP數據流,即可實時查看生成的聚合日志。可以使用 Logspout 的 HTTP流模塊,實時查看由它聚合的本地日志,而不用提供日志路由的URI,如執行以下操作:

[root@host1 ~]# docker run --rm -d --name="logspout" \--volume /var/run/docker.sock:/var/run/docker.sock \--publish=127.0.0.1:8000:80 \gliderlabs/logspout
cfd9130ed802c6d28dd2e67f85899510016d9f423586802bc6a6d447bd727e4a

? ? ? ? 2.使用 curl 觀察容器的日志流

[root@host1 ~]# curl http://127.0.0.1:8000/logs

? ? ? ? 3.打開另一個終端窗口,執行容器操作。這里啟動 Redis 容器,切回前面的終端窗口,會發現關于 Redis 容器啟動的日志流,如下所示

[root@host1 ~]# curl http://127.0.0.1:8000/logsredis|Starting Redis Serverredis|1:C 16 Sep 2025 14:32:02.923 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.redis|1:C 16 Sep 2025 14:32:02.924 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Ooredis|1:C 16 Sep 2025 14:32:02.924 * Redis version=8.2.1, bits=64, commit=00000000, modified=1, pid=1, just startedredis|1:C 16 Sep 2025 14:32:02.924 * Configuration loadedredis|1:M 16 Sep 2025 14:32:02.925 * monotonic clock: POSIX clock_gettimeredis|1:M 16 Sep 2025 14:32:02.926 * Running mode=standalone, port=6379.redis|1:M 16 Sep 2025 14:32:02.927 * <bf> RedisBloom version 8.2.0 (Git=unknown)redis|1:M 16 Sep 2025 14:32:02.927 * <bf> Registering configuration options: [redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { bf-error-rate       :      0.01 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { bf-initial-size     :       100 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { bf-expansion-factor :         2 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { cf-bucket-size      :         2 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { cf-initial-size     :      1024 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { cf-max-iterations   :        20 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { cf-expansion-factor :         1 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> { cf-max-expansions   :        32 }redis|1:M 16 Sep 2025 14:32:02.927 * <bf> ]redis|1:M 16 Sep 2025 14:32:02.927 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.soredis|1:M 16 Sep 2025 14:32:02.932 * <search> Redis version found by RedisSearch : 8.2.1 - ossredis|1:M 16 Sep 2025 14:32:02.932 * <search> RediSearch version 8.2.1 (Git=dba8dd0)redis|1:M 16 Sep 2025 14:32:02.933 * <search> Low level api version 1 initialized successfullyredis|1:M 16 Sep 2025 14:32:02.933 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results:  1000000, redis|1:M 16 Sep 2025 14:32:02.933 * <search> Initialized thread pools!redis|1:M 16 Sep 2025 14:32:02.933 * <search> Disabled workers threadpool of size 0redis|1:M 16 Sep 2025 14:32:02.933 * <search> Subscribe to config changesredis|1:M 16 Sep 2025 14:32:02.933 * <search> Enabled role change notificationredis|1:M 16 Sep 2025 14:32:02.933 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0msredis|1:M 16 Sep 2025 14:32:02.933 * <search> Register write commandsredis|1:M 16 Sep 2025 14:32:02.933 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.soredis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> RedisTimeSeries version 80200, git_sha=1439d4a439ca9c063e6ef124a510abff09a5d493redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> Redis version found by RedisTimeSeries : 8.2.1 - ossredis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> Registering configuration options: [redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-compaction-policy   :              }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-num-threads         :            3 }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-retention-policy    :            0 }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-duplicate-policy    :        block }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-chunk-size-bytes    :         4096 }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-encoding            :   compressed }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-ignore-max-time-diff:            0 }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> { ts-ignore-max-val-diff :     0.000000 }redis|1:M 16 Sep 2025 14:32:02.934 * <timeseries> ]redis|1:M 16 Sep 2025 14:32:02.935 * <timeseries> Detected redis ossredis|1:M 16 Sep 2025 14:32:02.935 * <timeseries> Enabled diskless replicationredis|1:M 16 Sep 2025 14:32:02.935 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.soredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Created new data type 'ReJSON-RL'redis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> version: 80200 git sha: unknown branch: unknownredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Exported RedisJSON_V1 APIredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Exported RedisJSON_V2 APIredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Exported RedisJSON_V3 APIredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Exported RedisJSON_V4 APIredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Exported RedisJSON_V5 APIredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Enabled diskless replicationredis|1:M 16 Sep 2025 14:32:02.936 * <ReJSON> Initialized shared string cache, thread safe: false.redis|1:M 16 Sep 2025 14:32:02.936 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.soredis|1:M 16 Sep 2025 14:32:02.936 * <search> Acquired RedisJSON_V5 APIredis|1:M 16 Sep 2025 14:32:02.937 * Server initializedredis|1:M 16 Sep 2025 14:32:02.937 * Ready to accept connections tcp
[root@host1 ~]# curl http://127.0.0.1:8000/logsredis|1:signal-handler (1758033244) Received SIGTERM scheduling shutdown...redis|1:M 16 Sep 2025 14:34:04.256 * User requested shutdown...redis|1:M 16 Sep 2025 14:34:04.256 * Saving the final RDB snapshot before exiting.redis|1:M 16 Sep 2025 14:34:04.259 * DB saved on diskredis|1:M 16 Sep 2025 14:34:04.259 # Redis is now ready to exit, bye bye...
^C

????????如果收集到多個容器的日志,則將以不同顏色顯示不同容器的日志。

? ? ? ? 4.實驗完畢,停止Redis 容器和 Logspout容器,它們會被自動刪除。

[root@host1 ~]# docker stop redis
redis

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/97989.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/97989.shtml
英文地址,請注明出處:http://en.pswp.cn/web/97989.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【智能化解決方案】基于多目標優化檢索增強生成的智能行程規劃方案

&#x1f4dd; 基于多目標優化的智能行程規劃方案 1 用戶需求分析與矩陣構建 1.1 核心用戶信息提取 根據用戶提供的年齡、出發地、目的地、出行時間等基本信息&#xff0c;我們首先構建一個用戶特征向量&#xff1a; U {Age, Origin, Destination, TravelDate, Duration, Budg…

軟件研發的演變

軟件研發從一門手工作坊式的藝術&#xff0c;逐步演進為一門系統化、工程化、智能化的現代學科。其發展歷程不僅體現了技術的飛躍&#xff0c;更反映了方法論、協作模式和思維方式的深刻變革。一、發展演變歷程軟件研發的演變可以大致劃分為以下幾個階段&#xff1a;1. 軟件作坊…

「日拱一碼」091 機器學習——集成學習

目錄 集成學習介紹 1. 核心思想 2. 為什么有效&#xff1f; 3. 主要流派與方法 A. 并行方法&#xff1a;Bagging (Bootstrap Aggregating) B. 串行方法&#xff1a;Boosting C. 堆疊法&#xff1a;Stacking 代碼示例 Bagging 的代表 —— 隨機森林 (Random Forest) 集成…

vscode實現第三方包的使用,cmake結合vcpkg(跨平臺)

要使用cmake和vcpkg組織一個完整的現代cpp項目&#xff0c;一般來說需要三個文件vcpkg.json描述第三方依賴項//vcpkg.json {"dependencies": ["fmt"] }//安裝,在vcpkg.json目錄執行 vcpkg installCMakePresets.json定義項目的本質屬性&#xff08;What&…

DevExpress中Word Processing Document API學習記錄

文章目錄1 文檔結構劃分2 文檔操作基礎2.1 Positions and Ranges2.2 Secitions2.3 Paragraphs2.4 Tables2.5 Lists2.6 Hyperlinks and Bookmarks2.7 Comments2.8 Headers and Footers2.9 Shapes and Pictures2.10 Watermarks2.11 Charts2.12 OLE Objects2.13 ActiveX Controls2…

Roo Code 的差異_快速編輯功能

什么是差異編輯&#xff1f; 簡單來說&#xff0c;差異編輯就像是一位細心的裝修師傅&#xff1a;他不會把整個房子拆掉重蓋&#xff0c;而是精準地只修補需要改動的部分。Roo Code 的這項功能默認開啟&#xff0c;它通過比對代碼差異&#xff08;diff&#xff09;來實施修改&a…

【Axure高保真原型】標簽樹分類查詢案例

今天和大家分享標簽樹分類查詢案例的原型模版&#xff0c;效果包括&#xff1a; 樹形分類——點擊左側樹形里的箭頭&#xff0c;可以展開或收起子級選項&#xff1b; 查詢表格——點擊標簽樹里的選項&#xff0c;如果是末級選項&#xff0c;可以篩選右側表格用戶標簽&#xf…

容器化部署項目05

一、工作原理 鏡像&#xff1a;容器的模板&#xff0c;包括容器運行時所需的數據 容器&#xff1a;運行中的進程&#xff0c;依賴鏡像運行&#xff0c;鏡像的具現化 鏡像你可以把它看成Python中的類&#xff0c;而容器可以看做是類的實例化對象。 一個類可以有多個對象&#xf…

微信小程序 工作日歷 周計劃日報 修改等提報和狀態展示功能,支持h5,Android ,ios,基于uniapp,適配vue2和vue3

Work-calendar 介紹 &#xff08;底部附鏈接&#xff09; 基于uni-calendar做的定制化開發&#xff0c;主要功能為工作日歷展示和提報組件 ? 1.支持周計劃日報狀態展示且可配置 ? 2.支持農歷展示配置&#xff0c;回到當日&#xff0c;月份切換 ? 3.日歷&#xff0c;周報…

openharmony 鴻蒙 下 利用藍牙API(a2dp模塊-高級音頻,ble模塊-低功耗藍牙等)完成對藍牙音響的控制(藍牙廣播)

1.首先是登錄頁面&#xff08;利用webapi 和本地數據存儲完成登陸操作&#xff09; 2.添加設備&#xff08;利用ble.startBLEScan 和 ble.on("BLEDeviceFind", onReceiveEvent);完成藍牙掃描與顯示&#xff09; 3.藍牙ble連接&#xff08;利用ble.createGattClientDe…

17、邏輯回歸與分類評估 - 從連續到離散的智能判斷

學習目標:理解分類問題的本質和評估方法,掌握邏輯回歸的數學原理和概率解釋,學會二分類和多分類問題的處理方法,熟練使用分類評估指標,理解過擬合和正則化的基本概念。 > 從第16章到第17章:從預測數值到判斷類別 在第16章中,我們學習了線性回歸,解決的是預測連續數…

自動化腳本的核心引擎

自動化腳本作為現代軟件開發與運維的重要工具&#xff0c;其核心引擎承擔著解析指令、調度任務和執行邏輯的關鍵職能。這種引擎本質上是一個輕量級的運行時環境&#xff0c;通過預定義的規則集將人類可讀的腳本語言轉化為機器可執行的原子操作。在持續集成/持續交付&#xff08…

【Vue2 ?】Vue2 入門之旅 · 進階篇(九):Vue2 性能優化

在前幾篇文章中&#xff0c;我們學習了 Vuex 的內部機制以及 Vue Router 的工作原理。本篇將深入探討 Vue2 性能優化&#xff0c;幫助你掌握在開發中提升 Vue 應用性能的方法和技巧。 目錄 性能優化的意義響應式系統優化虛擬 DOM 與渲染優化組件懶加載與按需渲染事件與計算屬性…

【題解】B2600 【深基1.例2】簡單的分蘋果

題目描述 這里有 101010 個蘋果&#xff0c;小 A 拿走了 222 個&#xff0c;Uim 拿走了 444 個&#xff0c;八尾勇拿走剩下的所有的蘋果。我們想知道&#xff1a; 小A 和 Uim 兩個人一共拿走多少蘋果&#xff1f;八尾勇能拿走多少蘋果&#xff1f; 現在需要編寫一個程序&#x…

中小企業 4G 專網部署:性能與成本的最佳平衡

在數字化轉型的浪潮中&#xff0c;中小企業同樣需要安全、穩定和高效的通信網絡。然而&#xff0c;傳統專網的高成本和復雜部署往往成為阻礙。IPLOOK 提供的4G輕量級核心網與專網解決方案&#xff0c;正是幫助中小企業在性能與成本之間找到最佳平衡的關鍵。 中小企業的網絡挑…

LeetCode每日一題,20250914

元音拼寫檢查器 思路 精確匹配 用 HashSet 保存原始單詞&#xff0c;查詢時直接判斷是否存在。 大小寫忽略匹配 用 HashMap<String, String> 保存 小寫單詞 -> 第一次出現的原始單詞。用 putIfAbsent&#xff0c;確保只記錄第一次出現的單詞。 元音模糊匹配 把單詞…

i2s_record_play

這章主要講述i2s 1&#xff1a;環境及配件 esp32c3 esp32s3 idf5.4.1 INMP441 MAX98357A 都使用dma 2&#xff1a;eps32c3 測試 只有1個i2s 只能一邊錄 完 再播放 &#xff0c;內存太小&#xff0c;這里用 flash 存audio里 只說能 錄音 能播放 &#xff0c;效果不好&#xff0…

Spring Boot 3 + EasyExcel 文件導入導出實現

SpringBoot集成EasyExcel 3.x&#xff1a;高效實現Excel數據的優雅導入與導出 在現代企業應用中&#xff0c;Excel作為數據交換的重要工具&#xff0c;幾乎無處不在。如何高效且優雅地實現Excel數據的導入與導出&#xff0c;是每個開發者都需要面對的問題。EasyExcel是阿里巴巴…

Ruby編程實踐:20個實用練習

1、編寫一個程序,計算一年有多少小時。 以下是兩種實現方式的代碼: 方式一: puts 24*365方式二: puts 24*365 puts "(or #{24*366} on a leap year)"2、編寫一個程序,計算十年中有多少分鐘。 以下兩種實現方式: 簡單計算(未考慮閏年數量差異): ru…

邏輯回歸(二):從原理到實戰 - 訓練、評估與應用指南

引言&#xff1a; 上期我們講了什么是邏輯回歸&#xff0c;了解了它如何利用Sigmoid函數將線性回歸的輸出轉化為概率&#xff0c;并通過最大似然估計來尋找最佳參數。今天&#xff0c;我們將繼續這段旅程&#xff0c;學習如何訓練這個 模型、如何評估它的表現&#xff0c;以及如…