Before you beginTo view the logs that you are sending from an Amazon Web Services (AWS) account to Logging, select the AWS connector project in the Google Cloud Console project picker and then use the Legacy Logs Viewer. The AWS connector project stores the Amazon Resource Name (ARN) for your AWS account and links your AWS account to Google Cloud services. For more information, see Viewing metrics for AWS accounts.
Ensure that you have the correct Identity and Access Management permissions or role for building queries using the Logs Explorer. For details on the necessary IAM permissions, see Access Control Guide: Cloud Console permissions.
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 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 the 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 the logName. You can select
multiple log names at the same time to add to the Query builder. When
selecting multiple entries, the logical operator
- Severity: Lets you specify the severity. You can select
multiple severity levels at the same time 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, and 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:
Select 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.
Select 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.
Shared queries let users of a project share their saved queries with each other.
For the roles and permissions needed to view and edit shared queries, see the Permissions and roles section on the Access control page.
Sharing a query
You can share queries that you have already saved, or you can share a new query.
To share a new query, do the following:
Enter a query in the Query builder.
Select Save from the query-builder pane.
Complete the fields in the save-query dialog.
Enable Share with project.
Your query is now shared with other users of the project.
To share an already saved query, do the following:
Select More options more_vert > Edit create, or select the query directly.
In the edit-query dialog, enable Share with project, and then select Update query.
Your query is now shared with other users of the project.
Viewing shared queries
To quickly view all shared queries, sort the Visibility column to show shared queries first:
Select the Saved tab.
Sort the Visibility column.
The Visibility column distinguishes queries shared with you from queries you are sharing with other users of the project.
Viewing only your queries
To view shared queries that you created or shared, click Mine. You now see a list of queries that you have created and saved. In the Visibility column, you can see your unshared Private queries. Queries that you've shared are denoted by Shared by me.
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.
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:
- Stream. Streams logs based on the given query parameters.
- 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.