DEVELOPER BLOG

HOME > DEVELOPER BLOG > 【Introduction to GCP】Google Cloud Platform log output - PrismScaler

【Introduction to GCP】Google Cloud Platform log output - PrismScaler

1. Introduction

Hello! We are a writer team from Definer Inc. In this issue, you are wondering about the use of log output by Google Cloud Platform. Let's take a look at the actual screens and resources to explain in detail.

2. Purpose/Use Cases

Outputting logs in Google Cloud Platform (GCP) is important for several reasons:   1. Troubleshooting and Debugging: Logs provide valuable insights into the behavior and operation of your applications and infrastructure. When issues or errors occur, logs can help you identify the root cause and troubleshoot problems more effectively.   2. Performance Monitoring: Logs allow you to monitor the performance of your applications and services. By analyzing logs, you can track response times, identify performance bottlenecks, and optimize the performance of your systems.   3. Auditing and Compliance: Logs play a crucial role in auditing and compliance requirements. They provide a record of actions and events within your environment, which can be used for regulatory compliance, security audits, and incident investigations.   4. Security and Intrusion Detection: Logs are essential for detecting security threats and monitoring for potential intrusions. By analyzing logs, you can identify suspicious activities, unauthorized access attempts, or unusual patterns that could indicate a security breach.   5. Capacity Planning and Resource Optimization: Logs can help you understand resource utilization patterns and plan for future capacity needs. By analyzing logs, you can identify trends, forecast resource requirements, and optimize the allocation of resources to ensure efficient operation.   6. Application and Business Insights: Logs can provide insights into user behavior, application usage, and customer interactions. By analyzing logs, you can gain valuable information to improve user experiences, enhance application features, and make informed business decisions.   This article summarizes information and practices that can be helpful when you want to output logs via Cloud Logging on Google Cloud Platform.

3. What is Cloud Logging?

Cloud Logging is a managed logging service provided by Google Cloud Platform (GCP). It enables you to collect, view, analyze, and store logs generated by your applications and services running on GCP. Cloud Logging allows you to centralize your log data, making it easier to monitor and troubleshoot your systems. Previously, the service was called Stackdriver Logging. Logs are collected in Cloud Logging by executing APIs or via agents in VMs. The collected logs can be viewed and queried in Explorer, and alarms can be fired when certain strings are detected. Cloud Logging logs can also be managed in Cloud Storage and can be set to rotate and deleted after a certain period of time.   Key features and functionalities of Cloud Logging include:   1. Log Collection: Cloud Logging supports log collection from various sources, including Google Cloud services, Google Kubernetes Engine (GKE), Google Compute Engine (GCE), and third-party applications.   2. Log Storage: Cloud Logging provides a scalable and durable storage solution for your log data. Logs are stored in a regional or multi-regional bucket, providing redundancy and availability.   3. Log Viewing and Analysis: Cloud Logging offers a user-friendly interface, the Logs Viewer, which allows you to search, filter, and analyze logs in real-time.   4. Monitoring and Alerting: Cloud Logging integrates with Cloud Monitoring, enabling you to set up alerts and notifications based on log data.   5. Log Exports: Cloud Logging allows you to export logs to other Google Cloud services or external destinations.   6. Integration with other GCP Services: Cloud Logging seamlessly integrates with other GCP services, such as Cloud Pub/Sub, Cloud Functions, and Cloud Dataflow.   7. Security and Access Control: Cloud Logging provides granular access control and permissions to ensure the security and privacy of your log data.   Cloud Logging supports the following logs:   1. Logs from Google Cloud services Cloud Logging integrates with various GCP services, including Google Compute Engine (GCE), Google Kubernetes Engine (GKE), Google Cloud Functions, Google Cloud Storage, Google Cloud SQL, Google Cloud Pub/Sub, and more. It captures logs generated by these services, providing visibility into their activities and operations.   2. Security logs Logs from Cloud Audit Logs, an audit log service, are also supported.   3. App/OS logs App logs/OS logs via agents in VMs and logs posted by users via APIs. Cloud Logging collects logs from operating systems running on GCE instances, such as Linux system logs (e.g., syslog, kernel logs) and Windows event logs. This allows you to monitor and troubleshoot system-level issues.   4. Logs outside of Google Cloud Logs imported from AWS or on-premises. Cloud Logging can receive logs from third-party applications and services through its API. You can configure log forwarding or use logging agents provided by those applications to send logs to Cloud Logging.

4. Cloud Logging for Compute Engine VMs

For troubleshooting Website Issues, when your website hosted on the server encounters problems, viewing syslog logs can help identify the root cause of the issue. For example, if users are experiencing slow response times or encountering errors, examining the syslog logs can provide insights into potential server-side issues such as high resource usage, misconfigurations, or software conflicts. By analyzing the logs, you can pinpoint the problem and take appropriate actions to resolve it, ensuring smooth website operation.   Google Cloud's operations suite provides the following agents for collecting logs from Linux and Windows VM instances. Which agent should you choose? - Ops Agent: The primary and preferred agent for collecting telemetry from your Compute Engine instances. This agent combines logging and metrics into a single agent, providing YAML-based configurations for collecting your logs and metrics, and features high-throughput logging. You can configure the Ops Agent to collect logs from supported third-party applications. - Legacy Logging agent: Streams logs from common third-party applications and system software to Cloud Logging. You can configure the agent to stream additional logs.   Let's try to use Cloud Logging on a VM immediately.   Assume you already have a running VM.   (1) Cloud Logging Agent Installation To use Cloud Logging on a VM, it is necessary to install the agent on each VM. Use the following command to install the agent.   (2) Start the agent Next, start the Cloud Logging agent. Logs will now be aggregated on GCP.  
## Cloud Logging Agent Installation
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
sudo bash add-logging-agent-repo.sh --also-install

## Agent Activation
sudo service google-fluentd restart                
 

(3) Confirm that logs are output to Cloud Logging
Log in to Google Cloud and click "Logging" → "Log Explorer".

We have successfully confirmed log output!

5. Cited/Referenced Articles

6. About the proprietary solution "PrismScaler"

・PrismScaler is a web service that enables the construction of multi-cloud infrastructures such as AWS, Azure, and GCP in just three steps, without requiring development and operation. ・PrismScaler is a web service that enables multi-cloud infrastructure construction such as AWS, Azure, GCP, etc. in just 3 steps without development and operation. ・The solution is designed for a wide range of usage scenarios such as cloud infrastructure construction/cloud migration, cloud maintenance and operation, and cost optimization, and can easily realize more than several hundred high-quality general-purpose cloud infrastructures by appropriately combining IaaS and PaaS.  

7. Contact us

This article provides useful introductory information free of charge. For consultation and inquiries, please contact "Definer Inc".

8. Regarding Definer

・Definer Inc. provides one-stop solutions from upstream to downstream of IT. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition/design development/implementation, and maintenance and operation. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition, design development, implementation, maintenance, and operation. ・PrismScaler is a high-quality, rapid, "auto-configuration," "auto-monitoring," "problem detection," and "configuration visualization" for multi-cloud/IT infrastructure such as AWS, Azure, and GCP.