Py学习  »  MongoDB

Mongodb百分比与组

user12403395 • 4 年前 • 589 次点击  

数据

{ "array" : 112233, "hgName" : "host1",  "iops" : 1, "mbps" : 0.001464844, "responseTime" : 0.06, "timeStamp" : NumberLong("1572665400110") }
{ "array" : 112233, "hgName" : "host1",  "iops" : 1, "mbps" : 0.001464844, "responseTime" : 0.06, "timeStamp" : NumberLong("1572666600117") }
{ "array" : 112233, "hgName" : "host2",  "iops" : 1, "mbps" : 0.001464844, "responseTime" : 0.06, "timeStamp" : NumberLong("1572661800115") }
{ "array" : 112233, "hgName" : "host3",  "iops" : 1, "mbps" : 0.001464844, "responseTime" : 0.06, "timeStamp" : NumberLong("1572666900103") }
{ "array" : 112233, "hgName" : "host3",  "iops" : 1, "mbps" : 0.001464844, "responseTime" : 0.06, "timeStamp" : NumberLong("1572667200110") }
<--Truncated-->

Current Query:
db.MyCollections.aggregate([
  { 
   $match: {}    
  }, {
    $group: {
      _id: "$hgName",
      average_IOPS: {
        $avg: "$iops"
      },
      average_MBps: {
        $avg: "$mbps"
      },
      Max_MBPS: {$max: "$mbps"},
      Max_IOPS: {$max: "$iops"}
    }
  }
]);

{ "_id" : "host1", "average_IOPS" : 32.26, "average_MBps" : 11.1, "Max_MBPS" : 664.8, "Max_IOPS" : 1674 }
{ "_id" : "host2", "average_IOPS" : 54.44, "average_MBps" : 0.19, "Max_MBPS" : 13.96, "Max_IOPS" : 3339 }
{ "_id" : "host3", "average_IOPS" : 0.909, "average_MBps" : 0.00, "Max_MBPS" : 0.002, "Max_IOPS" : 1 }

我需要包括一个“百分位数(0.95)计算iops和mbps”相同的平均数字合并主机。

谢谢和问候 VK公司

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55344
 
589 次点击