准备工作
-
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Trusted Cloud by S3NS 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
- Set a default region and zone.
-
Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) -
如需在实例上安装 Ops Agent,请执行以下操作:
OSPolicyAssignment Editor (
roles/osconfig.osPolicyAssignmentEditor
)
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
如需了解详情,请参阅 Trusted Cloud 身份验证文档中的使用 REST 时进行身份验证。
所需的角色
如需获得为 Ops Agent 监控和日志记录创建实例所需的权限,请让管理员向您授予项目的以下 IAM 角色:
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
在实例上安装 Ops Agent
您只能在现有实例上安装 Ops Agent。如需在单个实例或实例舰队上安装 Ops Agent,您可以使用Trusted Cloud 控制台、gcloud CLI 或自动化工具。如需查看相关说明,请参阅安装 Ops Agent。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-06-20。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-06-20。"],[[["The Ops Agent collects telemetry data for instances, aiding in troubleshooting and performance tuning."],["Authentication to Google Cloud services and APIs is necessary, and can be done through the Google Cloud console, gcloud CLI, or REST API."],["Creating an instance for Ops Agent monitoring and logging can be done via the Google Cloud console by enabling the \"Install the Ops Agent for Monitoring and Logging\" option during instance creation."],["The Ops Agent can also be installed on existing instances using the Google Cloud console, gcloud CLI, or an automation tool."],["To install the agent, required roles include Compute Instance Admin (v1) and OSPolicyAssignment Editor."]]],[]] -