Before you begin
You don't need a Workspace to use Logging, unless you are sending logs from Amazon Web Services (AWS) to Logging.
The Logs Explorer displays logs for a single Google Cloud project. If you are using a Workspace, Logging doesn't combine the logs from the monitored projects. You must select a specific project to view its logs.
If you're using a Workspace and AWS, select the AWS connector project to see the AWS logs.
To navigate to the Logs Explorer, do the following:
Go to the Google Cloud navigation menu menu and
select Logging > Logs Explorer:
Go to the Logs Explorer
- Select a Google Cloud project.
- From the Upgrade menu, switch from Legacy Logs Viewer to Logs Explorer.
You're now in the Logs Explorer.
The query-builder pane provides multiple ways to retrieve logs:
- Query builder drop-down menus.
- Queries using the Logging query language.
- Recent, Saved, and Suggested queries tabs.
The following sections describe how to build and run queries to retrieve your logs.
Query builder drop-down menus
The drop-down menus let you add query parameters to the Query builder. You can use the drop-down menus to select resources, log names, log severity, and time ranges. These options correspond to the LogEntry fields for all Logging logs.
- Resource: Lets you specify resource.type. You can select a
single resource at a time to add to the Query builder. Entries use
the logical operator
- Log name: Lets you specify logName. You can select multiple
log names at once to add to the Query builder. When selecting
multiple entries, the logical operator
- Severity: Lets you specify [severity][severity]. You can select multiple
severity levels at once to add to the Query builder. When selecting
multiple entries, the logical operator
To use any of the search parameter menus, expand them and select a parameter, or multiple parameters, then click Add.
Once you've built your query, click Run Query to retrieve your desired log entries.
Queries with a time restriction
There are two ways to query logs based on time:
- Query using a timestamp expression
Query using the time-range selector
If you have a query with a timestamp, the time-range selector is disabled, and the query uses the timestamp expression as its time-range restriction. If a query doesn't use a timestamp expression, then the query uses the time-range selector as its time-range restriction.
Queries using the Logging query language
For more details, see Logging query language.
The query-builder pane features a Saved tab, where you can access your saved queries.
Saved queries let you store query expressions to help you explore your logs more consistently and efficiently.
To save a query that you have built in the query-builder pane, do the following:
Click Save in the query-builder pane. The Save query dialog opens, with your query expression in the Query field.
Add a Name for your query.
Names are limited to 64 characters.
Optional: To add summary fields to your query, toggle Include summary fields.
Optional: Add a Description for your query.
Descriptions are limited to 1,000 characters. Don't include any sensitive information.
Click Save query in the dialog.
Your saved queries appear in a list under the Saved tab in the query-builder pane.
To run a saved query, click Run query.
The query-builder pane features a Recent tab. When you run a query, the query is added to your Recent queries list, which contains the last 10,000 unique queries over a 30-day period.
To view your recent queries, select the Recent tab in the query-builder pane. Within the Recent tab, you have the following options:
- Run. Runs the query.
More options more_vert. Lets you view the query parameters with the options to run the query or save it to your list of Saved queries. You can also select the query directly to get these options.
To run the query, select Run.
To save the query, select Save as, and complete the following fields:
- Name (Required): Provide a name.
- Description (Optional): Provide a description to help identify the purpose of the query.
- Include summary fields (Optional): Enable Include summary fields and enter the fields you want displayed.
- Truncate summary fields (Optional): Enable Truncate summary fields and select the number of characters to truncate to and whether truncation occurs at the beginning or end of the fields.
Select Save query. The query is now available in your Saved queries list.
Note that you can also filter your recent queries; the filter matches on the text in your query's expression.
Logging generates suggested queries based on its understanding of the Google Cloud products you're using. It proposes queries that can help you pinpoint issues and provide you with insights into the overall health of your systems. For instance, detecting that you're using Google Kubernetes Engine, Logging might suggest a query that finds all the error logs for your containers.
To view and run Suggested queries in the query-builder pane, do the following:
Click on the Suggested tab.
Review the description of the Suggested query.
To review the details of a Suggested query, do either of the following:
a. Click on the row.
b. Click More more_vert and select View.
In the query-builder pane, you see the query and the options to Run or Save it.
a. To save the query, click Save. The query shows up in your Saved list, where you can choose to run the query later.
b. To run the query, click Run. The query shows up under Query preview in the query-builder pane.
After you review the query, click Run query. The results of the suggested query are displayed under Query results.
Suggested queries are created dynamically based on the Google Cloud project context. Successive page loads might not show the same queries in the same order. This is expected behavior.