PROFESSIONAL-CLOUD-DEVOPS-ENGINEER · Question #163
You are configuring Cloud Logging for a new application that runs on a Compute Engine instance with a public IP address. A user-managed service account is attached to the instance. You confirmed…
The correct answer is C. Add the Logs Writer role to the service account. If logs from a Compute Engine instance are not appearing in Cloud Logging despite agents running, the user-managed service account attached to the instance likely lacks the necessary Logs Writer role to send logs.
Question
Options
- AExport the service account key and configure the agents to use the key.
- BUpdate the instance to use the default Compute Engine service account.
- CAdd the Logs Writer role to the service account.
- DEnable Private Google Access on the subnet that the instance is in.
How the community answered
(65 responses)- A6% (4)
- B14% (9)
- C77% (50)
- D3% (2)
Why each option
If logs from a Compute Engine instance are not appearing in Cloud Logging despite agents running, the user-managed service account attached to the instance likely lacks the necessary Logs Writer role to send logs.
Exporting service account keys is a security anti-pattern and not recommended for authentication within GCP, as instance service accounts are designed to provide credentials automatically.
While the default Compute Engine service account often has broad permissions, it's a general practice to use custom service accounts with the principle of least privilege, so this is not the recommended first step.
For an application or agent running on a Compute Engine instance to write logs to Cloud Logging, the service account associated with that instance must have the `roles/logging.logWriter` IAM role. This role grants the permissions required to create log entries in Cloud Logging, ensuring that logs emitted by the agents can be successfully ingested and displayed.
Private Google Access is for instances without external IP addresses to reach Google APIs over internal IP addresses; since the instance has a public IP, this setting is irrelevant to the logging issue.
Concept tested: Cloud Logging IAM permissions for Compute Engine
Source: https://cloud.google.com/logging/docs/agent/installation#before-you-begin
Topics
Community Discussion
No community discussion yet for this question.