Skip to content

feat: render tenant memory details #1623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/components/MemoryViewer/MemoryViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,22 @@ export interface MemoryProgressViewerProps {
stats: TMemoryStats;
className?: string;
warningThreshold?: number;
value?: number | string;
capacity?: number | string;
formatValues: FormatProgressViewerValues;
percents?: boolean;
dangerThreshold?: number;
}

export function MemoryViewer({
stats,
value,
capacity,
percents,
formatValues,
className,
warningThreshold = 60,
dangerThreshold = 80,
}: MemoryProgressViewerProps) {
const value = stats.AnonRss;
const capacity = stats.HardLimit;

const theme = useTheme();
let fillWidth =
Math.round((parseFloat(String(value)) / parseFloat(String(capacity))) * 100) || 0;
Expand Down
7 changes: 1 addition & 6 deletions src/components/nodesColumns/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,7 @@ export function getMemoryColumn<
defaultOrder: DataTable.DESCENDING,
render: ({row}) => {
return row.MemoryStats ? (
<MemoryViewer
capacity={row.MemoryLimit}
value={row.MemoryStats.AnonRss}
formatValues={formatStorageValuesToGb}
stats={row.MemoryStats}
/>
<MemoryViewer formatValues={formatStorageValuesToGb} stats={row.MemoryStats} />
) : (
<ProgressViewer
value={row.MemoryUsed}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
import React from 'react';

import {MemoryViewer} from '../../../../../components/MemoryViewer/MemoryViewer';
import {ProgressViewer} from '../../../../../components/ProgressViewer/ProgressViewer';
import type {TMemoryStats} from '../../../../../types/api/nodes';
import {formatStorageValuesToGb} from '../../../../../utils/dataFormatters/dataFormatters';
import {TenantDashboard} from '../TenantDashboard/TenantDashboard';
import {b} from '../utils';

import {TopNodesByMemory} from './TopNodesByMemory';
import {memoryDashboardConfig} from './memoryDashboardConfig';

interface TenantMemoryProps {
tenantName: string;
memoryStats?: TMemoryStats;
memoryUsed?: string;
memoryLimit?: string;
}

export function TenantMemory({tenantName}: TenantMemoryProps) {
export function TenantMemory({
tenantName,
memoryStats,
memoryUsed,
memoryLimit,
}: TenantMemoryProps) {
return (
<React.Fragment>
<TenantDashboard database={tenantName} charts={memoryDashboardConfig} />
<div className={b('title')}>{'Memory details'}</div>
<div className={b('memory-info')}>
{memoryStats ? (
<MemoryViewer formatValues={formatStorageValuesToGb} stats={memoryStats} />
) : (
<ProgressViewer
value={memoryUsed}
capacity={memoryLimit}
formatValues={formatStorageValuesToGb}
colorizeProgress={true}
/>
)}
</div>
<TopNodesByMemory tenantName={tenantName} />
</React.Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@
&__storage-info {
margin-bottom: 36px;
}

&__memory-info {
width: 300px;
margin-bottom: 36px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,14 @@ export function TenantOverview({
return <TenantStorage tenantName={tenantName} metrics={storageMetrics} />;
}
case TENANT_METRICS_TABS_IDS.memory: {
return <TenantMemory tenantName={tenantName} />;
return (
<TenantMemory
tenantName={tenantName}
memoryUsed={tenantData.MemoryUsed}
memoryLimit={tenantData.MemoryLimit}
memoryStats={tenantData.MemoryStats}
/>
);
}
case TENANT_METRICS_TABS_IDS.healthcheck: {
return <HealthcheckDetails tenantName={tenantName} />;
Expand Down
1 change: 1 addition & 0 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
path,
tablets: false,
storage: true,
memory: true,
},
{concurrentId, requestConfig: {signal}},
);
Expand Down
3 changes: 2 additions & 1 deletion src/types/api/tenant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {EFlag} from './enums';
import type {TPoolStats, TSystemStateInfo} from './nodes';
import type {TMemoryStats, TPoolStats, TSystemStateInfo} from './nodes';
import type {TTabletStateInfo} from './tablet';

/**
Expand Down Expand Up @@ -50,6 +50,7 @@ export interface TTenant {
MemoryUsed?: string; // Actual memory consumption
/** uint64 */
MemoryLimit?: string;
MemoryStats?: TMemoryStats;
/** double */
CoresUsed?: number; // Actual cpu consumption
/** uint64 */
Expand Down
Loading