Google Cloud Platform:如何监控VM实例的内存使用情况
Google Cloud Platform: how to monitor memory usage of VM instances
我最近迁移到 Google Cloud Platform,我非常喜欢它。
但是我找不到监控 Dataproc VM 实例的内存使用情况的方法。正如您在附件中看到的,控制台提供了有关 CPU、磁盘和网络的利用率信息,但不提供有关内存的利用率信息。
在不知道使用了多少内存的情况下,如何知道是否需要额外的内存?
那么您可以使用 /proc/meminfo 虚拟文件系统来获取有关当前内存使用情况的信息。您可以创建一个简单的 bash 脚本,从 /proc/meminfo 读取内存使用信息。该脚本可以作为 cron 作业服务定期 运行。如果内存使用量超过给定阈值,脚本可以发送警报电子邮件。
看到这个link:https://pakjiddat.netlify.app/posts/monitoring-cpu-and-memory-usage-on-linux
通过安装 Stackdriver agent in GCE VMs additional metrics like memory can be monitored. Stackdriver also offers you alerting and notification features. Nevertheless agent metrics are only available for premium tier accounts.
对于 Dataproc VM,请参阅此。
代理指标页面可能会有用:
https://cloud.google.com/monitoring/api/metrics_agent
您需要安装 stackdriver。参见:https://app.google.stackdriver.com/?project="your project name"
stackdriver 指标页面将提供一些指导。您需要更改 "project name"(例如 sinuous-dog-133823)以适合您的帐户:
此 REST 调用将为您提供 cpu 用法。您需要修改参数以适合您的项目名称(例如 sinuous-dog-133823)和其他参数以满足需要。
GET /v3/projects/sinuous-cat-233823/timeSeries?filter=metric.type="agent.googleapis.com/memory/bytes_used" resource.type="gce_instance"& aggregation.crossSeriesReducer=REDUCE_NONE& aggregation.alignmentPeriod=+60s& aggregation.perSeriesAligner=ALIGN_MEAN& secondaryAggregation.crossSeriesReducer=REDUCE_NONE& interval.startTime=2019-03-06T20:40:00Z& interval.endTime=2019-03-07T02:51:00Z& $unique=gc673 HTTP/1.1
Host: content-monitoring.googleapis.com
authorization: Bearer <your token>
cache-control: no-cache
Postman-Token: 039cabab-356e-4ee4-99c4-d9f4685a7bb2
stackdriver agent目前只支持监控E2系列的RAM。不支持 N1、N2 等其他实例类型。
查看支持内容的最新文档; https://cloud.google.com/monitoring/api/metrics_gcp#gcp-compute
这里回答最多up-to-date
如何在 GCP 中查看内存使用情况?
- 在您的虚拟机上安装代理。不到 5 分钟。
curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh
sudo apt-get update
sudo apt-get install stackdriver-agent
代码片段应安装最新版本的代理,但对于 up-to-date 指南,您始终可以参考
https://cloud.google.com/monitoring/agent/installation#joint-install.
- 安装后,一两分钟后,您应该会在 GCP 的“监控”部分看到其他指标。
https://console.cloud.google.com/monitoring
解释以及为什么默认情况下它是不可见的?
可以在不同的地方收集指标(例如 CPU 使用情况或内存使用情况)。例如,CPU usage 是主机(具有特殊软件的机器 运行 您的虚拟机)可以收集的一条信息。
内存使用和虚拟机的问题在于,它是管理它的底层操作系统(虚拟机的操作系统)。主机无法真正知道使用了多少,因为它在分配给该虚拟机的内存中所能看到的只是字节流。
这就是为什么有一个想法要在该虚拟机中安装 agents,以便从内部 收集指标并将其发送到某个地方他们可以被解释。有许多类型的代理可用,但 Google 推广自己的代理 - Monitoring Agent - 并且它很好地集成到整个 GCP 套件中。
VM 内存指标默认不可用,它需要 Cloud Monitoring Agent 1。
您显示的UI是Dataproc,它已经安装了代理,但默认情况下是禁用的,您不必重新安装它。要为 Dataproc 集群启用 Cloud Monitoring Agent,请在创建集群时设置 --properties dataproc:dataproc.monitoring.stackdriver.enable=true
2。然后您可以监控 VM 内存并在 Cloud Monitoring UI(尚未与 Dataproc UI 集成)中创建警报。
另请参阅此相关问题:
这篇文章现已过时,因为 Stackdriver 现在是旧版代理。这已被 Ops Agent 取代。请阅读 GCP 上有关迁移到 Ops Agent 的最新文章
我最近迁移到 Google Cloud Platform,我非常喜欢它。
但是我找不到监控 Dataproc VM 实例的内存使用情况的方法。正如您在附件中看到的,控制台提供了有关 CPU、磁盘和网络的利用率信息,但不提供有关内存的利用率信息。
在不知道使用了多少内存的情况下,如何知道是否需要额外的内存?
那么您可以使用 /proc/meminfo 虚拟文件系统来获取有关当前内存使用情况的信息。您可以创建一个简单的 bash 脚本,从 /proc/meminfo 读取内存使用信息。该脚本可以作为 cron 作业服务定期 运行。如果内存使用量超过给定阈值,脚本可以发送警报电子邮件。
看到这个link:https://pakjiddat.netlify.app/posts/monitoring-cpu-and-memory-usage-on-linux
通过安装 Stackdriver agent in GCE VMs additional metrics like memory can be monitored. Stackdriver also offers you alerting and notification features. Nevertheless agent metrics are only available for premium tier accounts.
对于 Dataproc VM,请参阅此
代理指标页面可能会有用: https://cloud.google.com/monitoring/api/metrics_agent
您需要安装 stackdriver。参见:https://app.google.stackdriver.com/?project="your project name"
stackdriver 指标页面将提供一些指导。您需要更改 "project name"(例如 sinuous-dog-133823)以适合您的帐户:
此 REST 调用将为您提供 cpu 用法。您需要修改参数以适合您的项目名称(例如 sinuous-dog-133823)和其他参数以满足需要。
GET /v3/projects/sinuous-cat-233823/timeSeries?filter=metric.type="agent.googleapis.com/memory/bytes_used" resource.type="gce_instance"& aggregation.crossSeriesReducer=REDUCE_NONE& aggregation.alignmentPeriod=+60s& aggregation.perSeriesAligner=ALIGN_MEAN& secondaryAggregation.crossSeriesReducer=REDUCE_NONE& interval.startTime=2019-03-06T20:40:00Z& interval.endTime=2019-03-07T02:51:00Z& $unique=gc673 HTTP/1.1
Host: content-monitoring.googleapis.com
authorization: Bearer <your token>
cache-control: no-cache
Postman-Token: 039cabab-356e-4ee4-99c4-d9f4685a7bb2
stackdriver agent目前只支持监控E2系列的RAM。不支持 N1、N2 等其他实例类型。
查看支持内容的最新文档; https://cloud.google.com/monitoring/api/metrics_gcp#gcp-compute
这里回答最多up-to-date
如何在 GCP 中查看内存使用情况?
- 在您的虚拟机上安装代理。不到 5 分钟。
curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh
sudo apt-get update
sudo apt-get install stackdriver-agent
代码片段应安装最新版本的代理,但对于 up-to-date 指南,您始终可以参考 https://cloud.google.com/monitoring/agent/installation#joint-install.
- 安装后,一两分钟后,您应该会在 GCP 的“监控”部分看到其他指标。 https://console.cloud.google.com/monitoring
解释以及为什么默认情况下它是不可见的?
可以在不同的地方收集指标(例如 CPU 使用情况或内存使用情况)。例如,CPU usage 是主机(具有特殊软件的机器 运行 您的虚拟机)可以收集的一条信息。 内存使用和虚拟机的问题在于,它是管理它的底层操作系统(虚拟机的操作系统)。主机无法真正知道使用了多少,因为它在分配给该虚拟机的内存中所能看到的只是字节流。
这就是为什么有一个想法要在该虚拟机中安装 agents,以便从内部 收集指标并将其发送到某个地方他们可以被解释。有许多类型的代理可用,但 Google 推广自己的代理 - Monitoring Agent - 并且它很好地集成到整个 GCP 套件中。
VM 内存指标默认不可用,它需要 Cloud Monitoring Agent 1。
您显示的UI是Dataproc,它已经安装了代理,但默认情况下是禁用的,您不必重新安装它。要为 Dataproc 集群启用 Cloud Monitoring Agent,请在创建集群时设置 --properties dataproc:dataproc.monitoring.stackdriver.enable=true
2。然后您可以监控 VM 内存并在 Cloud Monitoring UI(尚未与 Dataproc UI 集成)中创建警报。
另请参阅此相关问题:
这篇文章现已过时,因为 Stackdriver 现在是旧版代理。这已被 Ops Agent 取代。请阅读 GCP 上有关迁移到 Ops Agent 的最新文章