You can customize the Logging agent to send additional logs to Logging by adding input configurations. The detailed instructions can be found here.
From the Linux command prompt, create a log file:
touch /tmp/test-unstructured-log.log
Create a new configuration file labeled test-unstructured-log.conf
in the additional configuration directory /etc/google-fluentd/config.d
:
sudo tee /etc/google-fluentd/config.d/test-unstructured-log.conf <<EOF
<source>
@type tail
<parse>
# 'none' indicates the log is unstructured (text).
@type none
</parse>
# The path of the log file.
path /tmp/test-unstructured-log.log
# The path of the position file that records where in the log file
# we have processed already. This is useful when the agent
# restarts.
pos_file /var/lib/google-fluentd/pos/test-unstructured-log.pos
read_from_head true
# The log tag for this log input.
tag unstructured-log
</source>
EOF
Restart the agent to apply the configuration changes:
sudo service google-fluentd restart
Generate a log record into the log file:
echo 'This is a log from the log file at test-unstructured-log.log' >> /tmp/test-unstructured-log.log
Check the Logs Explorer to see the ingested log entry:
{
insertId: "eps2n7g1hq99qp"
labels: {
compute.googleapis.com/resource_name: "add-unstructured-log-resource"
}
logName: "projects/my-sample-project-12345/logs/unstructured-log"
receiveTimestamp: "2018-03-21T01:47:11.475065313Z"
resource: {
labels: {
instance_id: "3914079432219560274"
project_id: "my-sample-project-12345"
zone: "us-central1-c"
}
type: "gce_instance"
}
textPayload: "This is a log from the log file at test-unstructured-log.log"
timestamp: "2018-03-21T01:47:05.051902169Z"
}