Skip to main content

Google Cloud Logging

This Integration is part of the Google Cloud Logging Pack.#

Supported versions

Supported Cortex XSOAR versions: 6.8.0 and later.

With Google Cloud Logging, users can centralize all their logs in a single location, making it easier to troubleshoot issues and gain insights from their data.

Configure Google Cloud Logging in Cortex#

ParameterDescriptionRequired
Service Account JSONUser's Service Account key in JSON format.True
Trust any certificate (not secure)False
Use system proxy settingsFalse

Commands#

You can execute these commands from the CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.

gcp-logging-log-entries-list#


Lists log entries. Use this method to retrieve log entries that originated from a project/folder/organization/billing account.

Required Permissions#

This command requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/logging.read
  • https://www.googleapis.com/auth/logging.admin
  • https://www.googleapis.com/auth/cloud-platform.read-only
  • https://www.googleapis.com/auth/cloud-platform

The command requires one or more of the following IAM permissions on the specified resource:

  • logging.logEntries.list
  • logging.privateLogEntries.list
  • logging.views.access

Base Command#

gcp-logging-log-entries-list

Input#

Argument NameDescriptionRequired
project_nameA comma-separated list of projects names of parent resources from which to retrieve log entries. A maximum of 100 resources may be specified.Optional
organization_nameA comma-separated list of organizations names of parent resources from which to retrieve log entries. A maximum of 100 resources may be specified.Optional
billing_account_nameA comma-separated list of billing accounts names of parent resources from which to retrieve log entries. A maximum of 100 resources may be specified.Optional
folder_nameA comma-separated list of folders names of parent resources from which to retrieve log entries. A maximum of 100 resources may be specified.Optional
filterWhen specified, the results returned are limited to log entries that match the filter. Referencing a parent resource that is not listed in resourceNames will cause the filter to return no results. The maximum length of a filter is 20,000 characters. E.g., "protoPayload.requestMetadata.callerIp:1.1.1.1 AND protoPayload.serviceName:name".Optional
order_byHow the results should be sorted. Possible values are: timestamp asc, timestamp desc. Default is timestamp asc.Optional
limitThe maximum number of objects to return.Optional
page_sizeThe maximum number of results to return from this request. Default is 50. If the value is negative or exceeds 1000, the request is rejected.Optional
next_tokenIf present, then retrieve the next batch of results from the preceding call to this method. pageToken must be the value of nextPageToken from the previous response.Optional

Context Output#

PathTypeDescription
GoogleCloudLogging.LogsEntry.logNameStringThe resource name of the log to which this log entry belongs.
GoogleCloudLogging.LogsEntry.resource.typeStringThe monitored resource type.
GoogleCloudLogging.LogsEntry.resource.labelsUnknownValues for all of the labels listed in the associated monitored resource descriptor.
GoogleCloudLogging.LogsEntry.resource.labels.project_idUnknownThe project ID.
GoogleCloudLogging.LogsEntry.resource.labels.cluster_nameUnknownThe cluster name.
GoogleCloudLogging.LogsEntry.timestampStringThe time the event described by the log entry occurred.
GoogleCloudLogging.LogsEntry.receiveTimestampStringThe time the log entry was received by Logging.
GoogleCloudLogging.LogsEntry.severityStringThe severity of the log entry. The default value is LogSeverity.DEFAULT.
GoogleCloudLogging.LogsEntry.insertIdStringA unique identifier for the log entry.
GoogleCloudLogging.LogsEntry.httpRequest.requestMethodStringThe request method.
GoogleCloudLogging.LogsEntry.httpRequest.requestUrlStringThe scheme (http, https), the host name, the path and the query portion of the URL that was requested.
GoogleCloudLogging.LogsEntry.httpRequest.requestSizeStringThe size of the HTTP request message in bytes, including the request headers and the request body.
GoogleCloudLogging.LogsEntry.httpRequest.statusNumberThe response code indicating the status of response.
GoogleCloudLogging.LogsEntry.httpRequest.responseSizeStringThe size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
GoogleCloudLogging.LogsEntry.httpRequest.userAgentStringThe user agent sent by the client.
GoogleCloudLogging.LogsEntry.httpRequest.remoteIpStringThe IP address (IPv4 or IPv6) of the client that issued the HTTP request.
GoogleCloudLogging.LogsEntry.httpRequest.serverIpStringThe IP address (IPv4 or IPv6) of the origin server that the request was sent to.
GoogleCloudLogging.LogsEntry.httpRequest.refererStringThe referer URL of the request.
GoogleCloudLogging.LogsEntry.httpRequest.latencyStringThe request processing latency on the server, from the time the request was received until the response was sent.
GoogleCloudLogging.LogsEntry.httpRequest.cacheLookupBooleanWhether or not a cache lookup was attempted.
GoogleCloudLogging.LogsEntry.httpRequest.cacheHitBooleanWhether or not an entity was served from cache (with or without validation).
GoogleCloudLogging.LogsEntry.httpRequest.cacheValidatedWithOriginServerBooleanWhether or not the response was validated with the origin server before being served from cache. This field is only meaningful if cacheHit is True.
GoogleCloudLogging.LogsEntry.httpRequest.cacheFillBytesStringThe number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.
GoogleCloudLogging.LogsEntry.httpRequest.protocolStringProtocol used for the request.
GoogleCloudLogging.LogsEntry.labelsUnknownA map of key, value pairs that provides additional information about the log entry. The labels can be user-defined or system-defined.
GoogleCloudLogging.LogsEntry.operation.idStringAn arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.
GoogleCloudLogging.LogsEntry.operation.producerStringAn arbitrary producer identifier. The combination of ID and producer must be globally unique.
GoogleCloudLogging.LogsEntry.operation.firstBooleanSet this to True if this is the first log entry in the operation.
GoogleCloudLogging.LogsEntry.operation.lastBooleanSet this to True if this is the last log entry in the operation.
GoogleCloudLogging.LogsEntry.traceStringThe REST resource name of the trace being written to Cloud Trace in association with this log entry.
GoogleCloudLogging.LogsEntry.spanIdStringThe ID of the Cloud Trace span associated with the current operation in which the log is being written.
GoogleCloudLogging.LogsEntry.traceSampledBooleanThe sampling decision of the trace associated with the log entry.
GoogleCloudLogging.LogsEntry.sourceLocation.fileStringSource file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name.
GoogleCloudLogging.LogsEntry.sourceLocation.lineStringLine within the source file. 1-based; 0 indicates no line number available.
GoogleCloudLogging.LogsEntry.sourceLocation.functionStringHuman-readable name of the function or method being invoked, with optional context such as the class or package name.
GoogleCloudLogging.LogsEntry.split.uidStringA globally unique identifier for all log entries in a sequence of split log entries.
GoogleCloudLogging.LogsEntry.split.indexNumberThe index of this LogEntry in the sequence of split log entries.
GoogleCloudLogging.LogsEntry.split.totalSplitsNumberThe total number of log entries that the original LogEntry was split into.
GoogleCloudLogging.LogsEntry.protoPayload.@typeStringA URI identifying the type.
GoogleCloudLogging.LogsEntry.authenticationInfo.principalEmailStringIdentifies the principal that granted the role to the service account.
GoogleCloudLogging.LogsEntry.textPayloadStringThe log entry payload, represented as a Unicode string (UTF-8).
GoogleCloudLogging.LogsEntry.jsonPayloadUnknownThe log entry payload, represented as a structure that is expressed as a JSON object.
GoogleCloudLogging.nextPageTokenStringIf there might be more results than those appearing in this response, then nextPageToken is included.

