thomasdondorf/puppeteer-cluster

Expose stats via prometheus

abhisheksurve45 opened this issue · 2 comments

Hi, is it possible to expose the stats via prometheus

image

The monitor option just shows on console

    const puppeteer = addExtra(vanillaPuppeteer)

    const cluster = await Cluster.launch()
    const clusterSize = cluster.jobQueue.size()
    clusterSizeMetric.set(clusterSize)

    const availableWorkers = cluster.workersAvail.length
    const busyWorkers = cluster.workersBusy.length
    const totalWorkers = cluster.workers.length
    crawlerWorkerQueueMetric.labels('available').set(availableWorkers)
    crawlerWorkerQueueMetric.labels('busy').set(busyWorkers)
    crawlerWorkerQueueMetric.labels('total').set(totalWorkers)

    const cpuUsage = cluster.systemMonitor.cpuUsage
    const memory = cluster.systemMonitor.memoryUsage
    crawlerClusterTelemetryMetric.labels('cpu_usage').set(cpuUsage)
    crawlerClusterTelemetryMetric.labels('memory_usage').set(memory)
jwgo commented

https://www.npmjs.com/package/@devgo/puppeteer-cluster?activeTab=readme#clustergetmonitorobject

I've released it with what's in the PR and a few features I need, so check it out and do with it what you will.