You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCP debug-agent实验性Inspector功能如何使用?文档有但控制台无入口

Using the Experimental Inspector Feature for @google-cloud/debug-agent

Great question! Since this is an experimental feature, it doesn’t show up in the Cloud Console UI—you’ll need to enable and access it manually through code configuration and network forwarding. Here’s how to get it working:

Step 1: Enable the Inspector Feature

First, you have to explicitly turn on the Inspector when initializing the debug agent in your Node.js code. Add the inspector: true flag to the agent’s startup config:

const debugAgent = require('@google-cloud/debug-agent').start({
  projectId: 'your-gcp-project-id',
  inspector: true, // Enable the experimental Inspector feature
  // Add other required configs like serviceName, serviceVersion as needed
});

Step 2: Access the Inspector Interface

The way you access the Inspector depends on where your application is deployed:

For Kubernetes Clusters

Yes, you can use kubectl tools to access it—here are two reliable methods:

  1. Port Forwarding (Simplest Approach)
    Run this command to forward the default Inspector port (9229) from your pod to your local machine:

    kubectl port-forward <your-pod-name> 9229:9229 -n <your-namespace>
    

    Then open your browser and navigate to http://localhost:9229—you’ll see the Node.js Inspector interface load up.

  2. kubectl Proxy
    Start the kubectl proxy first:

    kubectl proxy
    

    Then access the Inspector via the proxy URL:

    http://localhost:8001/api/v1/namespaces/<your-namespace>/pods/<your-pod-name>:9229/proxy/
    

    Note: Make sure your Deployment YAML exposes the 9229 port (or your custom Inspector port) in the container spec:

    containers:
      - name: your-app-container
        image: your-app-image
        ports:
          - containerPort: 9229
            name: inspector-port
    

For Virtual Machines (VMs)

If your app runs on a GCP VM:

  • Ensure your VM’s firewall allows inbound traffic on port 9229 (create a firewall rule if it doesn’t exist).
  • Access the Inspector directly using your VM’s external IP: http://<vm-external-ip>:9229

Key Notes to Keep in Mind

  • This is an experimental feature, so behavior might change in future versions of the debug agent—use it cautiously in production environments.
  • Verify your Node.js version supports the Inspector API (Node.js 6.3.0+ includes it, but we recommend using a recent LTS version for stability).
  • For Cloud Run deployments, you’ll need to adjust your service configuration to expose the 9229 port and enable direct access (keep in mind Cloud Run’s serverless nature might have limitations here).

内容的提问来源于stack exchange,提问作者knownasilya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:12:26