How to use the prom-client.Counter function in prom-client

To help you get started, we’ve selected a few prom-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / js-libp2p-websocket-star / server / src / routes.js View on Github external
proto.addRequest('disconnect', [], disconnect)
  proto.addRequest('ss-dial', ['multiaddr', 'multiaddr', 'string', 'function'], dial) // dialFrom, dialTo, dialId, cb
  io.on('connection', handle)

  log('create new server', config)

  const _peers = {}
  const nonces = {}

  const peersMetric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge
  const dialsSuccessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter
  const dialsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_failure', help: 'failed dials since server started' }) : fake.counter
  const dialsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total', help: 'all dials since server started' }) : fake.counter
  const joinsSuccessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_success', help: 'sucessfully completed joins since server started' }) : fake.counter
  const joinsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_failure', help: 'failed joins since server started' }) : fake.counter
  const joinsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total', help: 'all joins since server started' }) : fake.counter

  const refreshMetrics = () => peersMetric.set(Object.keys(_peers).length)

  function safeEmit (addr, event, arg) {
    const peer = _peers[addr]
    if (!peer) {
      log('trying to emit %s but peer is gone', event)
      return
    }

    peer.emit(event, arg)
  }

  function handle (socket) {
    socket.addrs = []
    socket.cleanaddrs = {}
github mozilla / voice-web / server / src / lib / prometheus.ts View on Github external
constructor(config: CommonVoiceConfig) {
    this.config = config;
    this.register = register;

    // Do not run prometheus endpoints on non prod site.
    if (this.config.PROD) {
      this.requests = new Counter({
        name: 'voice_requests',
        help: 'Total Requests Served',
      });
      this.clip_cnt = new Counter({
        name: 'voice_clips_requests',
        help: 'Total Clip Requests Served',
      });
      this.api_cnt = new Counter({
        name: 'voice_api_requests',
        help: 'Total API Requests Served',
      });
      this.prometheus_cnt = new Counter({
        name: 'voice_prometheus_requests',
        help: 'Total Prometheus Requests Served',
      });
    }
  }
github jsha / blocktogether / stream.js View on Github external
remoteUpdateBlocks = setup.remoteUpdateBlocks,
    Action = setup.Action,
    BtUser = setup.BtUser;

var stats = {
  events: new prom.Counter({
    name: 'events',
    help: 'Number of events received from streaming API',
    labelNames: ['type']
  }),
  socketEvents: new prom.Counter({
    name: 'socketEvents',
    help: 'Number of Node events on the streaming socket.',
    labelNames: ['type']
  }),
  blocks: new prom.Counter({
    name: 'blocks',
    help: 'Number of blocks applied based on the streaming API',
    labelNames: ['type']
  }),
  streams: new prom.Gauge({
    name: 'streams',
    help: 'Number of active streams.'
  })
}

var workerId = 1;
var numWorkers = 1;

// An associative array of streams currently running. Indexed by uid.
var streams = {};
github RocketChat / Rocket.Chat / app / metrics / server / lib / metrics.js View on Github external
labelNames: ['method', 'entrypoint', 'user_agent', 'status', 'version'],
});

metrics.meteorSubscriptions = new client.Summary({
	name: 'rocketchat_meteor_subscriptions',
	help: 'summary of meteor subscriptions count and time',
	labelNames: ['subscription'],
});

metrics.messagesSent = new client.Counter({ name: 'rocketchat_message_sent', help: 'cumulated number of messages sent' });
metrics.notificationsSent = new client.Counter({ name: 'rocketchat_notification_sent', labelNames: ['notification_type'], help: 'cumulated number of notifications sent' });

metrics.ddpSessions = new client.Gauge({ name: 'rocketchat_ddp_sessions_count', help: 'number of open ddp sessions' });
metrics.ddpAthenticatedSessions = new client.Gauge({ name: 'rocketchat_ddp_sessions_auth', help: 'number of authenticated open ddp sessions' });
metrics.ddpConnectedUsers = new client.Gauge({ name: 'rocketchat_ddp_connected_users', help: 'number of unique connected users' });
metrics.ddpRateLimitExceeded = new client.Counter({ name: 'rocketchat_ddp_rate_limit_exceeded', labelNames: ['limit_name', 'user_id', 'client_address', 'type', 'name', 'connection_id'], help: 'number of times a ddp rate limiter was exceeded' });

metrics.version = new client.Gauge({ name: 'rocketchat_version', labelNames: ['version'], help: 'Rocket.Chat version' });
metrics.migration = new client.Gauge({ name: 'rocketchat_migration', help: 'migration versoin' });
metrics.instanceCount = new client.Gauge({ name: 'rocketchat_instance_count', help: 'instances running' });
metrics.oplogEnabled = new client.Gauge({ name: 'rocketchat_oplog_enabled', labelNames: ['enabled'], help: 'oplog enabled' });

// User statistics
metrics.totalUsers = new client.Gauge({ name: 'rocketchat_users_total', help: 'total of users' });
metrics.activeUsers = new client.Gauge({ name: 'rocketchat_users_active', help: 'total of active users' });
metrics.nonActiveUsers = new client.Gauge({ name: 'rocketchat_users_non_active', help: 'total of non active users' });
metrics.onlineUsers = new client.Gauge({ name: 'rocketchat_users_online', help: 'total of users online' });
metrics.awayUsers = new client.Gauge({ name: 'rocketchat_users_away', help: 'total of users away' });
metrics.offlineUsers = new client.Gauge({ name: 'rocketchat_users_offline', help: 'total of users offline' });

// Room statistics
metrics.totalRooms = new client.Gauge({ name: 'rocketchat_rooms_total', help: 'total of rooms' });
github mjkelly / experiments / nodejs / testserver / server.js View on Github external
const express = require('express');
const promclient = require('prom-client');

const port = 8080;
const app = express();
const serverName = process.env.SERVER_NAME || 'UNKNOWN';

const counter = new promclient.Counter({
  name: 'hit_counter',
  help: 'Count of hits per endpoint',
  labelNames: ['path']
});

app.get('/', (req, res) => {
  counter.inc({path: '/'});
  res.send(`Hello, I am ${serverName}`);
});

app.get('/health', (req, res) => {
  counter.inc({path: '/health'});
  res.set('Content-type', 'text/plain');
  res.send('ok\n');
});
github jsha / blocktogether / update-users.js View on Github external
var stats = {
  userUpdatesBegun: new prom.Counter({
    name: 'user_updates_begun',
    help:  'User updates begun',
    labelNames: ['reason']
  }),
  usersStored: new prom.Counter({
    name: 'users_stored',
    help:  'Users stored'
  }),
  usersSkipped: new prom.Counter({
    name: 'users_skipped',
    help:  'Users skipped due to no changes'
  }),
  usersVerified: new prom.Counter({
    name: 'users_verified',
    help:  'Users verified'
  }),
  inflight: new prom.Gauge({
    name: 'inflight',
    help:  'Inflight user lookup requests'
  })
}

/**
 * Find TwitterUsers needing update, look them up on Twitter, and store in
 * database. A user needs update if it's just been inserted (no screen name)
 * or if it hasn't been updated in a day.
 *
 * @param {string} sqlFilter An SQL `where' clause to filter users by. Allows
 *   running separate update cycles for fresh users (with no screen name) vs
github SimenB / node-prometheus-gc-stats / index.js View on Github external
const namePrefix = config.prefix ? config.prefix : '';

  const gcCount = new Counter({
    name: `${namePrefix}nodejs_gc_runs_total`,
    help: 'Count of total garbage collections.',
    labelNames,
    registers,
  });
  const gcTimeCount = new Counter({
    name: `${namePrefix}nodejs_gc_pause_seconds_total`,
    help: 'Time spent in GC Pause in seconds.',
    labelNames,
    registers,
  });
  const gcReclaimedCount = new Counter({
    name: `${namePrefix}nodejs_gc_reclaimed_bytes_total`,
    help: 'Total number of bytes reclaimed by GC.',
    labelNames,
    registers,
  });

  let started = false;

  return () => {
    if (started !== true) {
      started = true;

      gc().on('stats', stats => {
        const gcType = gcTypes[stats.gctype];

        gcCount.labels(gcType).inc();
github logux / server / bind-prometheus.js View on Github external
help: 'How many backend requests was processed'
})

let authTime = new prometheus.Histogram({
  name: 'logux_auth_processing_time_histogram',
  help: 'How long auth was processed',
  buckets: TIMES
})

let processingTime = new prometheus.Histogram({
  name: 'logux_request_processing_time_histogram',
  help: 'How long action was processed',
  buckets: TIMES
})

let subscriptionsCount = new prometheus.Counter({
  name: 'logux_subscription_counter',
  help: 'How many subscriptions was processed'
})

let cancelCount = new prometheus.Counter({
  name: 'logux_subscription_cancel_counter',
  help: 'How many clients closed page before subscription was finished'
})

let subscribingTime = new prometheus.Histogram({
  name: 'logux_subscription_processing_time_histogram',
  help: 'How long channel initial data was loaded',
  buckets: TIMES
})

let errorCount = new prometheus.Counter({
github jsha / blocktogether / stream.js View on Github external
verifyCredentials = require('./verify-credentials');

var twitter = setup.twitter,
    logger = setup.logger,
    sequelize = setup.sequelize,
    remoteUpdateBlocks = setup.remoteUpdateBlocks,
    Action = setup.Action,
    BtUser = setup.BtUser;

var stats = {
  events: new prom.Counter({
    name: 'events',
    help: 'Number of events received from streaming API',
    labelNames: ['type']
  }),
  socketEvents: new prom.Counter({
    name: 'socketEvents',
    help: 'Number of Node events on the streaming socket.',
    labelNames: ['type']
  }),
  blocks: new prom.Counter({
    name: 'blocks',
    help: 'Number of blocks applied based on the streaming API',
    labelNames: ['type']
  }),
  streams: new prom.Gauge({
    name: 'streams',
    help: 'Number of active streams.'
  })
}

var workerId = 1;
github logux / server / bind-prometheus.js View on Github external
100, 500, 1000, 2500, 5000, 7500, 10000, 25000, 50000, 75000, 100000
]

let actionsCount = new prometheus.Counter({
  name: 'logux_action_counter',
  help: 'How many action was added',
  labelNames: ['type']
})

let requestsCount = new prometheus.Counter({
  name: 'logux_request_counter',
  help: 'How many action was processed',
  labelNames: ['type']
})

let backendRequestsCount = new prometheus.Counter({
  name: 'logux_backend_request_counter',
  help: 'How many backend requests was processed'
})

let authTime = new prometheus.Histogram({
  name: 'logux_auth_processing_time_histogram',
  help: 'How long auth was processed',
  buckets: TIMES
})

let processingTime = new prometheus.Histogram({
  name: 'logux_request_processing_time_histogram',
  help: 'How long action was processed',
  buckets: TIMES
})