Prepare and test your skills

Prepare and test your skills

A log entry in Cloud Logging (opens in a new tab) is a LogEntry object that records a single event from a monitored resource. A log is a collection of log entries, and each log entry applies to one monitored resource type. Reading timestamp, severity, resource type, labels, and payload together shows what happened, where it happened, and how serious it was.
A log entry organizes operational data into standard metadata fields plus a message payload. The metadata describes the context of the event, while the payload carries the diagnostic details. Together these fields let you filter, group, and troubleshoot events from many services in one place.
An annotated LogEntry object showing its metadata fields — timestamp, severity, resource, labels, logName, trace — and a nested protoPayload containing an AuditLog object with serviceName, authenticationInfo, methodName, and metadata fields.
receiveTimestamp records when Cloud Logging received the entry.severity >= "ERROR".resource.type and resource.labels, such as a virtual machine instance or container.jsonPayload fields, or a protoPayload object for audit logs.logName identifies the log that stores the entry, while trace and traceSampled link related entries from the same traced request.The resource type in a log entry names the kind of Google Cloud or Kubernetes resource that produced the entry. The resource labels then pinpoint the specific instance, such as the cluster name, node, namespace, pod, or container name. Data flows from the producing resource to Cloud Logging, and the resource type determines where the entry appears when you search.
| Resource type | Display name | Holds logs from |
|---|---|---|
| k8s_control_plane_component | Control plane component logs | System components on control plane replicas, such as kube-apiserver |
| k8s_node | Node pool logs | System services on worker nodes, such as kubelet and containerd |
| k8s_container | Workload container logs | Containers on worker nodes, including system namespaces and user workloads |
System apps logs also use the k8s_container resource type. These entries come from pods installed by the platform in namespaces such as gke-system, gke-connect, kube-system, and istio-system. Filtering first by resource.type and then by resource.labels.cluster_name, resource.labels.container_name, or pod name narrows results to one component.
The payload of a log entry holds the diagnostic content that explains the event. General entries use a text message or structured jsonPayload fields, which appear under frequent fields in Logs Explorer. Audit entries use a structured protoPayload that contains an AuditLog object with fields such as serviceName and authenticationInfo.
The Cloud Audit Logs (opens in a new tab) service writes four kinds of audit logs for each project, folder, organization, and billing account. Each kind has its own log name suffix, typically shortened to activity, data_access, system_event, and policy. The full log name follows the pattern projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity, with parallel patterns for folders, organizations, and billing accounts. The protoPayload.serviceName field names the Google Cloud product that wrote the audit entry, such as compute.googleapis.com for Compute Engine. A resource type belongs to a single service, but one service can have several resource types. Service-specific details appear in the optional metadata field, while some services still use the older serviceData field for the same purpose.
Exam tip: An audit log entry is distinguished from other log entries by its protoPayload field containing an AuditLog object, not by timestamp or severity alone.
Contextual information and trace integration in Google Cloud connects individual log messages to the larger request they belong to. Cloud Logging (opens in a new tab) stores detailed fields inside each log entry, and Cloud Trace stores the timing and hierarchy of work across services. When those two systems share identifiers, an operator can move from one log to its full trace and back to all related logs to rebuild what happened in order.
Context fields are the metadata inside a log entry that identifies which request, resource, and trace produced it. The trace field holds the identifier of the trace that the log belongs to, while the traceSampled field records whether that request was sampled for tracing. The resource.type and resource.labels fields identify the monitored resource that emitted the log, such as a specific VM instance or container, and latency-related fields record how long the operation took. Together these fields let an operator group logs from the same request, filter to the same resource, and connect a log message to its parent span and child spans.
The Logs Explorer surfaces these fields visually so related context is easy to spot:
trace identifier links the log entry to one distributed trace across services.traceSampled flag indicates whether trace details were kept for sampling.resource.type and resource.labels link the log entry to the emitting resource instance.When a log entry contains both the trace field and a latency-related field, the Logs Explorer shows both a trace icon and a latency icon. When a log entry contains only the trace field, only the trace icon appears.
Viewing trace data from a log entry starts in the Logs Explorer by expanding the log to inspect its details. The operator clicks the trace icon on the entry and chooses how to follow the trace identifier into tracing data. The Trace details panel then shows the parent span and child spans for the selected trace, and the operator can open the full view in Cloud Trace by selecting View in Trace.
| Action | What it opens | Use when |
|---|---|---|
| View trace details | Parent span and child spans with trace timing in the Trace details panel | The goal is to see the sequence and hierarchy of spans for this request |
| Show all logs for this trace | Logs Explorer query filtered to trace equal to this trace identifier | The goal is to list every log that shares the same trace |
| Show only traced requests | Logs Explorer query filtered to traceSampled equal to True | The goal is to list only requests that were sampled for tracing |
Exam tip: View trace details is available only when traceSampled is true, while Show all logs for this trace works from the trace identifier alone.
Reconstructing an event sequence means following the link in both directions between Cloud Logging and Cloud Trace. Data flows from a log entry in the Logs Explorer to the Trace details panel, and data also flows from a span in the Trace explorer back to its associated logs. This two-way movement makes it possible to start from either a single error message or a slow trace and recover the full ordered set of events.
From the Trace explorer side, the workflow follows an ordered path:
/multi, in the Trace explorer./multi span in the Gantt chart to open its request panel, which shows HTTP method, status code, byte count, and caller user agent.Log data can become available several minutes before trace data is available. If searching by trace ID or opening trace details returns an error, waiting a minute or two and retrying allows time for the trace database to be created and populated.
Narrowing to related entries uses pinning and field matching to keep one important log in view while filtering to its context. Pinning highlights a log entry so it stays centered in the Query results pane and marks its timestamp on the Timeline pane. Showing or hiding matching entries filters the results to log entries that contain the same field value, such as the same serviceName.
After pinning a log entry, the pin menu can rerun the query around the pinned context:
resource.type as the pinned log.resource.labels as the pinned log.trace as the pinned log.The Timeline pane also works with the pinned entry through Scroll to log entry, which brings the entry into view with nearby logs, and Zoom to log entry, which narrows the time range to logs near the pinned timestamp.
A LogEntry in Cloud Logging (opens in a new tab) carries its message content in a payload field, and the payload type determines how much detail you can read. Simple human-readable text travels in textPayload, named JSON fields travel in jsonPayload, and audit data travels in protoPayload. The payload type tells you whether you are looking at a single message string, a set of searchable fields, or a formal audit record.
| Payload field | What it holds | What it reveals |
|---|---|---|
textPayload | A single string message | The basic event text, including a multi-line stack trace or a build message when only mappable fields are present |
jsonPayload | JSON-formatted fields such as message, stack_trace, exception, and custom fields | Structured detail that can be filtered and searched, such as which build step ran or which error field triggered grouping |
protoPayload | An AuditLog object for audit logs | Who did what to which resource, including service name, authentication info, and service-specific metadata |
The choice of payload affects troubleshooting because textPayload shows what happened in words, while jsonPayload and protoPayload break the event into fields that explain context and point to the cause.
A textPayload is the simplest log message content in Cloud Logging. The textPayload holds one string value, such as Build successful or a multi-line stack trace from an application error. In Cloud Build (opens in a new tab) structured logging, the build field message appears in textPayload when the build log contains only mappable fields. Text content is easy to read but harder to filter than named JSON fields, so it is best for short status messages and raw error text.
A jsonPayload is a set of named JSON fields stored inside the LogEntry. The jsonPayload lets an application add context around the message, such as custom build values, error details, or workload labels. Structured logging stores a JSON-formatted build log field as part of jsonPayload, or as another specific LogEntry field, when field mapping is turned on.
Field mapping for build logs is enabled by setting enableStructuredLogging to TRUE in BuildOptions. When mapping is enabled, the build field message must be a string and the build field severity must be an enum of LogSeverity. If the build log contains other unmapped fields besides message and severity, the message appears in jsonPayload.message instead of textPayload. If the build has multiple steps, the step identifier appears at the beginning of the message, which helps trace which step produced the output.
The following build log fields map to LogEntry fields:
| Build log field | LogEntry field | Requirement |
|---|---|---|
message | textPayload or jsonPayload.message | Must be a string; goes to textPayload only when no extra fields are present |
severity | severity | Must be an enum of LogSeverity |
All other build log fields appear as part of jsonPayload. Certain reserved fields cannot be mapped and are dropped from the log entry if they appear in a build log:
httpRequestlogging.googleapis.com/insertIdlogging.googleapis.com/labelslogging.googleapis.com/operationlogging.googleapis.com/sourceLocationlogging.googleapis.com/spanIdlogging.googleapis.com/tracelogging.googleapis.com/trace_sampledtimetimestamptimestampSecondstimestampNanosExam tip: A build message goes to textPayload when only mappable fields are present; when extra fields are present, the same message goes to jsonPayload.message.
A protoPayload is the payload type that marks a log entry as an audit log entry in Cloud Logging. The protoPayload contains an AuditLog object instead of free text or generic JSON. That object names the service in protoPayload.serviceName, such as compute.googleapis.com for Compute Engine, and identifies the project, folder, or organization that owns the entry plus the monitored resource it applies to. The payload also carries audit-specific detail such as authentication info and service-specific metadata, with some services still using the older serviceData field.
Because the AuditLog structure is consistent, message content in protoPayload reveals system behavior around access and change. A sample Admin Activity entry from App Engine records a change to an Identity and Access Management (IAM) policy, showing who made the change, which resource was affected, and when it occurred. Log names such as activity, data_access, system_event, and policy further indicate whether the entry records configuration activity, data access, a system event, or a policy denial.
Message content points to underlying issues when severity, step context, and error fields are read together. A severity value flags how serious the event is, while a build step identifier at the start of the message shows which part of a multi-step build failed. Custom jsonPayload fields add clues such as input values, resource labels, or service-specific metadata that explain why the system behaved that way.
Error events need specific fields so Error Reporting can capture and group them. An error can be logged as a multi-line textPayload stack trace or as a jsonPayload that includes error detail. When jsonPayload includes more than one error field, Error Reporting evaluates them in a fixed order:
If the error is formatted as a ReportedErrorEvent object, its fields are copied into jsonPayload. If jsonPayload has no message, stack_trace, or exception field but still contains a stack trace somewhere, Error Reporting searches all fields and selects one stack trace consistently. A message that lacks a recognizable stack trace or proper error fields may be visible in logs but will not group correctly as an error.
k8s_control_plane_component for control plane components, k8s_node for worker node system services, and k8s_container for workload containers.protoPayload containing an AuditLog object, with log name suffixes activity, data_access, system_event, and policy.message goes to textPayload when only mappable fields are present and to jsonPayload.message when extra unmapped fields are present.jsonPayload error fields in the order stack_trace, then exception, then message.An audit log entry is marked by a protoPayload field containing an AuditLog object, while general entries use a text message or structured jsonPayload fields. The AuditLog object names the service in protoPayload.serviceName and carries authentication info and service-specific metadata, and the log name suffix indicates activity, data_access, system_event, or policy.
A Cloud Build message goes to textPayload when only mappable fields are present and to jsonPayload.message when extra unmapped fields are present. Field mapping is enabled by setting enableStructuredLogging to TRUE in BuildOptions, where message must be a string and severity must be an enum of LogSeverity.
In Logs Explorer you can expand a log entry and use the trace identifier to open View trace details for parent and child spans, Show all logs for this trace, or Show only traced requests. From the Trace explorer you can select a trace row and span, open the Logs and Events tab, and return to Logging to rebuild the ordered event sequence.
A cloud engineer is reviewing an individual log entry in the Logs Explorer to troubleshoot an application failure. While viewing the expanded JSON object of the LogEntry, the engineer needs to determine the exact Google Cloud infrastructure component that emitted the log, including its resource type and specific identifying metadata such as the project ID and zone.
Which top-level field in the LogEntry structure contains this information?
Last updated