Skip to content

Commit 31f0a2d

Browse files
committed
fix: fluent-bit gce-startup.log filter & lua
1 parent aa723cd commit 31f0a2d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

transition/terraform/dev/scripts/gce-startup.tpl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ sudo tee /etc/td-agent-bit/td-agent-bit.conf > /dev/null <<EOF
4343
[FILTER]
4444
Name grep
4545
Match startup.log
46-
Regex message startup-script
46+
Regex log .*startup%-script.*
47+
48+
[FILTER]
49+
Name lua
50+
Match startup.log
51+
script /etc/td-agent-bit/trim_log.lua
52+
call trim
4753
4854
[OUTPUT]
4955
Name cloudwatch_logs
@@ -70,6 +76,17 @@ sudo tee /etc/td-agent-bit/td-agent-bit.conf > /dev/null <<EOF
7076
auto_create_group true
7177
EOF
7278

79+
sudo tee /etc/td-agent-bit/trim_log.lua > /dev/null <<'EOF'
80+
function trim(tag, timestamp, record)
81+
local raw = record["log"]
82+
local trimmed = string.match(raw, "startup%-script: (.*)")
83+
if trimmed then
84+
record["log"] = trimmed
85+
end
86+
return 1, timestamp, record
87+
end
88+
EOF
89+
7390
sudo mkdir -p /etc/systemd/system/td-agent-bit.service.d
7491
sudo tee /etc/systemd/system/td-agent-bit.service.d/aws-creds.conf > /dev/null <<EOF
7592
[Service]

0 commit comments

Comments
 (0)