記錄檔和指標

本頁面說明 Secure Web Proxy 如何記錄各種作業資訊,以及如何使用 Cloud Monitoring API 指標分析 Proxy 的效能。

記錄

Secure Web Proxy 會使用 Cloud Logging 擷取資訊,並在下列主要領域執行各種工作:

  • 監控與法規遵循

    • 強制遵守法規、提升網路安全性,並掌握傳送至允許外部目的地的外送網路流量。
    • 取得工作負載流量的寶貴控制層和可視性。
    • 取得重要洞察資料,有效監控資安營運中心 (SOC)。
    • 使用記錄檔偵測及追蹤安全事件,主動應對威脅。
  • 部署和設定

    • 追蹤初始基礎架構設定、使用者帳戶建立和設定變更。
    • 監控潛在錯誤,確保部署作業順利且安全。
    • 瞭解政策調整項的影響,並盡可能提升防護成效。

記錄類型

Secure Web Proxy 會使用 Logging 擷取及儲存下列類型的記錄:

  • Cloud 稽核記錄:記錄管理變更和 Secure Web Proxy 資源的資料存取權。這些記錄包括:

  • Proxy 交易記錄:擷取 Secure Web Proxy 處理的特定網路要求詳細資料。這些記錄可提供流量流動、政策強制執行,以及 Secure Web Proxy 執行個體效能的洞察資訊。

設定記錄檔快訊

您可以針對安全網頁 Proxy 寫入記錄檔的事件設定快訊,例如流量遭拒或符合特定規則。如需設定這類快訊的一般操作說明,請參閱「設定記錄檔型快訊」。

以下列舉幾個查詢範例,可用於設定 Secure Web Proxy 的記錄檔式快訊:

Secure Web Proxy 政策拒絕流量時發出快訊

當 Secure Web Proxy 政策拒絕要求時,請使用下列查詢觸發快訊:

logName="projects/PROJECT_ID/logs/networkservices.googleapis.com%2Fgateway_requests"
resource.type="networkservices.googleapis.com/Gateway"
jsonPayload.enforcedGatewaySecurityPolicy.matchedRules.action="DENIED"

PROJECT_ID 替換為目標Google Cloud 專案的 ID。

Secure Web Proxy 規則拒絕流量的警示

當特定 Secure Web Proxy 規則 (例如 my-specific-deny-rule) 拒絕要求時,請使用下列查詢觸發快訊:

logName="projects/PROJECT_ID/logs/networkservices.googleapis.com%2Fgateway_requests"
resource.type="networkservices.googleapis.com/Gateway"
jsonPayload.enforcedGatewaySecurityPolicy.matchedRules.action="DENIED"
AND jsonPayload.enforcedGatewaySecurityPolicy.matchedRules.name=~"projects/PROJECT_ID/locations/REGION/gatewaySecurityPolicies/POLICY_NAME/rules/my-specific-deny-rule$"

更改下列內容:

  • PROJECT_ID:目標 Google Cloud 專案的 ID
  • REGION:Secure Web Proxy 執行個體的區域
  • POLICY_NAME:Secure Web Proxy 政策的名稱

高延遲要求警報

如要接收要求延遲時間超過特定值 (例如 5 秒) 的通知,請使用下列查詢:

logName="projects/'PROJECT_ID'/logs/networkservices.googleapis.com%2Fgateway_requests"
resource.type="networkservices.googleapis.com/Gateway"
latency >= "5s"

PROJECT_ID 替換為目標Google Cloud 專案的 ID。

在 Cloud Logging 查看記錄

  1. 前往 Google Cloud 控制台的「Logs Explorer」頁面。

    前往「Logs Explorer」頁面

  2. 選取 Google Cloud 專案。

  3. 使用下拉式選單選取networkservices.googleapis.com/Gateway資源或 Secure Web Proxy 執行個體。

詳情請參閱「使用 Logs Explorer」。

記錄項目範例

Secure Web Proxy 每次處理要求時,都會產生詳細的記錄項目,追蹤其動作和套用的政策。以下範例說明 Secure Web Proxy 記錄的運作方式。

允許記錄項目範例

下列記錄項目顯示,Secure Web Proxy 執行個體攔截並檢查 www.example.com 的 HTTPS 流量,然後允許流量前往目的地網站。政策和規則名稱分別為 swp-policyallow-port-443

欄位
enforcedGatewaySecurityPolicy
{
        "requestWasTlsIntercepted": true,
        "hostname": "www.example.com",
        "matchedRules": [
          {
            "action": "ALLOWED",
            "name": "projects/76537/locations/us-central1/gatewaySecurityPolicies/swp-policy/rules/allow-port-443"
          }
        ]
      }
