本文档介绍了如何使用 Gemini Cloud Assist 中的对话型助理来分析和优化 Google Cloud 资源。
在 Gemini Cloud Assist 中,您可以使用 Cloud Assist 面板编写自然语言语句或问题(称为“提示”),以获取深入的说明、建议的操作或引导式工作流。借助这些资源,您无需成为云专家,也能快速高效地完成任务。
准备工作
打开 Cloud Assist 面板
前往 Google Cloud 控制台中的任意页面,例如 Gemini for Google Cloud 页面。
在 Google Cloud 控制台工具栏中,点击 spark 打开或关闭 Gemini AI 对话。
Cloud Assist 面板随即打开,并显示一些可点击的示例提示。提示内容会根据您当前所处的 Google Cloud 控制台页面而有所不同。
可选:撰写自然语言提示以获取帮助。
提示 Gemini Cloud Assist 提供帮助
本部分包含一些示例场景和您可以在 Cloud Assist 面板中输入的相关提示。
生成 SQL 查询
以下示例展示了如何在 Google Cloud 控制台的 BigQuery 页面中通过 Cloud Assist 面板生成 SQL 查询:
在 Cloud Assist 面板中,发送以下提示:
Generate a SQL query to show me the duration and subscriber type for the ten longest trips.
在此示例中,Gemini Cloud Assist 提供了一个特定的 SQL 查询,您可以查看该查询并将其复制到 BigQuery 查询编辑器中。
可选:发送提示以生成 Python 代码:
Generate Python code to query the bigquery-public-data.ml_datasets.penguins table using bigquery magics.
了解已部署的资产及其近期变更
为了了解已部署资产及其近期变更,您的项目必须隶属于某个组织。不支持未关联组织的项目。
以下示例使用 Cloud Asset Inventory。
在 Cloud Assist 面板中,发送以下提示:
What are the names of my instances and their private interface names?
Gemini Cloud Assist 会列出实例、其名称和专用接口名称。
可选:针对类似场景发送以下任一提示:
List the name and network name for the subnetworks.
List my artifact repo.
How many BigQuery datasets have a label whose value is 'foo'?
List all config changes in the last 24 hours.
List all users granted roles/bigquery.admin and include the attached resources.
List a BigQuery dataset organized by name and location.
Describe the configuration of "pubsub/topic/…"
分析数据库查询和系统性能
以下示例展示了如何在 Google Cloud 控制台的 Cloud SQL 页面中特定数据库实例的以下标签页上,从 Cloud Assist 面板获取查询性能数据:
- 概览
- 系统数据分析
- 查询数据分析
- 查询详情
在 Cloud Assist 面板中,发送以下提示:
What's the current CPU utilization of this database?
回答中包含数据库舰队的所有合规性问题列表,并附有一个表格,详细列出每个类别及其资源数量。
可选:针对类似场景发送以下任一提示:
Summarize database query trends by users.
Which of my queries have high latency for this database instance?
What is the slowest query for this database in this instance?
What are the wait times for the query id = in this database?
How many error log entries are there for this database instance?
了解数据库舰队健康状况和合规性
以下示例展示了如何从 Cloud Assist 面板获取数据库舰队健康状况和合规性数据:
在 Cloud Assist 面板中,发送以下提示:
How many databases do I have in the US?
Gemini Cloud Assist 会提供您在美国的所有数据库的列表。
可选:针对类似场景发送以下任一提示:
Where are my databases located?
What issues are affecting my databases?
Show me all databases running on Postgres.
What databases have NIST issues in Europe?
分析资源的性能趋势
以下示例使用 Cloud Monitoring。
在 Cloud Assist 面板中,发送以下提示:
Which of my VMs have the highest utilization?
Gemini Cloud Assist 可快速分析流量、吞吐量、执行等资源的性能趋势。
可选:针对类似场景发送以下任一提示:
What are the top 5 dataflow jobs with the highest estimated backlog processing time?
Total VM network bytes sent per second for each instance?
What's the QPS on my SQL databases?
查找建议和优化机会
以下示例使用 Active Assist。
在 Cloud Assist 面板中,发送以下提示:
Give me recommendations to reduce my resource costs.
Gemini Cloud Assist 会针对预估的节省幅度和集群可靠性提供具体建议。
可选:针对类似场景发送以下任一提示:
What are all the quotas for my project that are almost hitting the limit?
What BigQuery datasets should I partition or cluster?
Which of my VMs are idle?
了解 App Hub 应用、服务和工作负载
以下示例展示了如何在 Google Cloud 控制台中使用 Cloud Assist 面板来获取特定团队成员有权访问的 App Hub 主机项目中的 App Hub 应用列表。
在 Cloud Assist 面板中,发送以下提示:
Show me all applications in this project with the developer owner lee@example.com
Gemini Cloud Assist 会返回符合您指定条件的应用列表。
可选:针对特定场景发送以下任一提示:
List all the registered services in application "foo" in the location us-central1.
Show me all applications with user email myemail@example.com as business owners.
Describe my application "app-1" in us-east1.
获取监管控制建议
以下示例展示了如何在 Google Cloud 控制台中使用 Cloud Assist 面板,以获取有关使用哪个 Assured Workloads 监管控制包的建议。
在 Cloud Assist 面板中,发送以下提示:
Help me choose a regulatory control for my Google Cloud folders.
Gemini Cloud Assist 会开始与您进行自然语言对话,了解您的需求,并建议最合适的控制包。
可选:针对类似场景发送以下任一提示:
How do I set up an Assured Workloads control package?
How do I create an Assured Workloads folder?
How do I monitor an Assured Workloads folder for violations?
了解 Cloud Storage 存储类别
以下示例展示了如何在 Cloud Storage 页面中使用 Cloud Assist 面板来查看在存储桶中存储数据时可以使用的不同存储类别。
在 Cloud Assist 面板中,发送以下提示:
What storage class should I use for my data?
Gemini Cloud Assist 会返回可用存储类别的列表,并描述每种存储类别的用例。
可选:如果您拥有 Storage Intelligence 订阅以及访问存储空间分析数据集的适当 IAM 角色,则可以发送有关特定存储桶和对象的提示。例如,您可以发送以下提示:
How many bytes are stored in my buckets in the us-central1 location?
What is my Cloud storage usage, broken down by content type?
How many objects do I have in Standard storage smaller than 50 GB?
跟踪项目在一段时间内的费用
以下示例展示了如何在 Google Cloud 控制台中使用 Cloud Assist 面板来获取项目在过去一年中的每月费用。
在 Cloud Assist 面板中,发送以下提示:
How much did I spend on this project last year by month?
为了直接回答您的问题,您必须拥有相应的 IAM 权限才能访问项目的费用信息。
Gemini Cloud Assist 会返回指定日期范围内的每月费用。
可选:针对类似场景发送以下任一提示:
Which SKUs are costing me the most?
Did I spend more in October or November?
了解数据保护和隐私安全控件
以下示例展示了如何在 Google Cloud 控制台中使用 Cloud Assist 面板来创建 Secret Manager 密钥并列出您拥有的所有 Cloud Key Management Service 密钥。
在 Cloud Assist 面板中,发送以下提示:
Help me create a secret.
Gemini Cloud Assist 会开始通过自然语言对话指导您逐步创建 Secret。
可选:在逐步指导过程中,您可以请求提供建议,例如哪种保护措施适合您的需求。例如,您可以发送以下任一提示来获取更多指导:
What protection level should I use for my Cloud KMS key?
Help me create a Confidential Space
完成这些步骤后,Gemini Cloud Assist 会生成要使用的适当 Terraform 代码和 gcloud CLI 命令。
在 Cloud Assist 面板中,发送以下提示以返回有关安全资源的信息:
List my Cloud KMS keys in a table.
Gemini Cloud Assist 会返回所请求的信息。
可选:针对类似场景发送以下任一提示:
Which VMs have Confidential Computing enabled?
How many VMs have confidential Confidential Computing enabled?
What is the rotation policy for my Cloud KMS key?
When was my Cloud KMS key last rotated?
检查是否存在任何可能影响您项目的已知 Google Cloud 事件
以下示例展示了如何在 Google Cloud 控制台中使用 Cloud Assist 面板来获取可能影响您的项目的正在进行的 Google Cloud 事件的列表。
在 Cloud Assist 面板中,发送以下提示:
Is there something going on with Google Cloud? I'm seeing issues with my project.
Gemini Cloud Assist 会报告与您的项目可能相关的所有近期事件。
可选:针对类似场景发送以下任一提示:
What's the latest update on the Compute Engine outage in us-central1?
How is my project impacted by the Cloud Storage incident?
Is there a workaround for the BigQuery incident?