Command example#

!gcp-logging-log-entries-list project_name="project_id"

Context Example#

{
"GoogleCloudLogging": {
"LogsEntry": [
{
"insertId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"labels": {
"authorization.k8s.io/decision": "allow",
"authorization.k8s.io/reason": "authorization.k8s.io/reason"
},
"logName": "logName1",
"operation": {
"first": true,
"id": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"last": true,
"producer": "producer"
},
"protoPayload": {
"@type": "type.googleapis.com/google.cloud.audit.AuditLog",
"authenticationInfo": {
"principalEmail": "user@example.com"
},
"authorizationInfo": [
{
"granted": true,
"permission": "permission",
"resource": "resource"
}
],
"methodName": "methodName",
"requestMetadata": {
"callerIp": "callerIp",
"callerSuppliedUserAgent": "callerSuppliedUserAgent"
},
"resourceName": "resourceName",
"serviceName": "serviceName",
"status": {
"code": 0
}
},
"receiveTimestamp": "2023-05-06T14:39:56.974311Z",
"resource": {
"labels": {
"cluster_name": "cluster_name",
"location": "some_location",
"project_id": "project_id"
},
"type": "type"
},
"timestamp": "2023-05-06T14:39:56.974311Z"
},
{
"insertId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"labels": {
"authorization.k8s.io/decision": "allow",
"authorization.k8s.io/reason": "authorization.k8s.io/reason"
},
"logName": "logName2",
"operation": {
"first": true,
"id": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"last": true,
"producer": "producer"
},
"protoPayload": {
"@type": "type.googleapis.com/google.cloud.audit.AuditLog",
"authenticationInfo": {
"principalEmail": "user@example.com"
},
"authorizationInfo": [
{
"granted": true,
"permission": "permission",
"resource": "resource1"
}
],
"methodName": "methodName",
"requestMetadata": {
"callerIp": "callerIp",
"callerSuppliedUserAgent": "callerSuppliedUserAgent"
},
"resourceName": "resource1",
"serviceName": "appengine.googleapis.com",
"status": {
"code": 0
}
},
"receiveTimestamp": "2023-04-06T14:39:56.974311Z",
"resource": {
"labels": {
"cluster_name": "cluster_name",
"location": "some_location",
"project_id": "project_id"
},
"type": "type"
},
"timestamp": "2023-04-06T14:39:56.974311Z"
}
],
"nextPageToken": "xxx-xxx"
}
}

Human Readable Output#

Lists log entries#

TimeStampLog NameInsert IDPrincipal EmailTypeProject IDCluster Name
2023-05-06T14:39:56.974311ZlogName1XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXuser@example.comtypeproject_idcluster_name
2023-04-06T14:39:56.974311ZlogName2XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXuser2@example.comtypeproject_idcluster_name

Next page token#

nextPageToken
xxx-xxx

Troubleshooting#

If you encounter the following error message: 'Failed to generate/refresh token. Subject email or service account credentials are invalid. Reason: invalid_grant: Invalid JWT Signature.', please ensure that your Service Account JSON, permissions and service account scopes are correct.