Skip to content

Commit

Permalink
Release 7.7.5 - See CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tiredofit committed Aug 11, 2022
1 parent 51119e6 commit 29ab5a1
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 7.7.5 2022-08-11 <dave at tiredofit dot ca>

### Added
- Fluent-bit 1.9.7
- Customizable compssion types for logrotate, now defaults to using zstd
- Function for zcat to handle bz/xz/gz/zst

### Changed
- Fix error when CRON_PERIOD exists as a default or environment variable


## 7.7.4 2022-08-06 <dave at tiredofit dot ca>

### Added
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,15 @@ This image supports autoregistering configuration as an Active Agent to a Zabbix

This is work in progress for a larger logging solution. Presently there is functionality to rotate logs on a daily basis, however as this section matures there will be the capability to also ship the logs to an external data warehouse like Loki, or Elastic Search. At present Log shipping is only supported by `fluent-bit` and x86_64 only.

| Parameter | Description | Default |
| ------------------------------- | ---------------------------------------- | ------------ |
| `CONTAINER_ENABLE_LOGROTATE` | Enable Logrotate (if scheduling enabled) | `TRUE` |
| `CONTAINER_ENABLE_LOGSHIPPING` | Enable Log Shipping | `FALSE` |
| `CONTAINER_LOGSHIPPING_BACKEND` | Log shipping backend `fluent-bit` | `fluent-bit` |
| `LOGROTATE_RETAIN_DAYS` | Rotate and retain logs for x days | `7` |
| Parameter | Description | Default |
| ---------------------------------------- | ----------------------------------------------------------- | ------------ |
| `CONTAINER_ENABLE_LOGROTATE` | Enable Logrotate (if scheduling enabled) | `TRUE` |
| `CONTAINER_ENABLE_LOGSHIPPING` | Enable Log Shipping | `FALSE` |
| `CONTAINER_LOGSHIPPING_BACKEND` | Log shipping backend `fluent-bit` | `fluent-bit` |
| `LOGROTATE_COMPRESSION_TYPE` | Logfile compression algorithm `NONE` `BZIP2` `GZIP` `ZSTD` | `ZSTD` |
| `LOGROTATE_COMPRESSION_VALUE` | What level of compression to use | `8` |
| `LOGROTATE_COMPRESSION_EXTRA_PARAMETERS` | Pass extra parameters to the compression command (optional) | |
| `LOGROTATE_RETAIN_DAYS` | Rotate and retain logs for x days | `7` |

##### Log Shipping Parsing

Expand Down
9 changes: 8 additions & 1 deletion install/assets/defaults/05-logging
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,12 @@ FLUENTBIT_TAIL_KEY_PATH_ENABLE=${FLUENTBIT_TAIL_KEY_PATH_ENABLE:-"TRUE"}
FLUENTBIT_TAIL_KEY_PATH=${FLUENTBIT_TAIL_KEY_PATH:-"filename"}
FLUENTBIT_TAIL_KEY_OFFSET_ENABLE=${FLUENTBIT_TAIL_KEY_OFFSET_ENABLE:-"FALSE"}
FLUENTBIT_TAIL_KEY_OFFSET=${FLUENTBIT_TAIL_KEY_OFFSET:-"offset"}

case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in
"3.5" ) LOGROTATE_COMPRESSION_TYPE="gzip" ;;
*) LOGROTATE_COMPRESSION_TYPE=${LOGROTATE_COMPRESSION_TYPE:-"zstd"} ;;
esac

LOGROTATE_COMPRESSION_VALUE=${LOGROTATE_COMPRESSION_VALUE:-"8"}
LOGROTATE_RETAIN_DAYS=${LOGROTATE_RETAIN_DAYS:-"7"}
LOGSHIPPING_AUTO_CONFIG_LOGROTATE=${LOGSHIPPING_AUTO_CONFIG_LOGROTATE:-"TRUE"}
LOGSHIPPING_AUTO_CONFIG_LOGROTATE=${LOGSHIPPING_AUTO_CONFIG_LOGROTATE:-"TRUE"}
6 changes: 0 additions & 6 deletions install/assets/functions/00-container
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,7 @@ create_logrotate() {
cat <<EOF > /assets/logrotate/"${1}"
${lrlsparser}
$2 {
daily
ifempty
rotate ${LOGROTATE_RETAIN_DAYS}
missingok
compress
dateext
copytruncate
${lruser}
}
EOF
Expand Down
16 changes: 16 additions & 0 deletions install/etc/cont-init.d/00-startup
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ fi

echo "export PS1=\"${bash_prompt/ /}\"" >> /root/.bashrc

cat <<EOF >> /root/.bashrc

zcat () {
if [ -f "\$@" ] ; then
case "\$@" in
*.zst* ) $(which zstdcat) "\$@" ;;
*.bz*) $(which zcat) "\$@" ;;
*.gz*) $(which zcat) "\$@" ;;
*.xz) $(which zcat) "\$@" ;;
esac
else
echo "'\$@' is not a valid file!"
fi
}
EOF

