代码之家  ›  专栏  ›  技术社区  ›  Avishay28

GCP计算引擎不会显示内存指标

  •  0
  • Avishay28  · 技术社区  · 4 年前

    我想让我的计算引擎VM在控制台中显示内存使用指标,我去了 this page 并安装Ops agent,重新启动服务并转到VM可观察性部分,但仍然看到一条消息,即代理未安装(在内存使用度量中): enter image description here 我想可能默认情况下没有安装内存使用情况(任何地方都没有提到,只是猜测),我需要修改配置。我去了 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"*" 我可以看到以下错误消息:

    奥特洛普斯科尔[2763]: 2022-05-02T14:07:02.780Z#011错误# [email protected] /metrics.go:235#011can 不将时间序列导出到GCM#011{“error”:“rpc error:code= InvalidArgument desc=名称必须以开头 “{resource_container_type}/{resource-container_id}”,获取:projects/“}

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

    :> 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
    

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

    0 回复  |  直到 4 年前
        1
  •  0
  •   Nestor Daniel Ortega Perez    4 年前

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

    agent.googleapis.com/agent/memory_usage
    
    agent.googleapis.com/agent/memory_utilization
    

    这个前缀已经从Im共享的表中的条目中省略了 here

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

    agent.googleapis.com/memory/usage
    

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

    agent.googleapis.com/memory/bytes_used
    

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

    • 资源->实例:您应该看到您的VM实例。

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

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

        2
  •  0
  •   Promise Preston    2 年前

    当我试图在GCP计算虚拟机中显示内存度量时,我也有同样的担忧。

    这个脚本对我有用:

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

    参考文献:

    推荐文章