Google Cloud Platform:如何监控VM实例的内存使用情况

问题描述 投票:24回答:3

我最近进行了迁移到Google Cloud Platform,我非常喜欢它。

但是我找不到监视VM intances的内存使用情况的方法。正如您在附件中看到的那样,控制台提供有关CPU,磁盘和网络的利用率信息,但不提供有关内存的信息。

在不知道正在使用多少内存的情况下,如何理解是否需要额外内存?

enter image description here

memory memory-management google-cloud-platform google-compute-engine
3个回答
13
投票

通过在GCE VM中安装Stackdriver agent,可以监视其他类似内存的metrics。 Stackdriver还为您提供alerting and notification功能。然而,代理商指标仅适用于premium tier accounts


6
投票

那么您可以使用/ proc / meminfo虚拟文件系统来获取有关当前内存使用情况的信息。您可以创建一个简单的bash脚本,从/ proc / meminfo中读取内存使用情况信息。该脚本可以作为cron作业服务定期运行。如果内存使用量超过给定阈值,脚本可以发送警报电子邮件。

看到这个链接:http://www.pakjiddat.pk/articles/all/monitoring-cpu-and-memory-usage-on-linux


0
投票

代理度量页面可能很有用:https://cloud.google.com/monitoring/api/metrics_agent

你需要安装stackdriver。请参阅:https://app.google.stackdriver.com/?project=“您的项目名称”

stackdriver指标页面将提供一些指导。您需要更改“项目名称”(例如sinuous-dog-133823)以适合您的帐户:

https://app.google.stackdriver.com/metrics-explorer?project=sinuous-dog-133823&timeSelection={"timeRange":"6h"}&xyChart={"dataSets":[{"timeSeriesFilter":{"filter":"metric.type=\"agent.googleapis.com/memory/bytes_used\" resource.type=\"gce_instance\"","perSeriesAligner":"ALIGN_MEAN","crossSeriesReducer":"REDUCE_NONE","secondaryCrossSeriesReducer":"REDUCE_NONE","minAlignmentPeriod":"60s","groupByFields":[],"unitOverride":"By"},"targetAxis":"Y1","plotType":"LINE"}],"options":{"mode":"COLOR"},"constantLines":[],"timeshiftDuration":"0s","y1Axis":{"label":"y1Axis","scale":"LINEAR"}}&isAutoRefresh=true

这个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
© www.soinside.com 2019 - 2024. All rights reserved.