123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import React from 'react';
- import { ClusterId, BrokerMetrics, ZooKeeperStatus } from 'redux/interfaces';
- import useInterval from 'lib/hooks/useInterval';
- import formatBytes from 'lib/utils/formatBytes';
- import cx from 'classnames';
- import MetricsWrapper from 'components/common/Dashboard/MetricsWrapper';
- import Indicator from 'components/common/Dashboard/Indicator';
- import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
- interface Props extends BrokerMetrics {
- clusterId: string;
- isFetched: boolean;
- minDiskUsage: number;
- maxDiskUsage: number;
- fetchBrokers: (clusterId: ClusterId) => void;
- fetchBrokerMetrics: (clusterId: ClusterId) => void;
- }
- const Topics: React.FC<Props> = ({
- clusterId,
- isFetched,
- brokerCount,
- activeControllers,
- zooKeeperStatus,
- onlinePartitionCount,
- offlinePartitionCount,
- underReplicatedPartitionCount,
- diskUsageDistribution,
- minDiskUsage,
- maxDiskUsage,
- networkPoolUsage,
- requestPoolUsage,
- fetchBrokers,
- fetchBrokerMetrics,
- }) => {
- React.useEffect(
- () => {
- fetchBrokers(clusterId);
- fetchBrokerMetrics(clusterId);
- },
- [fetchBrokers, fetchBrokerMetrics, clusterId],
- );
- useInterval(() => { fetchBrokerMetrics(clusterId); }, 5000);
- const [minDiskUsageValue, minDiskUsageSize] = formatBytes(minDiskUsage);
- const [maxDiskUsageValue, maxDiskUsageSize] = formatBytes(maxDiskUsage);
- const zkOnline = zooKeeperStatus === ZooKeeperStatus.online;
- return (
- <div className="section">
- <Breadcrumb>Brokers overview</Breadcrumb>
- <MetricsWrapper title="Uptime">
- <Indicator label="Total Brokers">
- {brokerCount}
- </Indicator>
- <Indicator label="Active Controllers">
- {activeControllers}
- </Indicator>
- <Indicator label="Zookeeper Status">
- <span className={cx('tag', zkOnline ? 'is-primary' : 'is-danger')}>
- {zkOnline ? 'Online' : 'Offline'}
- </span>
- </Indicator>
- </MetricsWrapper>
- <MetricsWrapper title="Partitions">
- <Indicator label="Online">
- <span className={cx({'has-text-danger': offlinePartitionCount !== 0})}>
- {onlinePartitionCount}
- </span>
- <span className="subtitle has-text-weight-light"> of {onlinePartitionCount + offlinePartitionCount}</span>
- </Indicator>
- <Indicator label="URP" title="Under replicated partitions">
- {underReplicatedPartitionCount}
- </Indicator>
- <Indicator label="In Sync Replicas">
- <span className="has-text-grey-lighter">
- Soon
- </span>
- </Indicator>
- <Indicator label="Out of Sync Replicas">
- <span className="has-text-grey-lighter">
- Soon
- </span>
- </Indicator>
- </MetricsWrapper>
- <MetricsWrapper title="Disk">
- <Indicator label="Max usage">
- {maxDiskUsageValue}
- <span className="subtitle has-text-weight-light"> {maxDiskUsageSize}</span>
- </Indicator>
- <Indicator label="Min usage">
- {minDiskUsageValue}
- <span className="subtitle has-text-weight-light"> {minDiskUsageSize}</span>
- </Indicator>
- <Indicator label="Distribution">
- <span className="is-capitalized">
- {diskUsageDistribution}
- </span>
- </Indicator>
- </MetricsWrapper>
- <MetricsWrapper title="System">
- <Indicator label="Network pool usage">
- {Math.round(networkPoolUsage * 10000) / 100}
- <span className="subtitle has-text-weight-light">%</span>
- </Indicator>
- <Indicator label="Request pool usage">
- {Math.round(requestPoolUsage * 10000) / 100}
- <span className="subtitle has-text-weight-light">%</span>
- </Indicator>
- </MetricsWrapper>
- </div>
- );
- }
- export default Topics;
|