Skip to content

Commit 09b1238

Browse files
authored
feat: render tenant memory details (#1623)
1 parent 5b08e34 commit 09b1238

File tree

7 files changed

+47
-13
lines changed

7 files changed

+47
-13
lines changed

src/components/MemoryViewer/MemoryViewer.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,22 @@ export interface MemoryProgressViewerProps {
4040
stats: TMemoryStats;
4141
className?: string;
4242
warningThreshold?: number;
43-
value?: number | string;
44-
capacity?: number | string;
4543
formatValues: FormatProgressViewerValues;
4644
percents?: boolean;
4745
dangerThreshold?: number;
4846
}
4947

5048
export function MemoryViewer({
5149
stats,
52-
value,
53-
capacity,
5450
percents,
5551
formatValues,
5652
className,
5753
warningThreshold = 60,
5854
dangerThreshold = 80,
5955
}: MemoryProgressViewerProps) {
56+
const value = stats.AnonRss;
57+
const capacity = stats.HardLimit;
58+
6059
const theme = useTheme();
6160
let fillWidth =
6261
Math.round((parseFloat(String(value)) / parseFloat(String(capacity))) * 100) || 0;

src/components/nodesColumns/columns.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,7 @@ export function getMemoryColumn<
172172
defaultOrder: DataTable.DESCENDING,
173173
render: ({row}) => {
174174
return row.MemoryStats ? (
175-
<MemoryViewer
176-
capacity={row.MemoryLimit}
177-
value={row.MemoryStats.AnonRss}
178-
formatValues={formatStorageValuesToGb}
179-
stats={row.MemoryStats}
180-
/>
175+
<MemoryViewer formatValues={formatStorageValuesToGb} stats={row.MemoryStats} />
181176
) : (
182177
<ProgressViewer
183178
value={row.MemoryUsed}

src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TenantMemory.tsx

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
11
import React from 'react';
22

3+
import {MemoryViewer} from '../../../../../components/MemoryViewer/MemoryViewer';
4+
import {ProgressViewer} from '../../../../../components/ProgressViewer/ProgressViewer';
5+
import type {TMemoryStats} from '../../../../../types/api/nodes';
6+
import {formatStorageValuesToGb} from '../../../../../utils/dataFormatters/dataFormatters';
37
import {TenantDashboard} from '../TenantDashboard/TenantDashboard';
8+
import {b} from '../utils';
49

510
import {TopNodesByMemory} from './TopNodesByMemory';
611
import {memoryDashboardConfig} from './memoryDashboardConfig';
712

813
interface TenantMemoryProps {
914
tenantName: string;
15+
memoryStats?: TMemoryStats;
16+
memoryUsed?: string;
17+
memoryLimit?: string;
1018
}
1119

12-
export function TenantMemory({tenantName}: TenantMemoryProps) {
20+
export function TenantMemory({
21+
tenantName,
22+
memoryStats,
23+
memoryUsed,
24+
memoryLimit,
25+
}: TenantMemoryProps) {
1326
return (
1427
<React.Fragment>
1528
<TenantDashboard database={tenantName} charts={memoryDashboardConfig} />
29+
<div className={b('title')}>{'Memory details'}</div>
30+
<div className={b('memory-info')}>
31+
{memoryStats ? (
32+
<MemoryViewer formatValues={formatStorageValuesToGb} stats={memoryStats} />
33+
) : (
34+
<ProgressViewer
35+
value={memoryUsed}
36+
capacity={memoryLimit}
37+
formatValues={formatStorageValuesToGb}
38+
colorizeProgress={true}
39+
/>
40+
)}
41+
</div>
1642
<TopNodesByMemory tenantName={tenantName} />
1743
</React.Fragment>
1844
);

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss

+5
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@
6363
&__storage-info {
6464
margin-bottom: 36px;
6565
}
66+
67+
&__memory-info {
68+
width: 300px;
69+
margin-bottom: 36px;
70+
}
6671
}

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ export function TenantOverview({
123123
return <TenantStorage tenantName={tenantName} metrics={storageMetrics} />;
124124
}
125125
case TENANT_METRICS_TABS_IDS.memory: {
126-
return <TenantMemory tenantName={tenantName} />;
126+
return (
127+
<TenantMemory
128+
tenantName={tenantName}
129+
memoryUsed={tenantData.MemoryUsed}
130+
memoryLimit={tenantData.MemoryLimit}
131+
memoryStats={tenantData.MemoryStats}
132+
/>
133+
);
127134
}
128135
case TENANT_METRICS_TABS_IDS.healthcheck: {
129136
return <HealthcheckDetails tenantName={tenantName} />;

src/services/api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
202202
path,
203203
tablets: false,
204204
storage: true,
205+
memory: true,
205206
},
206207
{concurrentId, requestConfig: {signal}},
207208
);

src/types/api/tenant.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {EFlag} from './enums';
2-
import type {TPoolStats, TSystemStateInfo} from './nodes';
2+
import type {TMemoryStats, TPoolStats, TSystemStateInfo} from './nodes';
33
import type {TTabletStateInfo} from './tablet';
44

55
/**
@@ -50,6 +50,7 @@ export interface TTenant {
5050
MemoryUsed?: string; // Actual memory consumption
5151
/** uint64 */
5252
MemoryLimit?: string;
53+
MemoryStats?: TMemoryStats;
5354
/** double */
5455
CoresUsed?: number; // Actual cpu consumption
5556
/** uint64 */

0 commit comments

Comments
 (0)