You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srap/src/prometheus/index.js

46 lines
1.5 KiB
JavaScript

"use strict";
const prometheusClient = require("prom-client");
module.exports = function createPrometheus() {
let prometheusRegistry = new prometheusClient.Registry();
prometheusClient.collectDefaultMetrics({ register: prometheusRegistry });
return {
prometheusRegistry: prometheusRegistry,
metrics: {
storedItems: new prometheusClient.Counter({
registers: [ prometheusRegistry ],
name: "srap_stored_items_total",
help: "Amount of items that have been created or updated",
labelNames: [ "tag" ]
}),
successfulItems: new prometheusClient.Counter({
registers: [ prometheusRegistry ],
name: "srap_successful_items_total",
help: "Amount of items that have been successfully processed",
labelNames: [ "task" ]
}),
failedItems: new prometheusClient.Counter({
registers: [ prometheusRegistry ],
name: "srap_failed_items_total",
help: "Amount of items that have failed during processing",
labelNames: [ "task" ]
}),
taskFetchTime: new prometheusClient.Gauge({
registers: [ prometheusRegistry ],
name: "srap_task_fetch_seconds",
help: "Time needed for the most recent attempt at fetching new scraping tasks",
labelNames: [ "task" ]
}),
taskFetchResults: new prometheusClient.Gauge({
registers: [ prometheusRegistry ],
name: "srap_task_fetch_results_count",
help: "Amount of new scraping tasks fetched during the most recent attempt",
labelNames: [ "task" ]
})
// FIXME: Measure queue-refill task
}
};
};