Skip to content

Commit

Permalink
Merge pull request #19 from pabloromeo/dev
Browse files Browse the repository at this point in the history
Metrics fix
  • Loading branch information
pabloromeo authored Apr 22, 2020
2 parents 8adb091 + d7cc6dd commit 1f89d9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions orchestrator/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const gaugeWorkers = new client.Gauge({
const workerLoadCPUStats = new client.Gauge({
name : 'worker_load_cpu',
help : 'Worker Load - CPU usage',
labelNames: ['worker_id', 'worker_name'],
labelNames: ['worker_name'],
})

const workerLoadTasksStats = new client.Gauge({
name : 'worker_load_tasks',
help : 'Worker Load - Tasks Count',
labelNames: ['worker_id', 'worker_name'],
labelNames: ['worker_name'],
})

module.exports = {
Expand All @@ -58,8 +58,8 @@ module.exports = {

setActiveWorkers : (amount) => { gaugeWorkers.set(amount) },
setActiveJobPosters : (amount) => { gaugeJobPosters.set(amount) },
setWorkerLoadCPU : (workerId, workerName, value) => { workerLoadCPUStats.labels(workerId, workerName).set(value) },
setWorkerLoadTasks : (workerId, workerName, value) => { workerLoadTasksStats.labels(workerId, workerName).set(value) },
setWorkerLoadCPU : (workerName, value) => { workerLoadCPUStats.labels(workerName).set(value) },
setWorkerLoadTasks : (workerName, value) => { workerLoadTasksStats.labels(workerName).set(value) },

injectMetricsRoute : (app) => {
app.get('/metrics', (req, res) => {
Expand Down
4 changes: 2 additions & 2 deletions orchestrator/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Worker {

updateStats(stats) {
this.stats = { cpu : parseFloat(stats.cpu), tasks: parseInt(stats.tasks)}
metrics.setWorkerLoadCPU(this.id, this.host, this.stats.cpu)
metrics.setWorkerLoadTasks(this.id, this.host, this.stats.tasks)
metrics.setWorkerLoadCPU(this.host, this.stats.cpu)
metrics.setWorkerLoadTasks(this.host, this.stats.tasks)
}
}

Expand Down

0 comments on commit 1f89d9d

Please sign in to comment.