python-eve使用实战

mongo document

{
  "eth0_pps_in_metric": {
    "top_5_avg": 9841.6
  },
  "memory_metric": {
    "top_5_avg": 2
  },
  "BusinessDay": 17037,
  "eth2_loss_rate_out_metric": {
    "top_5_avg": 0
  },
  "eth2_pps_in_metric": {
    "top_5_avg": 461200.6
  },
  "cpu_metric": {
    "top_5_avg": 2.6
  },
  "load_one_metric": {
    "top_5_avg": 0
  },
  "eth0_pps_out_metric": {
    "top_5_avg": 2
  },
  "eth0_loss_rate_out_metric": {
    "top_5_avg": 0
  },
  "host": {
    "SecUsage": "pnat",
    "eip_count": 2,
    "IP": "172.23.44.78",
    "trash_id": 3,
    "SN": "2102310QPD10E9002196",
    "AssetNo": "UCSV01201409020032",
    "_cls": "Hosts",
    "Usage": "unet",
    "nat_mode": 1,
    "_id": "578dde6f9746ef2cda0f9f0b",
    "az_id": 5001,
    "Location": "yg"
  },
  "conntrack_rate_metric": {
    "top_5_avg": -1
  },
  "eth2_loss_rate_in_metric": {
    "top_5_avg": 0
  },
  "eth2_bps_out_metric": {
    "top_5_avg": 19.8
  },
  "eth2_pps_out_metric": {
    "top_5_avg": 461941.2
  },
  "eth0_bps_out_metric": {
    "top_5_avg": 0
  },
  "eth0_bps_in_metric": {
    "top_5_avg": 0
  }
}

mongo shell[a and (b or d)]

db.getCollection('aggregate_day_host_metric2').find(
{
    'BusinessDay':17037,
    $or:[{'cpu_metric.top_5_avg':2.6},
        {'cpu_metric.top_5_avg':57.2}]
}
)

url

http://IP:PORT/module_name_which_define_in_eve_setting?where=
{
    "BusinessDay": 17037,
    "$or":[{"cpu_metric.top_5_avg":2.6},
          {"cpu_metric.top_5_avg":57.2}]
}

讲道理的话,
EVE源码这里的operators set里的都支持

被证明有bug,原来是and关系,上面url里面如果两个OR,那么python的字典里就有了相同的key,这是不合理的,所以,mongo2.0之后变了一下写法,如下:

http://IP:PORT/module_name_which_define_in_eve_setting?where=
{
    "$and":[
        {"BusinessDay": 17037},
        {"$or":[
            {"cpu_metric.top_5_avg":2.6},
            {"cpu_metric.top_5_avg":57.2}]
        }
    ]
}

你可能感兴趣的:(mongodb)