## Add Support to list all Changelogs known of all base images
if [ -d "/assets/.changelogs" ] ; then
echo "image_version() { for clname in /assets/.changelogs/* ; do version=\$(head -n 1 \$clname | awk '{print \$2}') ; echo \"Image: $(basename \$clname) \$version\" ; done ;}" >> /root/.bashrc
Expand Down
5 changes: 3 additions & 2 deletions install/etc/cont-init.d/04-scheduling
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ else
## Docker Build and Runtime overrides
cronenv=$(mktemp)
set -o posix; set -f ; set | grep -E '^CRON_'| sed "s|CRON_||g" > ${cronenv}
sed -i "/^PERIOD/d" "${cronenv}"
while IFS= read -r cron_entry; do
schedule_title="$(echo ${cron_entry} | cut -d = -f1 | tr '[:upper:]' '[:lower:]' )"
schedule_value="$(echo ${cron_entry} | cut -d = -f2 )"
Expand Down Expand Up @@ -67,12 +68,12 @@ EOF
# shellcheck source=/assets/defaults/
source $d
cronenv=$(mktemp)
set -o posix; set -f ; set | grep -E '^CRON_'| sed "s|CRON_||g" > ${cronenv}
set -o posix; set -f ; set | grep -E '^CRON_'| sed "s|CRON_||g" > "${cronenv}"
sed -i "/^PERIOD/d" "${cronenv}"
while IFS= read -r cron_entry; do
schedule_title="$(echo ${cron_entry} | cut -d = -f1 | tr '[:upper:]' '[:lower:]')"
schedule_value="$(echo ${cron_entry} | cut -d = -f2 )"
schedule_value="$(echo ${schedule_value:1:-1})"

if [ ! -f "${CONTAINER_SCHEDULING_LOCATION}/${schedule_title,,}" ] ; then
print_debug "Adding $schedule_title with value $schedule_value to crontab"
cat <<EOF > "${CONTAINER_SCHEDULING_LOCATION}/${schedule_title,,}"
Expand Down
45 changes: 45 additions & 0 deletions install/etc/cont-init.d/05-logging
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@ output_off

if var_true "${CONTAINER_ENABLE_LOGROTATE}" ; then
print_debug "Enabling log rotation"
case "${LOGROTATE_COMPRESSION_TYPE,,}" in
bz* )
logrotate_compression=$(cat<<EOF
compress
compresscmd $(which bzip2)
compressext .bz2
compressoptions -${LOGROTATE_COMPRESSION_VALUE} ${LOGROTATE_COMPRESSION_EXTRA_PARAMETERS}
EOF
)
;;
gz* )
logrotate_compression=$(cat<<EOF
compress
compresscmd $(which gzip)
compressext .gz
compressoptions -${LOGROTATE_COMPRESSION_VALUE} ${LOGROTATE_COMPRESSION_EXTRA_PARAMETERS}
EOF
)
;;
none )
logrotate_compression=""
;;
zs* )
logrotate_compression=$(cat<<EOF
compress
compresscmd $(which zstd)
compressext .zst
compressoptions -${LOGROTATE_COMPRESSION_VALUE} ${LOGROTATE_COMPRESSION_EXTRA_PARAMETERS}
EOF
)
;;
esac

cat <<EOF > /etc/logrotate.conf
daily
rotate ${LOGROTATE_RETAIN_DAYS}
copytruncate
dateext
nomail
notifempty
${logrotate_compression}
include /etc/logrotate.d
EOF

chmod 0744 /etc/logrotate.conf
mkdir -p "${CONTAINER_SCHEDULING_LOCATION}"
cat <<EOF > "${CONTAINER_SCHEDULING_LOCATION}"/logrotate
# Hardcoded in image in /etc/cont-init.d/$(basename "$0")
Expand Down

0 comments on commit 29ab5a1

Please sign in to comment.