Skip to content

Commit fa98a22

Browse files
feat(MetricChart): make charts database specific (#750)
1 parent 9a0b867 commit fa98a22

File tree

10 files changed

+28
-11
lines changed

10 files changed

+28
-11
lines changed

src/components/MetricChart/MetricChart.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ const prepareWidgetData = (
9999
};
100100

101101
interface DiagnosticsChartProps {
102+
database: string;
103+
102104
title?: string;
103105
metrics: MetricDescription[];
104106
timeFrame?: TimeFrame;
@@ -121,6 +123,7 @@ interface DiagnosticsChartProps {
121123
}
122124

123125
export const MetricChart = ({
126+
database,
124127
title,
125128
metrics,
126129
timeFrame = '1h',
@@ -172,6 +175,7 @@ export const MetricChart = ({
172175
// should be width > maxDataPoints to prevent points that cannot be selected
173176
// more px per dataPoint - easier to select, less - chart is smoother
174177
const response = await getChartData({
178+
database,
175179
metrics,
176180
timeFrame,
177181
maxDataPoints: width / 2,

src/components/MetricChart/getChartData.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ import {TIMEFRAMES, type TimeFrame} from '../../utils/timeframes';
22
import type {MetricDescription} from './types';
33

44
interface GetChartDataParams {
5+
database: string;
56
metrics: MetricDescription[];
67
timeFrame: TimeFrame;
78
maxDataPoints: number;
89
}
910

10-
export const getChartData = async ({metrics, timeFrame, maxDataPoints}: GetChartDataParams) => {
11+
export const getChartData = async ({
12+
database,
13+
metrics,
14+
timeFrame,
15+
maxDataPoints,
16+
}: GetChartDataParams) => {
1117
const targetString = metrics.map((metric) => `target=${metric.target}`).join('&');
1218

1319
const until = Math.round(Date.now() / 1000);
1420
const from = until - TIMEFRAMES[timeFrame];
1521

1622
return window.api.getChartData(
17-
{target: targetString, from, until, maxDataPoints},
23+
{target: targetString, from, until, maxDataPoints, database},
1824
{concurrentId: `getChartData|${targetString}`},
1925
);
2026
};
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import {TenantDashboard} from '../TenantDashboard/TenantDashboard';
22
import {defaultDashboardConfig} from './defaultDashboardConfig';
33

4-
export const DefaultOverviewContent = () => {
5-
return <TenantDashboard charts={defaultDashboardConfig} />;
4+
interface DefaultOverviewContentProps {
5+
database: string;
6+
}
7+
8+
export const DefaultOverviewContent = ({database}: DefaultOverviewContentProps) => {
9+
return <TenantDashboard database={database} charts={defaultDashboardConfig} />;
610
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface TenantCpuProps {
1414
export function TenantCpu({path, additionalNodesProps}: TenantCpuProps) {
1515
return (
1616
<>
17-
<TenantDashboard charts={cpuDashboardConfig} />
17+
<TenantDashboard database={path} charts={cpuDashboardConfig} />
1818
<TopNodesByLoad path={path} additionalNodesProps={additionalNodesProps} />
1919
<TopNodesByCpu path={path} additionalNodesProps={additionalNodesProps} />
2020
<TopShards path={path} />

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ export interface ChartConfig {
2626
}
2727

2828
interface TenantDashboardProps {
29+
database: string;
2930
charts: ChartConfig[];
3031
}
3132

32-
export const TenantDashboard = ({charts}: TenantDashboardProps) => {
33+
export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
3334
const [isDashboardHidden, setIsDashboardHidden] = useState<boolean>(true);
3435

3536
const [timeFrame = '1h', setTimeframe] = useQueryParam('timeframe', StringParam);
@@ -64,6 +65,7 @@ export const TenantDashboard = ({charts}: TenantDashboardProps) => {
6465
return (
6566
<MetricChart
6667
key={chartId}
68+
database={database}
6769
title={chartConfig.title}
6870
metrics={chartConfig.metrics}
6971
timeFrame={timeFrame as TimeFrame}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface TenantMemoryProps {
99
export function TenantMemory({path}: TenantMemoryProps) {
1010
return (
1111
<>
12-
<TenantDashboard charts={memoryDashboardConfig} />
12+
<TenantDashboard database={path} charts={memoryDashboardConfig} />
1313
<TopNodesByMemory path={path} />
1414
</>
1515
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export function TenantOverview({
146146
);
147147
}
148148
default: {
149-
return <DefaultOverviewContent />;
149+
return <DefaultOverviewContent database={tenantName} />;
150150
}
151151
}
152152
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function TenantStorage({tenantName, metrics}: TenantStorageProps) {
6969

7070
return (
7171
<>
72-
<TenantDashboard charts={storageDashboardConfig} />
72+
<TenantDashboard database={tenantName} charts={storageDashboardConfig} />
7373
<InfoViewer className={b('storage-info')} title="Storage details" info={info} />
7474
<TopTables path={tenantName} />
7575
<TopGroups tenant={tenantName} />

src/services/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,13 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
399399
});
400400
}
401401
getChartData(
402-
{target, from, until, maxDataPoints}: JsonRenderRequestParams,
402+
{target, from, until, maxDataPoints, database}: JsonRenderRequestParams,
403403
{concurrentId}: AxiosOptions = {},
404404
) {
405405
const requestString = `${target}&from=${from}&until=${until}&maxDataPoints=${maxDataPoints}&format=json`;
406406

407407
return this.post<JsonRenderResponse>(
408-
this.getPath('/viewer/json/render'),
408+
this.getPath(`/viewer/json/render?database=${database}`),
409409
requestString,
410410
{},
411411
{

src/types/api/render.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ export interface JsonRenderRequestParams {
3434
from: number;
3535
until: number;
3636
maxDataPoints: number;
37+
database: string;
3738
}

0 commit comments

Comments
 (0)