httpRequest
{
        "requestMethod": "GET",
        "requestUrl": "https://www.example.com/",
        "requestSize": "41",
        "status": 200,
        "responseSize": "1446",
        "userAgent": "curl/7.74.0",
        "remoteIp": "10.128.0.12:35418",
        "serverIp": "93.184.216.34:443",
        "latency": "0.051800s",
        "protocol": "HTTP/2"
      }
resource
{
        "type": "networkservices.googleapis.com/Gateway",
        "labels": {
          "gateway_name": "multi-level-tlds",
          "network_name": "projects/76537/global/networks/default",
          "location": "us-central1",
          "resource_container": "",
          "gateway_type": "SECURE_WEB_GATEWAY"
        }
      }
timestamp "2024-02-15T16:56:19.570534Z"
severity 「INFO」
logName "projects/76537/logs/networkservices.googleapis.com%2Fgateway_requests"
receiveTimestamp "2024-02-15T16:56:20.714988329Z"

拒絕記錄項目範例

這筆記錄項目顯示,Secure Web Proxy 執行個體檢查了 www.example.com:443 的流量,並因 Secure Web Proxy 政策中的 default_denied 規則而拒絕 HTTPS 要求。

欄位
enforcedGatewaySecurityPolicy
{
        "hostname": "www.example.com:443",
        "matchedRules": [
          {
            "name": "default_denied",
            "action": "DENIED"
          }
        ]
      }
httpRequest
{
        "requestMethod": "CONNECT",
        "requestSize": "122",
        "status": 403,
        "responseSize": "141",
        "userAgent": "curl/7.74.0",
        "remoteIp": "10.128.0.12:36338",
        "latency": "0.000133s",
        "protocol": "HTTP/1.1"
      }
resource
{
        "type": "networkservices.googleapis.com/Gateway",
        "labels": {
          "gateway_type": "SECURE_WEB_GATEWAY",
          "resource_container": "",
          "location": "us-central1",
          "network_name": "projects/gcp-1768/global/networks/default",
          "gateway_name": "high-latency-repro"
        }
      }
timestamp "2024-02-15T16:55:00.089727Z"
severity 「WARNING」
logName "projects/gcp-1768/logs/networkservices.googleapis.com%2Fgateway_requests"
receiveTimestamp "2024-02-15T16:55:04.456901833Z"

指標

您可以透過 Cloud Monitoring API 指標,觀察 Secure Web Proxy 執行個體的效能、健康狀態和用量。

受控資源

系統會將 Secure Web Proxy 的指標匯出至下列受監控資源:

  • networkservices.googleapis.com/Gateway:代表 Secure Web Proxy 閘道執行個體。

下表說明 networkservices.googleapis.com/Gateway 可用的資源。您可以使用這些資源來篩選及匯總監控資料。

標籤 說明
resource_container 與 Secure Web Proxy 閘道執行個體相關聯的專案 ID。
location Google Cloud 部署閘道的區域。
gateway_id Secure Web Proxy 閘道執行個體的專屬名稱。
gateway_type 閘道類型,設為 SECURE_WEB_GATEWAY
network_name 與閘道相關聯的虛擬私有雲 (VPC) 網路名稱。

可用的指標

Gateway 資源提供下列指標。所有指標都會加上 networkservices.googleapis.com/https/ 前置字元。

指標類型 顯示名稱 種類;類型;單位 說明
networkservices.googleapis.com/https/request_count 要求數量 DELTAINT641 Proxy 處理的要求總數。
networkservices.googleapis.com/https/request_bytes_count 要求位元組數 DELTAINT64By 要求中收到的位元組總數。
networkservices.googleapis.com/https/response_bytes_count 回應位元組數 DELTAINT64By 回應中傳送的位元組總數。
networkservices.googleapis.com/https/total_latencies 總延遲時間 DELTADISTms 從收到要求的第一個位元組,到傳送回應的最後一個位元組所經過的時間。
networkservices.googleapis.com/https/backend_latencies 後端延遲時間 DELTADISTms 從要求傳送至後端,到收到回應的第一個位元組之間的時間。

建立自訂資訊主頁

如要建立自訂資訊主頁,以便顯示安全無虞的網路 Proxy 執行個體的成效和流量趨勢,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的「Dashboards」(資訊主頁) 頁面。

    前往「Dashboards」(資訊主頁)

  2. 按一下「建立自訂資訊主頁」

  3. 按一下「新增小工具」,然後選取「折線圖」選項。

  4. 在「指標」欄位中,搜尋 networkservices.googleapis.com/https/request_count

  5. 如果您已設定多個 Secure Web Proxy 執行個體,可以在「篩選器」欄位中依 gateway_id 進行篩選。

  6. 在「Aggregation」部分中,將「Alignment Period」設為 1 minute,然後選取「Aligner」rate

    這會將原始要求資料轉換為每秒要求數率,方便您查看及分析一段時間內一致的流量趨勢。

  7. 如要儲存小工具,請按一下「套用」

後續步驟