Skip to content

Commit

Permalink
Merge branch 'main' into ml/anomaly_edmbeddable_perf
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 11, 2024
2 parents 6578755 + c80be51 commit c4790b6
Show file tree
Hide file tree
Showing 35 changed files with 1,026 additions and 261 deletions.
464 changes: 436 additions & 28 deletions packages/kbn-text-based-editor/src/esql_documentation_sections.tsx

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion packages/kbn-text-based-editor/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const getDocumentationSections = async (language: string) => {
initialSection,
functions,
aggregationFunctions,
spatialFunctions,
operators,
} = await import('./esql_documentation_sections');
groups.push({
Expand All @@ -164,7 +165,14 @@ export const getDocumentationSections = async (language: string) => {
}),
items: [],
});
groups.push(sourceCommands, processingCommands, functions, aggregationFunctions, operators);
groups.push(
sourceCommands,
processingCommands,
functions,
aggregationFunctions,
spatialFunctions,
operators
);
return {
groups,
initialSection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ describe('migration actions', () => {
});
});

describe('waitForIndexStatus', () => {
// FLAKY: https://github.com/elastic/kibana/issues/152677
describe.skip('waitForIndexStatus', () => {
afterEach(async () => {
try {
await client.indices.delete({ index: 'red_then_yellow_index' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const diskUsageByMountPoint: LensConfigWithId = {
},
yAxis: [
{
...formulas.diskUsage,
...formulas.diskUsageAverage,
label: i18n.translate(
'xpack.metricsData.assetDetails.metricsCharts.diskUsage.label.used',
{
Expand Down Expand Up @@ -200,63 +200,6 @@ const diskWriteThroughput: LensConfigWithId = {
...DEFAULT_XY_HIDDEN_AXIS_TITLE,
};

const diskSpaceUsageAvailable: LensConfigWithId = {
id: 'diskSpaceUsageAvailable',
chartType: 'xy',
title: i18n.translate('xpack.metricsData.assetDetails.metricsCharts.diskUsage', {
defaultMessage: 'Disk Usage',
}),
layers: [
{
seriesType: 'area',
type: 'series',
xAxis: '@timestamp',
yAxis: [
{
...formulas.diskUsage,
label: i18n.translate(
'xpack.metricsData.assetDetails.metricsCharts.diskUsage.label.used',
{
defaultMessage: 'Used',
}
),
},
{
...formulas.diskSpaceAvailability,
label: i18n.translate(
'xpack.metricsData.assetDetails.metricsCharts.diskUsage.label.available',
{
defaultMessage: 'Available',
}
),
},
],
},
],
...DEFAULT_XY_FITTING_FUNCTION,
...DEFAULT_XY_LEGEND,
...DEFAULT_XY_YBOUNDS,
...DEFAULT_XY_HIDDEN_AXIS_TITLE,
};

const diskUsageXY: LensConfigWithId = {
id: 'diskUsage',
chartType: 'xy',
title: formulas.diskUsage.label ?? '',
layers: [
{
seriesType: 'line',
type: 'series',
xAxis: '@timestamp',
yAxis: [formulas.diskUsage],
},
],
...DEFAULT_XY_FITTING_FUNCTION,
...DEFAULT_XY_HIDDEN_LEGEND,
...DEFAULT_XY_YBOUNDS,
...DEFAULT_XY_HIDDEN_AXIS_TITLE,
};

const diskUsageMetric: LensConfigWithId = {
id: 'diskUsage',
chartType: 'metric',
Expand All @@ -267,7 +210,6 @@ const diskUsageMetric: LensConfigWithId = {

export const disk = {
xy: {
diskSpaceUsageAvailable,
diskThroughputReadWrite,
diskUsageByMountPoint,
diskIOReadWrite,
Expand All @@ -276,7 +218,6 @@ export const disk = {
diskIOWrite,
diskReadThroughput,
diskWriteThroughput,
diskUsage: diskUsageXY,
},
metric: {
diskUsage: diskUsageMetric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ export const diskUsage: LensBaseLayer = {
label: i18n.translate('xpack.metricsData.assetDetails.formulas.diskUsage', {
defaultMessage: 'Disk Usage',
}),
value: 'max(system.filesystem.used.pct)',
format: 'percent',
decimals: 0,
};

export const diskUsageAverage: LensBaseLayer = {
label: i18n.translate('xpack.metricsData.assetDetails.formulas.diskUsageAverage', {
defaultMessage: 'Disk Usage Average',
}),
value: 'average(system.filesystem.used.pct)',
format: 'percent',
decimals: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
diskSpaceAvailable,
diskSpaceAvailability,
diskUsage,
diskUsageAverage,
diskWriteThroughput,
} from './disk';

Expand Down Expand Up @@ -57,6 +58,7 @@ export const formulas = {
diskSpaceAvailability,
diskSpaceAvailable,
diskUsage,
diskUsageAverage,
hostCount,
logRate,
normalizedLoad1m,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

import { MetricsUIAggregation } from '../../../types';
export const diskSpaceUsage: MetricsUIAggregation = {
diskSpaceUsage: { avg: { field: 'system.filesystem.used.pct' } },
diskSpaceUsage: { max: { field: 'system.filesystem.used.pct' } },
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface HostKpiChartsProps {
filters?: Filter[];
searchSessionId?: string;
options?: {
subtitle?: string;
getSubtitle?: (formulaValue: string) => string;
};
loading?: boolean;
}
Expand All @@ -37,7 +37,7 @@ export const HostKpiCharts = ({
const charts = useHostKpiCharts({
dataViewId: dataView?.id,
options: {
subtitle: options?.subtitle,
getSubtitle: options?.getSubtitle,
seriesColor: euiTheme.colors.lightestShade,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('useHostFlyoutViewMetricsCharts', () => {
'memoryUsage',
'normalizedLoad1m',
'logRate',
'diskSpaceUsageAvailable',
'diskUsageByMountPoint',
'diskThroughputReadWrite',
'diskIOReadWrite',
Expand Down Expand Up @@ -70,7 +69,6 @@ describe('useHostPageViewMetricsCharts', () => {
'normalizedLoad1m',
'loadBreakdown',
'logRate',
'diskSpaceUsageAvailable',
'diskUsageByMountPoint',
'diskThroughputReadWrite',
'diskIOReadWrite',
Expand Down Expand Up @@ -131,15 +129,16 @@ describe('useHostKpiCharts', () => {

result.current.forEach((chart, index) => {
expect(chart).toHaveProperty('id', expectedOrder[index]);
expect(chart).toHaveProperty('subtitle', 'Average');
// diskUsage should have subtitle 'Max'
expect(chart).toHaveProperty('subtitle', index === 3 ? 'Max' : 'Average');
expect(chart).toHaveProperty('decimals', 1);
});
});

it('should return an array of charts with correct options', async () => {
const options = {
seriesColor: 'blue',
subtitle: 'Custom Subtitle',
getSubtitle: () => 'Custom Subtitle',
};

const { result, waitForNextUpdate } = renderHook(() =>
Expand All @@ -151,7 +150,7 @@ describe('useHostKpiCharts', () => {

result.current.forEach((chart) => {
expect(chart).toHaveProperty('seriesColor', options.seriesColor);
expect(chart).toHaveProperty('subtitle', options.subtitle);
expect(chart).toHaveProperty('subtitle', 'Custom Subtitle');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const useHostFlyoutViewMetricsCharts = ({
memory.xy.memoryUsage,
cpu.xy.normalizedLoad1m,
logs.xy.logRate,
disk.xy.diskSpaceUsageAvailable,
disk.xy.diskUsageByMountPoint,
disk.xy.diskThroughputReadWrite,
disk.xy.diskIOReadWrite,
Expand Down Expand Up @@ -67,7 +66,6 @@ export const useHostPageViewMetricsCharts = ({
cpu.xy.normalizedLoad1m,
cpu.xy.loadBreakdown,
logs.xy.logRate,
disk.xy.diskSpaceUsageAvailable,
disk.xy.diskUsageByMountPoint,
disk.xy.diskThroughputReadWrite,
disk.xy.diskIOReadWrite,
Expand Down Expand Up @@ -118,12 +116,19 @@ export const useKubernetesSectionMetricsCharts = ({
return charts;
};

const getSubtitleFromFormula = (value: string) =>
value.startsWith('max')
? i18n.translate('xpack.infra.hostsViewPage.kpi.subtitle.max', { defaultMessage: 'Max' })
: i18n.translate('xpack.infra.assetDetails.kpi.subtitle.average', {
defaultMessage: 'Average',
});

export const useHostKpiCharts = ({
dataViewId,
options,
}: {
dataViewId?: string;
options?: { seriesColor: string; subtitle?: string };
options?: { seriesColor: string; getSubtitle?: (formulaValue: string) => string };
}) => {
const { value: charts = [] } = useAsync(async () => {
const model = findInventoryModel('host');
Expand All @@ -138,18 +143,16 @@ export const useHostKpiCharts = ({
...chart,
seriesColor: options?.seriesColor,
decimals: 1,
subtitle:
options?.subtitle ??
i18n.translate('xpack.infra.assetDetails.kpi.subtitle.average', {
defaultMessage: 'Average',
}),
subtitle: options?.getSubtitle
? options?.getSubtitle(chart.value)
: getSubtitleFromFormula(chart.value),
...(dataViewId && {
dataset: {
index: dataViewId,
},
}),
}));
}, [dataViewId, options?.seriesColor, options?.subtitle]);
}, [dataViewId, options?.seriesColor, options?.getSubtitle]);

return charts;
};

This file was deleted.

Loading

0 comments on commit c4790b6

Please sign in to comment.