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

使用gcloud客户端向Vertex AI Endpoint写日志报501错误如何解决?

错误诱因

你为Google Cloud Logging客户端错误配置了服务端点。你设置的us-east1-aiplatform.googleapis.com是Vertex AI业务的专属服务地址,仅提供Vertex AI相关的API接口,并不支持Cloud Logging的/google.logging.v2.LoggingServiceV2/WriteLogEntries日志写入接口,因此服务端返回501方法未实现的错误,和你已经确认的API启用状态、服务账号权限无关。

解决方案
  • 移除Logging客户端构造参数中指向Vertex AI服务地址的client_options配置,Cloud Logging客户端默认会使用官方正确的日志服务端点,不需要额外手动配置。
  • 如果你需要将日志写入指定的区域存储(比如要求日志存储在us-east1本地区域),请将api_endpoint替换为对应区域的Cloud Logging服务端点,格式为{region}-logging.googleapis.com,us-east1区域对应的值为us-east1-logging.googleapis.com。
  • 你原有代码中关联Vertex AI端点的Resource配置是正确的,不需要修改,该配置会自动将写入的日志和对应区域的Endpoint资源做绑定,在Cloud Logging控制台可以直接通过Endpoint资源筛选到对应日志。
修正后的核心代码示例
# 其余导入和原有逻辑保持不变
client = logging_v2.client.Client(
    credentials=credentials,
    # 无需指定Vertex AI的服务端点,如果需要区域日志则取消下一行注释
    # client_options=ClientOptions(api_endpoint="us-east1-logging.googleapis.com"),
)
# 后续handler的Resource配置保持原有即可

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.25 23:06:03