diff --git a/api/mocks/brokerMetrics.js b/api/mocks/brokerMetrics.js new file mode 100644 index 0000000000000000000000000000000000000000..acbffa4148209915c94307f2d1e99aaa39af4f4a --- /dev/null +++ b/api/mocks/brokerMetrics.js @@ -0,0 +1,25 @@ +const randomBrokerMetrics = () => ({ + bytesInPerSec: Math.ceil(Math.random() * 10000), + + brokerCount: 1, + zooKeeperStatus: 1, + activeControllers: 1, + uncleanLeaderElectionCount: 0, + networkPoolUsage: Math.random(), + requestPoolUsage: Math.random(), + onlinePartitionCount: Math.ceil(Math.random() * 1000), + underReplicatedPartitionCount: Math.ceil(Math.random() * 10), + offlinePartitionCount: Math.ceil(Math.random() * 10), + diskUsage: [ + { + brokerId: 1, + segmentSize: Math.ceil(Math.random() * 1_000_000_000), + }, + ], + diskUsageDistribution: 'even', +}); + +module.exports = { + 'wrYGf-csNgiGdK7B_ADF7Z': randomBrokerMetrics(), + 'dMMQx-WRh77BKYas_g2ZTz': randomBrokerMetrics(), +}; diff --git a/api/mocks/brokers.js b/api/mocks/brokers.js new file mode 100644 index 0000000000000000000000000000000000000000..a6113a297e2fd4743d87457b1ac6d5e751383b86 --- /dev/null +++ b/api/mocks/brokers.js @@ -0,0 +1,21 @@ +const randomBroker = () => ({ + bytesInPerSec: Math.ceil(Math.random() * 10000), + bytesOutPerSec: Math.ceil(Math.random() * 10000), + segmentSize: Math.ceil(Math.random() * 1_000_000_000), + partitionReplicas: 134, +}); + +module.exports = { + 'wrYGf-csNgiGdK7B_ADF7Z': [ + { + brokerId: 1, + ...randomBroker(), + }, + ], + 'dMMQx-WRh77BKYas_g2ZTz': [ + { + brokerId: 2, + ...randomBroker(), + }, + ], +}; diff --git a/api/services/brokers.js b/api/services/brokers.js index eba0c1757337f8dcacd41eafa5e9b3b915f900b6..c481bd8ca29451bbce497b33ed97bdd1c6f2c26a 100644 --- a/api/services/brokers.js +++ b/api/services/brokers.js @@ -1,11 +1,16 @@ 'use strict' -module.exports = function (fastify, opts, next) { - fastify.get('/brokers', function (request, reply) { - reply.send([ +const brokers = require('../mocks/brokers'); +const brokerMetrics = require('../mocks/brokerMetrics'); - ]); - }); +module.exports = function (fastify, opts, next) { + fastify + .get('/clusters/:clusterId/brokers', function (request, reply) { + reply.send(brokers[request.params.clusterId]); + }) + .get('/clusters/:clusterId/metrics/broker', function (request, reply) { + reply.send(brokerMetrics[request.params.clusterId]); + }); next(); }