Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Prometheus = require('prometheus-client');
- var client = new Prometheus();
- function measureShare(postDetail){
- var numberOfShare = client.newGauge({
- namespace: "psu_project",
- name: "share_count",
- help: "number of share"
- });
- setInterval(function(){
- postDetail.aggregate(
- [
- {
- $group:
- {
- _id:"like_count",
- count: {
- $sum: "$SHARE"
- }
- }
- }
- ]).toArray(function(err, docs){
- if(err){
- process.exit(0);
- }
- var count = docs[0].count;
- numberOfShare.set({
- period: "10sec"
- }, count);
- });
- }, 10000);
- }
- measureShare(mongodb.collection("post_detail"));
- client.listen(9095);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement