9.2. 自定义监控和日志记录


指标由 AnsiblePodmanGoogle Ops 代理提供。Google Ops Agent 和 Podman 安装在自动化控制器和自动化中心虚拟机实例上,但 Ansible 指标仅安装在自动化中心实例上。

一个可配置的进程(collector)在每个自动化控制器虚拟机实例和自动化中心虚拟机实例上运行,将收集的 Ansible 和 Podman 指标导出到 Google Cloud Platform 监控。由于 Google Ops Agent 是 Google Cloud 解决方案的一部分,它拥有自己的配置文件。

Google Ops Agent 还负责日志配置。

为监控和日志记录功能分别启用服务 API monitoring.googleapis.comlogging.googleapis.com

配置

配置文件位于每个自动化控制器和自动化中心共享的磁盘上。修改文件 /aap/bootstrap/config_file_templates/<controller|hub>/monitoring.yml,以配置所有导出器和代理。

9.2.1. Ansible 和 podman 配置

自动化控制器或自动化中心上的 /aap/bootstrap/config_file_templates/<controller|hub>/monitoring.yaml 文件包含收集 Ansible 和 podman 指标到 GCP 的配置。

自动化控制器的默认配置如下:

# This value will be set at deployment time.
# Set to zero if monitoringEnabled is false otherwise 59s
# The collection interval for each collector will be the minimum
# between the defaultCollectorInterval and all send Interval
# of a given collector
# NB: The awx exported should not run on controllers as
# it duplicates the number of records sent to GCP Monitoring

defaultCollectorInterval: $DEFAULT_COLLECTOR_INTERVAL
collectors:
- name: podman
 endpoint: http://localhost:9882/podman/metrics
 enabled: true

# list of metrics to exclude
# excludedMetrics:
# - podman_container_created_seconds

 metrics:
 - name: podman_container_exit_code
   # interval on which the metric must be pushed to gcp
   sendInterval: 59s
Copy to Clipboard Toggle word wrap

Automation hub 的默认配置如下:

# This value will be set at deployment time.
# Set to zero if monitoringEnabled is false otherwise 59s
# The collection interval for each collector will be the minimum
# between the defaultCollectorInterval and all sendInterval
# of a given collector
# NB: The awx exporter should not run on controllers as
# it duplicates the number of records sent to GCP Monitoring

defaultCollectorInterval: 59s
collectors:
- name: awx
 userName: admin
 endpoint: http://<Controller_LB_IP>/api/v2/metrics/
 enabled: true
 metrics:
 - name: awx_inventories_total
   # interval on which the metric must be pushed to gcp
   sendInterval: 59s
- name: podman
 endpoint: http://localhost:9882/podman/metrics
 enabled: true

# list of metrics to exclude
#  excludedMetrics:
#  - podman_container_created_seconds

 metrics:
 - name: podman_container_exit_code
   # interval on which the metric must be pushed to gcp
   sendInterval: 59s
Copy to Clipboard Toggle word wrap

其中 collectors 是一个配置数组,每个收集器有一个项目,即 awx 和 podman。

awx 收集器需要身份验证,因此 userName 必须设置为 admin。密码从 secret-manager 检索。

不应更改端点。

defaultCollectorInterval 指定导出器从指标端点收集信息并将其发送到 Google Cloud Platform Monitoring 的默认间隔。

将此值设置为 0 或省略此属性会禁用所有收集器。

通过将 enabled 设为 truefalse,可以单独启用或禁用每个收集器。

收集器返回按系列分组的所有可用指标,但您可以通过在数组 exclude Metrics 中添加名称来排除不应发送到 Google Cloud Platform Monitoring 的系列。

对于所有其他系列指标,您可以指定要收集的时间间隔并将其发送到 Google Cloud Platform Monitoring。收集器间隔是所有系列指标间隔和 defaultCollectorInterval 之间的最小值。这样可确保为发送到 Google Cloud Platform Monitoring 的每个指标集合集合。

9.2.2. Google Cloud ops 代理配置

配置文件详细信息可在此位置找到。

配置文件位于 /etc/google-cloud-ops-agent/config.yml 中。

这是到共享磁盘 /aap/bootstrap/config_file_templates/controller/gcp-ops-agent-config.yml/aap/bootstrap/config_file_templates/hub/gcp-ops-agent-config.yml 的符号链接,具体取决于组件类型。

配置文件包含多个接收器,指定 ops 代理应收集的内容。

您在部署过程中的 Connect LoggingConnect Metrics 决定了哪些管道包含在文件中,因此会收集哪些日志和指标并发送到 GCP。

如果需要在部署后添加更多管道,您可以在 /aap/bootstrap/config_file_templates/hub|controller/gcp-ops-agent-config.yml 中插入它们。

如果最后 10 分钟内更改了 gcp-ops-agent-config.yml,则 crontab 作业会重新启动代理。代理在重启后重新读取其配置。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat