Package: log2s3
log files managemant CLI utilitiyprepare rsyslog/docker logging/etc/docker/daemon.json{"log-driver":"syslog","log-opts":{"syslog-address":"tcp://localhost","syslog-facility":"daemon","syslog-format":"rfc5424micro","tag":"container/{{.Name}}/{{.ID}}"}}/etc/rsyslog.conf# ...
module(load="imtcp")
input(type="imtcp" port="514")
# ...
$ActionFileDefaultTemplate RSYSLOG_FileFormat

$IncludeConfig /etc/rsyslog.d/*.conf/etc/rsyslog.d/10-container.conftemplate(name="spcontainerfile" type="string" string="/var/log/container/%syslogtag:R,ERE,1,FIELD:container/([a-z0-9]*).*--end%/%$YEAR%-%$MONTH%-%$DAY%.log")
template(name="containerfile" type="string" string="/var/log/container/default/%$YEAR%-%$MONTH%-%$DAY%.log")
template(name="cmdcontainerfile" type="string" string="/var/log/container/run/%$YEAR%-%$MONTH%-%$DAY%.log")

# docker compose run
:syslogtag,contains,"-run-" ?cmdcontainerfile
& stop

# special containers
:syslogtag,startswith,"container/traefik/" ?spcontainerfile
& stop
# :syslogtag,startswith,"container/YOUR_CONTAINER_NAME/" ?spcontainerfile
# & stop

# other container logs
:syslogtag,startswith,"container/" ?containerfile
& stopinstall (pip)pip install log2s3(optional)pip install zstd lz4 Brotli pyliblzfse zopfli python-snappy python-lzo pyzpaq zlib-nglog2s3 [options]install (docker)docker pull ghcr.io/wtnb75/log2s3docker run -u $(id -u syslog):$(id -g syslog) -v /var/log/container:/var/log/container -w /w ghcr.io/wtnb75/log2s3 [options]subcommandsfiletreecompress old/large log fileslog2s3 filetree-compress --top /var/log/container --older 2d --bigger 4k --compress gzipdecompress all log fileslog2s3 filetree-compress --top /var/log/container --compress decompressremove old log fileslog2s3 filetree-delete --top /var/log/container --older 30ds3option/environment variablesoptionenv namedescription--s3-access-keyAWS_ACCESS_KEY_IDAWS Access Key--s3-secret-keyAWS_SECRET_ACCESS_KEYAWS Secret Key--s3-regionAWS_DEFAULT_REGIONAWS Region--s3-endpointAWS_ENDPOINT_URL_S3AWS Endpoint URL for S3--s3-bucketAWS_S3_BUCKETAWS S3 Bucket name--dotenvload .env for S3 client config--prefixobject key prefixmake bucketlog2s3 s3-make-bucket --s3-bucket mytestbucket123list bucketslog2s3 s3-bucketlist objectslog2s3 s3-listdulog2s3 s3-ducompress and upload to S3 object storagelog2s3 s3-put-tree --top /var/log/container --prefix $(hostname -s)/ --older 7d --compress xzremove by object key suffixlog2s3 s3-delete-by --prefix $(hostname -s)/ --suffix .gzcat/view/editlocal fileslog2s3 cat /path/to/file.gzlog2s3 less /path/to/file.xzlog2s3 vi /path/to/file.bz2s3 objectslog2s3 s3-cat path/to/file.gzlog2s3 s3-less path/to/file.xzlog2s3 s3-vi path/to/file.bz2otherscompress benchmarklog2s3 compress-benchmark /path/to/fileexamplesdocker-compose.ymlversion:'3'services:logcompress:image:ghcr.io/wtnb75/log2s3container_name:logcompressvolumes:-/var/log/container:/workuser:"107:4"# syslog:admcommand:-filetree-compress---top-/work---older-2d---newer-7d---bigger-4k---compress-gzipprofiles:-clilogstage:image:ghcr.io/wtnb75/log2s3container_name:logstagevolumes:-/var/log/container:/work:rocommand:-s3-put-tree---top-/work---older-7d---newer-14d---compress-xz---prefix-container-logs/environment:AWS_ACCESS_KEY_ID:${AWS_ACCESS_KEY}AWS_SECRET_ACCESS_KEY:${AWS_SECRET_KEY}AWS_ENDPOINT_URL_S3:${AWS_ENDPOINT_URL_S3}AWS_REGION:${AWS_REGION}AWS_S3_BUCKET:${AWS_S3_BUCKET}loggc:image:ghcr.io/wtnb75/log2s3container_name:loggcvolumes:-/var/log/container:/workuser:"107:4"# syslog:admcommand:-filetree-delete---top-/work---older-400dshell script#! /bin/shset-eu# compress oldlog2s3filetree-compress--top/var/log/container--older2d--newer7d--bigger4k--compressgzip# stage olderlog2s3s3-put-tree--top/var/log/container--older7d--newer14d--compressxz--dotenv--s3-bucketmytestbucket123--prefixcontainer-log/# remove oldestlog2s3filetree-delete--top/var/log/container--older400d