How to use the prom-client.AggregatorRegistry 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 coralproject / talk / src / core / server / index.ts View on Github external
this.tasks.notifier.process();

    // Start up the cron job processors.
    this.scheduledTasks = startScheduledTasks({
      mongo: this.mongo,
      config: this.config,
      mailerQueue: this.tasks.mailer,
      tenantCache: this.tenantCache,
      signingConfig: this.signingConfig,
    });

    // If we are running in concurrency mode, and we are the master, we should
    // setup the aggregator for the cluster metrics.
    if (cluster.isMaster && this.config.get("concurrency") > 1) {
      // Create the aggregator registry for metrics.
      const aggregatorRegistry = new AggregatorRegistry();

      // Setup the cluster metrics server.
      const metricsServer = express();

      // Setup access logger.
      metricsServer.use(accessLogger);

      // Add basic auth if provided.
      const username = this.config.get("metrics_username");
      const password = this.config.get("metrics_password");
      if (username && password) {
        metricsServer.use("/cluster_metrics", basicAuth(username, password));
        logger.info("adding authentication to metrics endpoint");
      } else {
        logger.info(
          "not adding authentication to metrics endpoint, credentials not provided"
github jochen-schweizer / express-prom-bundle / src / index.js View on Github external
function clusterMetrics() {
    const aggregatorRegistry = new promClient.AggregatorRegistry();

    const metricsMiddleware = function(req, res) {
      aggregatorRegistry.clusterMetrics((err, clusterMetrics) => {
        if (err) {
            console.error(err);
            return res.sendStatus(500);
        }
        res.set('Content-Type', aggregatorRegistry.contentType);
        res.send(clusterMetrics);
      });
    };

    return metricsMiddleware;
}