-
Notifications
You must be signed in to change notification settings - Fork 151
K8SPSMDB-297 support persistent logs #1936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
384b91a
5937f7e
823d89c
3550700
cf08be7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
set -e | ||
set -o xtrace | ||
|
||
export PATH="$PATH":/opt/fluent-bit/bin | ||
|
||
if [ "$1" = 'logrotate' ]; then | ||
if [[ $EUID != 1001 ]]; then | ||
Check warning on line 8 in build/logcollector/entrypoint.sh
|
||
# logrotate requires UID in /etc/passwd | ||
sed -e "s^x:1001:^x:$EUID:^" /etc/passwd >/tmp/passwd | ||
Check warning on line 10 in build/logcollector/entrypoint.sh
|
||
cat /tmp/passwd >/etc/passwd | ||
rm -rf /tmp/passwd | ||
fi | ||
exec go-cron "0 0 * * *" sh -c "logrotate -s /data/logs/logrotate.status /opt/percona/logcollector/logrotate/logrotate.conf;/usr/bin/find /data/logs/ -mtime +7 ! -name logrotate.status -delete" | ||
else | ||
if [ "$1" = 'fluent-bit' ]; then | ||
fluentbit_opt+='-c /opt/percona/logcollector/fluentbit/fluentbit.conf' | ||
Check warning on line 17 in build/logcollector/entrypoint.sh
|
||
fi | ||
|
||
exec "$@" $fluentbit_opt | ||
Check notice on line 20 in build/logcollector/entrypoint.sh
|
||
fi |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this? if yes, we need to fix the typo in the file name |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@INCLUDE fluentbit_*.conf | ||
@INCLUDE custom/*.conf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[SERVICE] | ||
Flush 1 | ||
Log_Level error | ||
Daemon off | ||
|
||
[INPUT] | ||
Name tail | ||
Path ${LOG_DATA_DIR}/mongod.log | ||
Tag ${POD_NAMESPACE}.${POD_NAME}.mongod.log | ||
Refresh_Interval 5 | ||
DB /tmp/flb_kube.db | ||
read_from_head true | ||
Path_Key file | ||
|
||
[OUTPUT] | ||
Name stdout | ||
Match * | ||
Format json_lines | ||
json_date_key false | ||
|
||
[OUTPUT] | ||
Name file | ||
Match ${POD_NAMESPACE}.${POD_NAME}.mongod.log | ||
File mongod.full.log | ||
Path ${LOG_DATA_DIR}/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[MULTILINE_PARSER] | ||
name multiline-regex-test | ||
type regex | ||
flush_timeout 1000 | ||
# | ||
# Regex rules for multiline parsing | ||
# --------------------------------- | ||
# | ||
# configuration hints: | ||
# | ||
# - first state always has the name: start_state | ||
# - every field in the rule must be inside double quotes | ||
# | ||
# rules | state name | regex pattern | next state | ||
# ------|---------------|-------------------------------------------- | ||
rule "start_state" "/\d{2,4}\-\d{2,4}\-\d{2,4}T\d{2,4}\:\d{2,4}\:\d{2,4}\.\d{1,6}Z(.*)|\d{2,6} \d{2,4}\:\d{2,4}\:\d{2,4}(.*)/" "cont" | ||
rule "cont" "/^\D/" "cont" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/data/logs/*.log { | ||
daily | ||
minsize 10M | ||
maxsize 100M | ||
rotate 10 | ||
missingok | ||
nocompress | ||
notifempty | ||
sharedscripts | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -480,6 +480,11 @@ if [[ $originalArgOne == mongo* ]]; then | |||||
_mongod_hack_rename_arg_save_val --sslDisabledProtocols --tlsDisabledProtocols "${mongodHackedArgs[@]}" | ||||||
fi | ||||||
|
||||||
if [[ $originalArgOne == "mongod" && "${LOGCOLLECTOR_ENABLED:-}" == "true" ]]; then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [shfmt] reported by reviewdog 🐶
Suggested change
|
||||||
_mongod_hack_ensure_arg_val --logpath "/data/logs/mongod.log" "${mongodHackedArgs[@]}" | ||||||
_mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}" | ||||||
fi | ||||||
|
||||||
set -- "${mongodHackedArgs[@]}" | ||||||
|
||||||
# MongoDB 3.6+ defaults to localhost-only binding | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -743,3 +743,10 @@ spec: | |
# storageName: s3-us-west | ||
# compressionType: gzip | ||
# compressionLevel: 6 | ||
logcollector: | ||
enabled: true | ||
image: perconalab/percona-xtradb-cluster-operator:main-logcollector | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to fix this image, is this temporary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Until the new images for Fluentbit are ready, I think we should keep this as is. We can change it with a new PR once these new images are ready. |
||
resources: | ||
requests: | ||
memory: 100M | ||
cpu: 200m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shellcheck (suggestion)] reported by reviewdog 🐶