- A Cloud Guru
Install and Configure Logging Agent on Google Cloud
This lab guides you through installing the Cloud Logging agent on a Compute Engine instance, acting as an Apache web server. We install and configure the agent on the web server instance, and view application-specific logs collected.
Table of Contents
Install and Configure Logging Agent on Website Instance
Once on the Google Cloud Platform page, select Compute Engine >>VM Instances and click on the External IP and keep this tab open.
In a new browser tab, we note the logs available by clicking on the top-left three bar-menu, and select Logging >> Log Explorer(open in new tab).
Click VM Instance and note the logs under the Log Name portion.
Connect to the Compute Engine, by going back to the Compute Engine browser tab. Select SSH to enter into the Compute Engine instance. This launches a new browser tab with access to a Cloud terminal.
Once in the Compute Engine terminal, install the agent:
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
Execute the script:
sudo bash add-logging-agent-repo.sh
Update our repo:
sudo apt update
Install the logging agent:
sudo apt install google-fluentd
Install additional configurations:
sudo apt install -y google-fluentd-catch-all-config
Restart the agent:
sudo service google-fluentd restart
Ensure the agent is running:
sudo service google-fluentd status
If running, this output will contain:
Active: active (running).
Exit out of the SSH terminal with:
Generate Traffic to Our Example Website
- Generate traffic/logs to our example website by navigating back to this Compute Engine's browser tab. Refresh the page multiple times (5-10 times).
View Apache-Access and Linux Syslog Logs in Logs Viewer
- Navigate back to the Log Explorer browser tab and refresh this page.
- Click Options >> Go back to the Legacy Logs Viewer.
- Select Legacy Log Viewer. In the first dropdown menu (Audited Resources), select VM Instance >>web-agent-server.
- The All logs drop-down menu shows new log entries that are specific to our Compute Engine (apache-access, apache-error, syslog).
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.