history 表:item_id, resource_id, clock_time, collect_value。entry 表。這是一個典型的雙角色節點架構:
/agent),接收外部系統推送的實時數據,寫入 MongoDB。history、列表 entry_*),按時間分片/索引優化查詢。// 主動通知接口(Server 端)
POST /agent/notify
Content-Type: application/json
{
"item_id": "cpu_usage",
"resource_id": "server_01",
"clock_time": 1700000000,
"collect_value": 85.5
}
// 采集任務配置(Client 端)
{
"task_id": "collect_cpu",
"target_url": "https://192.168.1.100/api/metrics",
"method": "GET",
"interval_sec": 60,
"parser": "json_path:$.cpu.usage"
}
insertMany、有序/無序寫入、寫關注級別。upsert),列表數據去重。理解雙角色職責分離,是設計穩健監控采集系統的關鍵。