让 Gemini 协助您编写查询
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本文档介绍了如何使用自然语言提示为 VPC 流日志生成 SQL 查询。如需为 VPC 流日志生成 SQL 查询,您可以在 Flow Analyzer 中与 Gemini Cloud Assist 互动。
了解 Gemini for Google Cloud 如何以及何时使用您的数据。
准备工作
生成 SQL 查询
如需与 Gemini Cloud Assist 互动,请使用 pen_spark编写 Cloud Assist 查询提示字段。在提示字段中,您可以输入提示或选择预定义的提示。下表提供了您可以使用的提示示例。
提示 |
生成的 SQL 查询 |
显示跨可用区的流量 |
选择来源和目的地位于不同区域的流。 |
显示具有 SSH 流量的资源 |
选择具有 SSH 流量的流。 |
显示流量最高的前 10 个虚拟机 |
选择发送的字节数最多的 10 个虚拟机。 |
显示来自 10.10.0.10 和发送到 10.10.0.10 的流量 |
选择 10.10.0.10 为来源 IP 地址或目的地 IP 地址的流。 |
显示 example-instance 到互联网的流量 |
选择从名为 example-instance 的来源虚拟机实例到互联网的流。 |
显示过去三天内来自网关的流量 |
选择过去三天内以 Cloud Interconnect 的 VLAN 连接和 Cloud VPN 隧道为来源的流。 |
如需生成并运行 SQL 查询,请执行以下操作:
在 Google Cloud 控制台中,前往 Flow Analyzer 页面。
前往 Flow Analyzer
点击 pen_spark编写 Cloud Assist 查询。
描述要查看的日志数据,或选择预定义的提示。
点击 Generate SQL。
查看回答并运行查询:
- 如需在 Flow Analyzer 中运行查询,请点击在 Flow Analyzer 中探索标签页,然后点击在 Flow Analyzer 中打开。
- 如需在 Log Analytics 中运行查询,请点击在 Log Analytics 中运行 SQL 标签页,然后点击在 Log Analytics 中运行 SQL。
运行查询后,您可以选择根据需要修改填充的值。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-25。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[],[],null,["# Write queries with Gemini assistance\n\n| **Preview\n| --- [Gemini Cloud Assist](/gemini/docs/cloud-assist/overview)**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document describes how you can use natural language prompts to generate\nSQL queries for VPC Flow Logs. To generate SQL queries for\nVPC Flow Logs, you interact\nwith [Gemini Cloud Assist](/gemini/docs/cloud-assist/overview)\nin Flow Analyzer.\n\nLearn [how and when Gemini\nfor Google Cloud uses your data](/gemini/docs/discover/data-governance).\n\nBefore you begin\n----------------\n\n- [Set up Gemini Cloud Assist](/gemini/docs/cloud-assist/set-up-gemini)\n in a Google Cloud project that contains a Cloud Logging bucket with flow\n logs.\n\n- Make sure that the log bucket is\n [upgraded to use Log Analytics](/logging/docs/buckets#upgrade-bucket)\n and you have the\n [required roles and permissions](/network-intelligence-center/docs/flow-analyzer/analyze-traffic-flows#required_roles_and_permissions)\n to query the flow logs.\n\nGenerate a SQL query\n--------------------\n\n| As an early-stage technology, Gemini for Google Cloud\n| products can generate output that seems plausible but is factually incorrect. We recommend that you\n| validate all output from Gemini for Google Cloud products before you use it.\n| For more information, see\n| [Gemini for Google Cloud and responsible AI](/gemini/docs/discover/responsible-ai).\n\nTo interact with Gemini Cloud Assist, use the\npen_spark**Compose a Cloud Assist Query**\nprompt field. In the prompt field, you can enter a prompt or select a\npredefined prompt. The following table provides examples of prompts that\nyou can use.\n\nTo generate and run a SQL query, do the following:\n\n1. In the Google Cloud console, go to the **Flow Analyzer** page.\n\n [Go to Flow Analyzer](https://console.cloud.google.com/net-intelligence/flow-analyzer)\n2. Click pen_spark**Compose a Cloud\n Assist Query**.\n\n3. Describe the log data that you want to view or\n select a predefined prompt.\n\n4. Click **Generate SQL**.\n\n5. Review the response and run the query:\n\n - To run the query in Flow Analyzer, click the **Explore in Flow Analyzer** tab and then click **Open in Flow Analyzer**.\n - To run the query in Log Analytics, click the **Run SQL in Log Analytics** tab and then click **Run SQL in Log Analytics**.\n\nAfter you run the query, you can optionally modify the populated\nvalues as needed.\n\nWhat's next\n-----------\n\n- Read [Gemini for Google Cloud overview](/gemini/docs/overview).\n- Learn [how Gemini for Google Cloud uses your data](/gemini/docs/discover/data-governance)."]]