Skip to main content

Monitor with a collector


Make sure you have Docker installed locally for this type of monitor

The monitor we are going to build uses a docker container to collect relevant data to our API, then uses this data directly for visualization.

As explained in the Collector section, a usual collector code would do the following:

  1. Fetch the instances, then loop over them
  2. Fetch an access token for the user
  3. Fetch the data
  4. Push the data to our API
  5. Mark the instance as updated
  6. Repeat

So, a simple NodeJS collector that fetches the data we need for our monitor would look like this. Clone the code, and replace relevant IDs and secrets.

Add an .env file to your project, that should look like this:


Use the following to run your collector: docker build -t collector . && docker run --env-file .env collector:latest

Then, in the Collector tab, create a collector (collectors are free for Public monitors, and paid for Private monitors), then follow the instructions to push your collector to CoreBI.


With collectors of Private monitors, the collector will get running immediately. As for Public monitors, you need to contact us to run your collector.

The collector will start collecting the data and push it to our API. So to visualize it, the Visualizer code would look like this: (remember, here you are fetching the data from CoreBI now)

version: 1.0,
type: "scoreboard",
do: async function(ctx) {
try {
let now = new Date();
let nowISO = now.toISOString();

let past = new Date();
let pastISO = past.toISOString();

let events = await db.query(ctx.monitorID, "repositories", {
timeframe: {
from: past,
to: now
order: {
by: "timestamp",
direction: "desc",
type: "numeric"
limit: 1,
if (events.length > 0) {
let event = events[0];
let stars = event.stars;
let forks = event.forks;
let watchers = event.watchers;
let scores = [{
name: "Stars",
value: utils.formatNumber(stars),
}, {
name: "Forks",
value: utils.formatNumber(forks),
}, {
name: "Watchers",
value: utils.formatNumber(watchers),
ctx.setScoreboard({scores: scores});
} else {
} catch (err) {
// unhandled error, show the RETRY message