分析和优化 Google Cloud 资源

本文档介绍了如何使用 Gemini Cloud Assist 中的对话式助理来分析和优化资源。 Google Cloud

在 Gemini Cloud Assist 中,您可以使用 Cloud Assist 窗格编写自然语言语句或问题(称为提示),以获取深入的说明、建议的操作或引导式工作流。这些资源可帮助您快速高效地完成任务,而无需成为云专家。

准备工作

打开 Cloud Assist 窗格

  1. 前往 Google Cloud 控制台中的任意页面,例如 Gemini for Google Cloud 页面。

    前往 Gemini for Google Cloud

  2. 在 Google Cloud 控制台工具栏中,点击 spark 打开或关闭 Gemini AI 聊天

    Cloud Assist 窗格随即打开,并显示一些可供点击的示例提示。提示会因您当前的 Google Cloud 控制台页面而异。

  3. 可选:撰写自然语言提示以获取帮助。

提示 Gemini Cloud Assist 提供帮助

本部分包含一些示例场景和相关提示,您可以将其输入 Cloud Assist 窗格中。

生成 SQL 查询

以下示例展示了如何在 Google Cloud 控制台的 BigQuery 页面中,通过 Cloud Assist 窗格生成 SQL 查询:

  1. Cloud Assist 窗格中,发送以下提示:

    Generate a SQL query to show me the duration and subscriber type for the ten
    longest trips.
    

    在此示例中,Gemini Cloud Assist 提供了一个特定的 SQL 查询,您可以查看该查询并将其复制到 BigQuery 查询编辑器中。

  2. 可选:发送提示以生成 Python 代码:

    Generate Python code to query the bigquery-public-data.ml_datasets.penguins
    table using bigquery magics.
    

了解已部署的素材资源及其近期的更改

您的项目必须有一个组织,以便了解已部署的资源及其近期更改。不支持没有组织的项目。

以下示例使用 Cloud Asset Inventory

  1. Cloud Assist 窗格中,发送以下提示:What are the names of my instances and their private interface names?

    Gemini Cloud Assist 会列出实例、其名称和私有接口名称。

  2. 可选:针对类似场景发送以下任意提示:

    • 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 窗格获取查询性能数据:

  • 概览
  • 系统数据分析
  • 查询数据分析
  • 查询详情
  1. Cloud Assist 窗格中,发送以下提示:

    What's the current CPU utilization of this database?
    

    响应包含数据库集群的所有合规性问题列表,其中包含一个表格,其中会对每个类别和资源数进行细分。

  2. 可选:针对类似场景发送以下任意提示:

    • 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 窗格获取数据库集群运行状况和合规性数据:

  1. Cloud Assist 窗格中,发送以下提示:

    How many databases do I have in the US?
    

    Gemini Cloud Assist 会提供您在美国的所有数据库的列表。

  2. 可选:针对类似场景发送以下任意提示:

    • 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

  1. Cloud Assist 窗格中,发送以下提示:Which of my VMs have the highest utilization?

    Gemini Cloud Assist 可快速分析流量、吞吐量和执行等资源的性能趋势。

  2. 可选:针对类似场景发送以下任意提示:

    • 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?

查找建议和优化机会

以下示例使用了主动辅助

  1. Cloud Assist 窗格中,发送以下提示:Give me recommendations to reduce my resource costs.

    Gemini Cloud Assist 会针对预计节省金额和集群可靠性提供具体建议。

  2. 可选:针对类似场景发送以下任意提示:

    • 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?

后续步骤