I use mongo db with php I need a last 1 hour data. I implement as like bellow.
{
"_id":{"$oid":"5ff42b30be00ec1eaf261db1"},
"logtype":"syslog",
"message":"Jan 4 06:51:56 4S-096 kernel: [70745743.387001] CPU7: Package temperature above threshold, cpu clock throttled (total events = 2955852254)",
"node_id":875,
"app_id":0,
"send_to_slack":1,
"created_date":{"$date":"2021-01-05T09:02:39.593Z"}
}
PHP CODE
$client = mongodb_connect();
$db = $client->$db_name;
$col = $db->selectCollection($collection_name);
$client->selectDatabase($db_name);
$criteria = array(
"created_date" => [$gte=> new MongoDBBSONUTCDateTime(strtotime("-1 hour") * 1000)],
"logtype" => $logType,
"message" => trim($logdata),
"node_id" => $node_id,
);
$count = $col->count($criteria);
I need a count result. thanks in advance
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…