Skip to content

Commit 2d8c246

Browse files
Rob PercivalRJPercival
authored andcommitted
Configure google-fluentd correctly for ct-mirror
Previously, collection of logs was only correctly configured for ct-server.
1 parent 3235c10 commit 2d8c246

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

cloud/google/node_init.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,52 @@ if ! echo "${EXPECTED_SHA256}" | sha256sum --quiet -c; then
3939
exit 1
4040
fi
4141

42-
# TODO(robpercival): For CT mirrors, the path below should be "/data/ctmirror/",
43-
# not "/data/ctlog/".
4442
sudo bash ./${AGENT_INSTALL_SCRIPT}
45-
sudo cat > /etc/google-fluentd/config.d/ct-info.conf <<EOF
43+
44+
# Examine what kind of Docker image is on this machine to determine what to log.
45+
if docker images | grep ct-server; then
46+
CT_LOGS_PREFIX="${DATA_DIR}/ctlog/logs/ct-server"
47+
elif docker images | grep ct-mirror; then
48+
CT_LOGS_PREFIX="${DATA_DIR}/ctmirror/logs/ct-mirror"
49+
fi
50+
51+
if [[ -n "${CT_LOGS_PREFIX}" ]]; then
52+
sudo cat > /etc/google-fluentd/config.d/ct-info.conf <<EOF
4653
<source>
4754
type tail
4855
format none
49-
path /data/ctlog/logs/ct-server.*.INFO.*
50-
pos_file /data/ctlog/logs/ct-server.INFO.pos
56+
path ${CT_LOGS_PREFIX}.*.INFO.*
57+
pos_file ${CT_LOGS_PREFIX}.INFO.pos
5158
read_from_head true
5259
tag ct-info
5360
</source>
5461
<source>
5562
type tail
5663
format none
57-
path /data/ctlog/logs/ct-server.*.ERROR.*
58-
pos_file /data/ctlog/logs/ct-server.ERROR.pos
64+
path ${CT_LOGS_PREFIX}.*.ERROR.*
65+
pos_file ${CT_LOGS_PREFIX}.ERROR.pos
5966
read_from_head true
6067
tag ct-warn
6168
</source>
6269
<source>
6370
type tail
6471
format none
65-
path /data/ctlog/logs/ct-server.*.WARNING.*
66-
pos_file /data/ctlog/logs/ct-server.WARNING.pos
72+
path ${CT_LOGS_PREFIX}.*.WARNING.*
73+
pos_file ${CT_LOGS_PREFIX}.WARNING.pos
6774
read_from_head true
6875
tag ct-warn
6976
</source>
7077
<source>
7178
type tail
7279
format none
73-
path /data/ctlog/logs/ct-server.*.FATAL.*
74-
pos_file /data/ctlog/logs/ct-server.FATAL.pos
80+
path ${CT_LOGS_PREFIX}.*.FATAL.*
81+
pos_file ${CT_LOGS_PREFIX}.FATAL.pos
7582
read_from_head true
7683
tag ct-error
7784
</source>
7885
EOF
79-
sudo service google-fluentd restart
86+
sudo service google-fluentd restart
87+
fi
8088
# End google-fluentd stuff
8189

8290
cat > /etc/logrotate.d/docker <<EOF

0 commit comments

Comments
 (0)