【问题标题】:GCP Compute Engine won't show memory metricsGCP Compute Engine 不会显示内存指标
【发布时间】:2022-06-15 22:01:08
【问题描述】:

我希望我的计算引擎 VM 在控制台中显示内存使用指标,我去了 this page 并安装了 Ops-Agents,重新启动服务并转到 VM 可观察性部分,但仍然看到一条消息说代理是未安装(在内存使用指标中): 我想也许默认情况下没有安装内存使用(它没有在任何地方提到,只是一个猜测),我需要修改配置。我去了this docs,把这段代码加到/etc/google-cloud-ops-agent/config.yaml

metrics:
  receivers:
    agent.googleapis.com/memory/bytes_used:
      type: hostmetrics
      collection_interval: 1m

根据文档,当代理重新启动时,此配置将与内置配置合并。 我重新启动代理服务,返回仪表板,但仍然显示消息“需要 Ops Agent”。 我不知道我做错了什么,IMO 的文档真的很差,我找不到任何关于如何打开内存使用指标的示例。

编辑 运行sudo systemctl status google-cloud-ops-agent"*" 我可以看到这个错误信息:

otelopscol[2763]: 2022-05-02T14:07:02.780Z#011error#011collector@v0.26.1-0.20220307211504-dc45061a44f9/metrics.go:235#011可以 不将时间序列导出到 GCM#011{"error": "rpc error: code = InvalidArgument desc = 名称必须以 '{resource_container_type}/{resource_container_id}',得到:projects/"}

EDIT2 如果我通过控制台单击安装,我会看到以下安装说明:

:> agents_to_install.csv && \
echo '"projects/<project>/zones/europe-west1-b/instances/<instance>","[{""type"":""ops-agent""}]"' >> agents_to_install.csv && \
curl -sSO https://dl.google.com/cloudagents/mass-provision-google-cloud-ops-agents.py && \
python3 mass-provision-google-cloud-ops-agents.py --file agents_to_install.csv

与这里的不同:https://cloud.google.com/monitoring/agent/monitoring/installation#joint-install

curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh --also-install

不确定安装了什么,都试过了。

【问题讨论】:

  • 在您的用户配置(与内置配置合并)中,您定义了一个接收器,我不确定名称“agent.googleapis.com/memory/bytes_used”是否会导致重新启动服务时看到的错误。

标签: google-cloud-platform google-compute-engine google-cloud-ops-agent


【解决方案1】:

关于您的问题“我找不到任何关于如何打开内存使用指标的示例”“是否已安装但需要针对内存使用指标修改配置?” 答案是肯定的,您需要根据here 的指定自定义要启用的一组或多组指标。 metric type 字符串必须以agent.googleapis.com/agent/ 为前缀。对于内存指标,示例如下:

agent.googleapis.com/agent/memory_usage

agent.googleapis.com/agent/memory_utilization

我正在共享here的表格中的条目中省略了该前缀。

现在,您需要根据需要从中获取指标的目标 VM 选择设置,例如,仅限 Linux:

agent.googleapis.com/memory/usage

此外,您还可以使用其他选项,更改最终标准,例如:

agent.googleapis.com/memory/bytes_used

确保您没有错过任何有关代理安装的信息,请按照these 说明从 CLI 安装它。然后转到:

  • Resources -> Instances:您应该会看到您的 VM 实例。

  • 单击您的实例 -> 单击代理 -> 向下滚动,您会看到您的内存和交换使用情况。

最后,您可以按照 Ops Agent issues 的故障排除指南,以及更多经验案例和解决方案 Memory Usage Monitoring in GCP Compute EngineNo metric found 这些线程。

【讨论】:

  • "'它是否已安装,但需要针对内存使用指标修改配置?'"答案是肯定的" - 显然没有,我刚刚启动了一个新的小实例,安装了代理,然后我可以在没有自定义配置的情况下查看内存使用指标。我有错误的实例和新实例之间的唯一区别是有错误的实例具有“Legacy Agent”,如监控虚拟机实例部分所示。我不知道为什么,我在这两种情况下都安装了具有相同安装指南(您提供的那个)的代理
  • 那么,它现在在这两种情况下都有效吗?如果您在原始实例中仍然遇到问题,您能否按照我与您分享的 CLI 中的安装指南和故障排除步骤进行操作?
  • 感谢您的帮助。原来的那个不起作用,我尝试了故障排除指南,运行sudo systemctl status google-cloud-ops-agent"*" 时我在日志中看到的唯一错误是could not export time series to GCM {"error": "rpc error: code = InvalidArgument desc = Name must begin with '{resource_container_type}/{resource_container_id}', got: projects/"},它从collector@v0.26.1-0.20220307211504-dc45061a44f9/metrics.go:235 触发。我想这是问题的原因,但我找不到解决此问题的方法。
【解决方案2】:

您是否尝试过在 Cloud Shell 中使用 Edit2 的内容运行它? 当我运行下面的文档时它不起作用,因为我还通过 IAP 连接到 SSH。 当我在 Cloud Shell 中运行它时,它起作用了。

https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/installation#install-latest-version

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-11
  • 1970-01-01
  • 1970-01-01
  • 2019-05-05
  • 2021-04-20
  • 1970-01-01
相关资源
最近更新 更多