咨询下OCP页面中的monagent的内存占用的历史数据有没有其他获取方式,我集群比较多,几十个,经常内存占用过高,想写个脚本或查询数据库的方式看峰值出现的时间和最大值。找了下ocp_monitor库,没找到存放在哪张表
2 个赞
之前也是经常内存过多,后来升了ocp 版本好了一点,现在也还有几台内存还是超限,改大内存也不行
1 个赞
出个显示sql 就好了
1 个赞
monagent内存占用过多的原因清楚了,分析了蛮多轮,monagent也从默认2G调整到4G,最后调整到8G
主要是在业务高峰期采集的sql_audit太多,而且一个ocp上10多个集群,采集都存到ocp_monitor中,处理不及时或压力太大就直接把monagent的内存打高。 没办法控制采集的sql_audit的量。只能扩大monagent内存环节,避免monagent oom的告警
2 个赞
看来都有这个问题
1 个赞
查了下,历史监控数据存放在ocp的monitor元数据库的metric_data_second表中,但数据二进制加密存储的,没法直接查询,只能通过调接口方式访问
## 查询指定时间段demo集群monagent_resident_memory的内存数据
curl -s --user admin:xxxxxx -X GET "http://xxxxx:8080/api/v2/monitor/metric?startTime=2025-09-28T18%3A30%3A00.000%2B08%3A00&endTime=2025-09-28T18%3A31%3A00.000%2B08%3A00&interval=60&metrics=monagent_resident_memory&labels=app%3Ahost%2Cob_cluster_name%3Ademo%2Cob_cluster_id%3A1757569992&groupBy=app%2Cob_cluster_name%2Cob_cluster_id" | python -m json.tool
{
"data": {
"contents": [
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055450
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055420
},
{
"monagent_resident_memory": 432193536.0,
"timestamp": 1759055455
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055440
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055410
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055445
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055415
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055400
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055435
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055405
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055425
},
{
"monagent_resident_memory": 432193536.0,
"timestamp": 1759055460
},
{
"monagent_resident_memory": 438054912.0,
"timestamp": 1759055430
}
]
},
"duration": 14,
"server": "794e2ff08a",
"status": 200,
"successful": true,
"timestamp": "2025-09-29T15:33:38.006+08:00",
"traceId": "6687b8a8442894e4"
}
