Skip to content

Commit

Permalink
Merge branch 'main' into saml-cypress-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema authored Dec 12, 2023
2 parents 5215f31 + bd21e30 commit 32d9b04
Show file tree
Hide file tree
Showing 116 changed files with 3,912 additions and 5,647 deletions.
20 changes: 18 additions & 2 deletions packages/kbn-apm-synthtrace/src/cli/run_synthtrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
import datemath from '@kbn/datemath';
import { Argv } from 'yargs';
import yargs from 'yargs/yargs';
import { readdirSync } from 'fs';
import path from 'path';
import { intervalToMs } from './utils/interval_to_ms';
import { parseRunCliFlags } from './utils/parse_run_cli_flags';
import { startHistoricalDataUpload } from './utils/start_historical_data_upload';
import { startLiveDataUpload } from './utils/start_live_data_upload';

function getBuiltinScenarios() {
return readdirSync(path.resolve(__dirname, '../scenarios')).map((s) => s.replace(/\.ts$/, ''));
}

function options(y: Argv) {
return y
.usage('$0 <file>')
.positional('file', {
describe: 'File that contains the trace scenario',
describe: 'Name of scenario',
demandOption: true,
string: true,
choices: getBuiltinScenarios(),
})
.option('target', {
describe: 'Elasticsearch target',
Expand Down Expand Up @@ -54,6 +62,7 @@ function options(y: Argv) {
})
.option('logLevel', {
describe: 'Log level',
choices: ['trace', 'debug', 'info', 'error'],
default: 'info',
})
.option('scenarioOpts', {
Expand All @@ -66,7 +75,14 @@ function options(y: Argv) {
describe: 'Assumes passed package version to avoid calling Fleet API to install',
string: true,
})
.showHelpOnFail(false);
.example(
'$0 simple_logs --target=http://admin:changeme@localhost:9200',
'Ingest data to specific Elasticsearch cluster'
)
.example('$0 simple_logs --live', 'Continuously ingest data to local development cluster')
.example('$0 simple_logs --from=now-24h --to=now', 'Ingest data for a fixed time window')
.showHelpOnFail(false)
.wrap(null);
}

async function run(argv: RunCliFlags) {
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@
"indicator.params",
"indicator.type",
"name",
"tags"
"tags",
"version"
],
"threshold-explorer-view": [],
"observability-onboarding-state": [
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,9 @@
},
"tags": {
"type": "keyword"
},
"version": {
"type": "long"
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [
},
],
},
{
name: 'to_geopoint',
description: i18n.translate('monaco.esql.definitions.toGeopointDoc', {
defaultMessage: 'Converts to geo_point.',
}),
signatures: [
{
params: [{ name: 'field', type: 'any' }],
returnType: 'geo_point',
examples: [`from index | EVAL geopoint = to_geopoint(field)`],
},
],
},
{
name: 'to_integer',
alias: ['to_int'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function getCallbackMocks() {
name: `${type}Field`,
type,
})),
{ name: 'geoPointField', type: 'geo_point' },
{ name: 'any#Char$ field', type: 'number' },
{ name: 'kubernetes.something.something', type: 'number' },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"siem-ui-timeline": "d3de8ff3617be8f2a799d66b1471b9be6124bf40",
"siem-ui-timeline-note": "0a32fb776907f596bedca292b8c646496ae9c57b",
"siem-ui-timeline-pinned-event": "082daa3ce647b33873f6abccf340bdfa32057c8d",
"slo": "2048ab6791df2e1ae0936f29c20765cb8d2fcfaa",
"slo": "9a9995e4572de1839651c43b5fc4dc8276bb5815",
"space": "8de4ec513e9bbc6b2f1d635161d850be7747d38e",
"spaces-usage-stats": "3abca98713c52af8b30300e386c7779b3025a20e",
"synthetics-monitor": "33ddc4b8979f378edf58bcc7ba13c5c5b572f42d",
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/kbn-slo-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
export * from './src/schema';
export * from './src/rest_specs';
export * from './src/models/duration';
export * from './src/models/pagination';
17 changes: 17 additions & 0 deletions x-pack/packages/kbn-slo-schema/src/models/pagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export interface Paginated<T> {
total: number;
page: number;
perPage: number;
results: T[];
}

export interface Pagination {
page: number;
perPage: number;
}
50 changes: 30 additions & 20 deletions x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import * as t from 'io-ts';
import { toBooleanRt } from '@kbn/io-ts-utils';
import {
allOrAnyString,
apmTransactionDurationIndicatorSchema,
Expand Down Expand Up @@ -109,6 +110,7 @@ const sloResponseSchema = t.intersection([
groupBy: allOrAnyString,
createdAt: dateType,
updatedAt: dateType,
version: t.number,
}),
t.partial({
instanceId: allOrAnyString,
Expand Down Expand Up @@ -157,6 +159,12 @@ const manageSLOParamsSchema = t.type({
path: t.type({ id: sloIdSchema }),
});

const resetSLOParamsSchema = t.type({
path: t.type({ id: sloIdSchema }),
});

const resetSLOResponseSchema = sloResponseSchema;

const updateSLOResponseSchema = sloResponseSchema;

const findSLOResponseSchema = t.type({
Expand All @@ -182,23 +190,21 @@ const fetchHistoricalSummaryResponseSchema = t.array(
})
);

/**
* The query params schema for /internal/observability/slo/_definitions
*
* @private
*/
const findSloDefinitionsParamsSchema = t.type({
query: t.type({
const findSloDefinitionsParamsSchema = t.partial({
query: t.partial({
search: t.string,
includeOutdatedOnly: toBooleanRt,
page: t.string,
perPage: t.string,
}),
});

/**
* The response schema for /internal/observability/slo/_definitions
*
* @private
*/
const findSloDefinitionsResponseSchema = t.array(sloResponseSchema);
const findSloDefinitionsResponseSchema = t.type({
page: t.number,
perPage: t.number,
total: t.number,
results: t.array(sloResponseSchema),
});

const getSLOBurnRatesResponseSchema = t.type({
burnRates: t.array(
Expand Down Expand Up @@ -244,6 +250,9 @@ type GetSLOResponse = t.OutputOf<typeof getSLOResponseSchema>;

type ManageSLOParams = t.TypeOf<typeof manageSLOParamsSchema.props.path>;

type ResetSLOParams = t.TypeOf<typeof resetSLOParamsSchema.props.path>;
type ResetSLOResponse = t.OutputOf<typeof resetSLOResponseSchema>;

type UpdateSLOInput = t.OutputOf<typeof updateSLOParamsSchema.props.body>;
type UpdateSLOParams = t.TypeOf<typeof updateSLOParamsSchema.props.body>;
type UpdateSLOResponse = t.OutputOf<typeof updateSLOResponseSchema>;
Expand All @@ -258,12 +267,8 @@ type FetchHistoricalSummaryParams = t.TypeOf<typeof fetchHistoricalSummaryParams
type FetchHistoricalSummaryResponse = t.OutputOf<typeof fetchHistoricalSummaryResponseSchema>;
type HistoricalSummaryResponse = t.OutputOf<typeof historicalSummarySchema>;

/**
* The response type for /internal/observability/slo/_definitions
*
* @private
*/
type FindSloDefinitionsResponse = t.OutputOf<typeof findSloDefinitionsResponseSchema>;
type FindSLODefinitionsParams = t.TypeOf<typeof findSloDefinitionsParamsSchema.props.query>;
type FindSLODefinitionsResponse = t.OutputOf<typeof findSloDefinitionsResponseSchema>;

type GetPreviewDataParams = t.TypeOf<typeof getPreviewDataParamsSchema.props.body>;
type GetPreviewDataResponse = t.OutputOf<typeof getPreviewDataResponseSchema>;
Expand Down Expand Up @@ -300,6 +305,8 @@ export {
findSloDefinitionsParamsSchema,
findSloDefinitionsResponseSchema,
manageSLOParamsSchema,
resetSLOParamsSchema,
resetSLOResponseSchema,
sloResponseSchema,
sloWithSummaryResponseSchema,
updateSLOParamsSchema,
Expand All @@ -325,8 +332,11 @@ export type {
FetchHistoricalSummaryParams,
FetchHistoricalSummaryResponse,
HistoricalSummaryResponse,
FindSloDefinitionsResponse,
FindSLODefinitionsParams,
FindSLODefinitionsResponse,
ManageSLOParams,
ResetSLOParams,
ResetSLOResponse,
SLOResponse,
SLOWithSummaryResponse,
UpdateSLOInput,
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/kbn-slo-schema/src/schema/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const sloSchema = t.type({
createdAt: dateType,
updatedAt: dateType,
groupBy: allOrAnyString,
version: t.number,
});

const sloWithSummarySchema = t.intersection([sloSchema, t.type({ summary: summarySchema })]);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/packages/kbn-slo-schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"**/*.ts"
],
"kbn_references": [
"@kbn/std"
"@kbn/std",
"@kbn/io-ts-utils"
],
"exclude": [
"target/**/*",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/performance/journeys/many_fields_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const journey = new Journey({
.step('Go to Transforms', async ({ page, kbnUrl, kibanaPage }) => {
await page.goto(kbnUrl.get(`app/management/data/transform`));
await kibanaPage.waitForHeader();
await page.waitForSelector(subj('transformButtonCreate'));
await page.waitForSelector(subj('transformCreateFirstButton'));
await page.waitForSelector(subj('globalLoadingIndicator-hidden'));
})
.step('Go to data view selection', async ({ page }) => {
const createButtons = page.locator(subj('transformButtonCreate'));
const createButtons = page.locator(subj('transformCreateFirstButton'));
await createButtons.first().click();
await page.waitForSelector(subj('savedObjectsFinderTable'));
})
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import type {
PackageSpecTags,
} from '../../../../types';
import { savedObjectTypes } from '../../packages';
import { indexPatternTypes, getIndexPatternSavedObjects } from '../index_pattern/install';
import {
indexPatternTypes,
getIndexPatternSavedObjects,
makeManagedIndexPatternsGlobal,
} from '../index_pattern/install';
import { saveKibanaAssetsRefs } from '../../packages/install';
import { deleteKibanaSavedObjectsAssets } from '../../packages/remove';
import { KibanaSOReferenceError } from '../../../../errors';
Expand Down Expand Up @@ -114,12 +118,14 @@ export function createSavedObjectKibanaAsset(asset: ArchiveAsset): SavedObjectTo
}

export async function installKibanaAssets(options: {
savedObjectsClient: SavedObjectsClientContract;
savedObjectsImporter: SavedObjectsImporterContract;
logger: Logger;
pkgName: string;
kibanaAssets: Record<KibanaAssetType, ArchiveAsset[]>;
}): Promise<SavedObjectsImportSuccess[]> {
const { kibanaAssets, savedObjectsImporter, logger } = options;
const { kibanaAssets, savedObjectsClient, savedObjectsImporter, logger } = options;

const assetsToInstall = Object.entries(kibanaAssets).flatMap(([assetType, assets]) => {
if (!validKibanaAssetTypes.has(assetType as KibanaAssetType)) {
return [];
Expand Down Expand Up @@ -152,6 +158,8 @@ export async function installKibanaAssets(options: {
managed: true,
});

await makeManagedIndexPatternsGlobal(savedObjectsClient);

const installedAssets = await installKibanaSavedObjects({
logger,
savedObjectsImporter,
Expand Down Expand Up @@ -196,6 +204,7 @@ export async function installKibanaAssetsAndReferences({
);

const importedAssets = await installKibanaAssets({
savedObjectsClient,
logger,
savedObjectsImporter,
pkgName,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';

import { createAppContextStartContractMock } from '../../../../mocks';

import { appContextService } from '../../../app_context';

import { makeManagedIndexPatternsGlobal } from './install';

describe('Fleet index patterns', () => {
let mockSoClient: jest.Mocked<SavedObjectsClientContract>;
let mockContract: ReturnType<typeof createAppContextStartContractMock>;

beforeEach(() => {
mockSoClient = savedObjectsClientMock.create();
mockContract = createAppContextStartContractMock();
appContextService.start(mockContract);
});

afterEach(() => {
appContextService.stop();
});

describe('makeManagedIndexPatternsGlobal', () => {
it('should call updateObjectsSpaces with the correct params', async () => {
const result = await makeManagedIndexPatternsGlobal(mockSoClient);

for (const pattern of ['logs-*', 'metrics-*']) {
expect(mockSoClient.updateObjectsSpaces).toHaveBeenCalledWith(
[{ id: pattern, type: 'index-pattern' }],
['*'],
[]
);
}

expect(result).toHaveLength(2);
});

it('handles errors from updateObjectsSpaces', async () => {
mockSoClient.updateObjectsSpaces.mockRejectedValue(new Error('foo'));

const result = await makeManagedIndexPatternsGlobal(mockSoClient);

expect(result).toHaveLength(0);
});
});
});
Loading

0 comments on commit 32d9b04

Please sign in to comment.