Brokers.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import React from 'react';
  2. import { ClusterId, BrokerMetrics, ZooKeeperStatus } from 'redux/interfaces';
  3. import useInterval from 'lib/hooks/useInterval';
  4. import formatBytes from 'lib/utils/formatBytes';
  5. import cx from 'classnames';
  6. import MetricsWrapper from 'components/common/Dashboard/MetricsWrapper';
  7. import Indicator from 'components/common/Dashboard/Indicator';
  8. import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
  9. interface Props extends BrokerMetrics {
  10. clusterId: string;
  11. isFetched: boolean;
  12. minDiskUsage: number;
  13. maxDiskUsage: number;
  14. fetchBrokers: (clusterId: ClusterId) => void;
  15. fetchBrokerMetrics: (clusterId: ClusterId) => void;
  16. }
  17. const Topics: React.FC<Props> = ({
  18. clusterId,
  19. isFetched,
  20. brokerCount,
  21. activeControllers,
  22. zooKeeperStatus,
  23. onlinePartitionCount,
  24. offlinePartitionCount,
  25. underReplicatedPartitionCount,
  26. diskUsageDistribution,
  27. minDiskUsage,
  28. maxDiskUsage,
  29. networkPoolUsage,
  30. requestPoolUsage,
  31. fetchBrokers,
  32. fetchBrokerMetrics,
  33. }) => {
  34. React.useEffect(
  35. () => {
  36. fetchBrokers(clusterId);
  37. fetchBrokerMetrics(clusterId);
  38. },
  39. [fetchBrokers, fetchBrokerMetrics, clusterId],
  40. );
  41. useInterval(() => { fetchBrokerMetrics(clusterId); }, 5000);
  42. const [minDiskUsageValue, minDiskUsageSize] = formatBytes(minDiskUsage);
  43. const [maxDiskUsageValue, maxDiskUsageSize] = formatBytes(maxDiskUsage);
  44. const zkOnline = zooKeeperStatus === ZooKeeperStatus.online;
  45. return (
  46. <div className="section">
  47. <Breadcrumb>Brokers overview</Breadcrumb>
  48. <MetricsWrapper title="Uptime">
  49. <Indicator label="Total Brokers">
  50. {brokerCount}
  51. </Indicator>
  52. <Indicator label="Active Controllers">
  53. {activeControllers}
  54. </Indicator>
  55. <Indicator label="Zookeeper Status">
  56. <span className={cx('tag', zkOnline ? 'is-primary' : 'is-danger')}>
  57. {zkOnline ? 'Online' : 'Offline'}
  58. </span>
  59. </Indicator>
  60. </MetricsWrapper>
  61. <MetricsWrapper title="Partitions">
  62. <Indicator label="Online">
  63. <span className={cx({'has-text-danger': offlinePartitionCount !== 0})}>
  64. {onlinePartitionCount}
  65. </span>
  66. <span className="subtitle has-text-weight-light"> of {onlinePartitionCount + offlinePartitionCount}</span>
  67. </Indicator>
  68. <Indicator label="URP" title="Under replicated partitions">
  69. {underReplicatedPartitionCount}
  70. </Indicator>
  71. <Indicator label="In Sync Replicas">
  72. <span className="has-text-grey-lighter">
  73. Soon
  74. </span>
  75. </Indicator>
  76. <Indicator label="Out of Sync Replicas">
  77. <span className="has-text-grey-lighter">
  78. Soon
  79. </span>
  80. </Indicator>
  81. </MetricsWrapper>
  82. <MetricsWrapper title="Disk">
  83. <Indicator label="Max usage">
  84. {maxDiskUsageValue}
  85. <span className="subtitle has-text-weight-light"> {maxDiskUsageSize}</span>
  86. </Indicator>
  87. <Indicator label="Min usage">
  88. {minDiskUsageValue}
  89. <span className="subtitle has-text-weight-light"> {minDiskUsageSize}</span>
  90. </Indicator>
  91. <Indicator label="Distribution">
  92. <span className="is-capitalized">
  93. {diskUsageDistribution}
  94. </span>
  95. </Indicator>
  96. </MetricsWrapper>
  97. <MetricsWrapper title="System">
  98. <Indicator label="Network pool usage">
  99. {Math.round(networkPoolUsage * 10000) / 100}
  100. <span className="subtitle has-text-weight-light">%</span>
  101. </Indicator>
  102. <Indicator label="Request pool usage">
  103. {Math.round(requestPoolUsage * 10000) / 100}
  104. <span className="subtitle has-text-weight-light">%</span>
  105. </Indicator>
  106. </MetricsWrapper>
  107. </div>
  108. );
  109. }
  110. export default Topics;