使用 Gemini 輔助功能編寫查詢
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本文說明如何使用自然語言提示,為虛擬私有雲流量記錄產生 SQL 查詢。如要生成 VPC 流量記錄的 SQL 查詢,請在 Flow Analyzer 中與 Gemini Cloud Assist 互動。
瞭解 Gemini for Google Cloud 如何使用您的資料,以及使用時機。
事前準備
生成 SQL 查詢
如要與 Gemini Cloud Assist 互動,請使用「編寫 Cloud Assist 查詢」pen_spark提示欄位。在提示欄位中,您可以輸入提示或選取預先定義的提示。下表提供可使用的提示範例。
提示 |
生成的 SQL 查詢 |
顯示跨可用區流量 |
選取來源和目的地位於不同區域的流程。 |
顯示有 SSH 流量的資源 |
選取有 SSH 流量的流程。 |
顯示流量最多的前 10 個 VM |
選取傳送位元組數最多的 10 個 VM。 |
Show me traffic from and to 10.10.0.10 |
選取 10.10.0.10 是來源或目的地 IP 位址的流程。 |
Show me traffic from example-instance to the internet |
選取從名為 example-instance 的來源 VM 執行個體到網際網路的流程。 |
顯示過去三天的閘道流量 |
選取過去三天內,以 Cloud Interconnect 和 Cloud VPN 通道的 VLAN 連結為來源的流程。 |
如要生成及執行 SQL 查詢,請按照下列步驟操作:
前往 Google Cloud 控制台的「Flow Analyzer」頁面。
前往 Flow Analyzer
按一下「pen_spark」pen_spark撰寫 Cloud Assist 查詢。
描述要查看的記錄資料,或選取預先定義的提示。
按一下 [Generate SQL]。
查看回覆並執行查詢:
- 如要在 Flow Analyzer 中執行查詢,請按一下「Explore in Flow Analyzer」分頁標籤,然後點選「Open in Flow Analyzer」。
- 如要在記錄檔分析中執行查詢,請按一下「在記錄檔分析中執行 SQL」分頁標籤,然後點選「在記錄檔分析中執行 SQL」。
查詢執行完畢後,您可以視需要修改填入的值。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],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)."]]