-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Logs+] Implement Logs Dataset selector #159907
Changes from 91 commits
9ab4529
6bcf4f8
eeecf6f
eea7560
1a6fb0b
d2a76bb
559bc9c
c775f49
5d957b5
b68f33b
826cb03
7ed6317
4d2d8cd
6660674
c2bd77e
80b4dc2
cc23a2a
d102bdb
60436ed
bc227c2
ee42d87
dd530db
ec969ef
b39b901
2220c29
dd77c92
b3cb323
790df31
c47afcc
01fb593
99fbea3
5cf58f4
8391f03
fc535df
e549917
0ad11d1
0b8fdc7
75f92c9
a5feafd
9d050fb
8a14ec7
0d31cc6
d5e10df
7aef4ca
02bd234
a00b747
eca8902
3131c30
c8036c6
4bf3fa5
9d862ab
48ceaae
e0b61ac
d8e3a31
9aee3b1
fc44fb6
6a586a9
9ac5732
7211653
2b4f3e5
126ea3b
474098e
e7e36e4
bc0a6a2
8e884f0
2a1495d
1e61e77
7ef8c35
9654ba1
3bda2aa
bf1a324
59a68f7
5e7a431
106e3a9
b498853
073d301
7a713e3
c4fd397
e70e44c
14614ee
5228ce2
3e0b492
04fa5a9
906e7cd
4054fc6
f10030e
ad5b2d5
b6b654b
32e8580
1cc0d05
3aebf92
4b98e27
8109cc0
6f87200
b39f91c
0818d3f
19e9be2
9caebee
8a5e765
20f4363
5c2b3c8
3a06731
f2aa421
d2a4431
93d3537
cf48f3c
aedf1bb
007b64b
4462f41
e950984
645f3af
d4df21d
51db3a1
455e53f
bfaa5bc
6c8b461
fa90bff
3c0acf7
0a0d34a
1351408
48bdc91
ee0eeed
549cea8
57aee54
eafd4b9
294602b
2bc90cd
e583a6f
d8ff061
cfc5019
7a4dcd7
29f0d7b
e8ec06e
edcb90e
0ffdf0a
389c097
7d605a7
8184fb9
cbba119
b214654
033af2d
2893978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiIcon } from '@elastic/eui'; | ||
|
||
// Export mock package icon that doesn't trigger http requests | ||
export const PackageIcon = () => <EuiIcon type="package" style={{ marginRight: 8 }} />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
const defaultConfig = require('@kbn/storybook').defaultConfig; | ||
|
||
module.exports = { | ||
...defaultConfig, | ||
stories: ['../**/*.stories.mdx', ...defaultConfig.stories], | ||
webpackFinal: async (config) => { | ||
const originalConfig = await defaultConfig.webpackFinal(config); | ||
|
||
// Mock fleet plugin for PackageIcon component | ||
originalConfig.resolve.alias['@kbn/fleet-plugin/public'] = require.resolve( | ||
'./__mocks__/package_icon' | ||
); | ||
return originalConfig; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 const parameters = { | ||
docs: { | ||
source: { | ||
type: 'code', // without this, stories in mdx documents freeze the browser | ||
}, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Discover Log Explorer | ||
|
||
This plugin exposes and registers Logs+ features. | ||
weltenwort marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* 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 const DISCOVER_LOG_EXPLORER_PROFILE_ID = 'discover-log-explorer'; | ||
weltenwort marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* eslint-disable max-classes-per-file */ | ||
|
||
export class FindIntegrationsError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'FindIntegrationsError'; | ||
} | ||
} | ||
|
||
export class FindDatasetsError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'FindDatasetsError'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* 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 * from './types'; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||||||||||||||||||
/* | ||||||||||||||||||||||
* 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 { indexPatternRt } from '@kbn/io-ts-utils'; | ||||||||||||||||||||||
import * as rt from 'io-ts'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export const datasetRT = rt.exact( | ||||||||||||||||||||||
rt.intersection([ | ||||||||||||||||||||||
rt.type({ | ||||||||||||||||||||||
name: indexPatternRt, | ||||||||||||||||||||||
weltenwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
}), | ||||||||||||||||||||||
rt.partial({ | ||||||||||||||||||||||
title: rt.string, | ||||||||||||||||||||||
}), | ||||||||||||||||||||||
]) | ||||||||||||||||||||||
); | ||||||||||||||||||||||
|
||||||||||||||||||||||
const integrationStatusRT = rt.union([ | ||||||||||||||||||||||
rt.literal('installed'), | ||||||||||||||||||||||
rt.literal('installing'), | ||||||||||||||||||||||
rt.literal('install_failed'), | ||||||||||||||||||||||
]); | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The io-ts docs recommend using
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
export const integrationRT = rt.type({ | ||||||||||||||||||||||
name: rt.string, | ||||||||||||||||||||||
status: integrationStatusRT, | ||||||||||||||||||||||
version: rt.string, | ||||||||||||||||||||||
dataStreams: rt.array(datasetRT), | ||||||||||||||||||||||
}); | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type Dataset = rt.TypeOf<typeof datasetRT>; | ||||||||||||||||||||||
export type Integration = rt.TypeOf<typeof integrationRT>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { isEmpty, mapValues, omitBy } from 'lodash'; | ||
import { Integration } from '../types'; | ||
import { FindDatasetsRequestQuery } from './find_datasets'; | ||
import { FindIntegrationsRequestQuery } from './find_integrations'; | ||
|
||
/** | ||
* Constants | ||
*/ | ||
export const DATASETS_URL = '/api/fleet/epm/datasets'; | ||
export const INTEGRATIONS_URL = '/api/fleet/epm/packages/installed'; | ||
|
||
/** | ||
* Common types | ||
*/ | ||
export const sortOrderRT = rt.union([rt.literal('asc'), rt.literal('desc')]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, how about following the official recommendation about unions of string literals? |
||
export type SortOrder = rt.TypeOf<typeof sortOrderRT>; | ||
export type IntegrationId = `integration-${string}-${string}`; | ||
weltenwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Getters | ||
*/ | ||
export const getIntegrationId = (integration: Integration): IntegrationId => | ||
`integration-${integration.name}-${integration.version}`; | ||
|
||
/** | ||
* Utils | ||
*/ | ||
function stringifyByProp( | ||
obj: FindIntegrationsRequestQuery | FindDatasetsRequestQuery, | ||
props: string[] | ||
) { | ||
return mapValues(obj, (val, key) => (props.includes(key) ? JSON.stringify(val) : val)); | ||
} | ||
|
||
/** | ||
* Format the integrations and data streams search request into the required API format | ||
*/ | ||
export const formatSearch = (search: FindIntegrationsRequestQuery | FindDatasetsRequestQuery) => { | ||
return stringifyByProp(omitBy(search, isEmpty), ['searchAfter']); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { datasetRT } from '../types'; | ||
import { sortOrderRT } from './common'; | ||
|
||
export const findDatasetsResponseRT = rt.type({ | ||
items: rt.array(datasetRT), | ||
}); | ||
|
||
export const findDatasetsRequestQueryRT = rt.exact( | ||
rt.partial({ | ||
datasetQuery: rt.string, | ||
type: rt.literal('logs'), | ||
sortOrder: sortOrderRT, | ||
uncategorisedOnly: rt.boolean, | ||
}) | ||
); | ||
|
||
export type FindDatasetsRequestQuery = rt.TypeOf<typeof findDatasetsRequestQueryRT>; | ||
export type FindDatasetsResponse = rt.TypeOf<typeof findDatasetsResponseRT>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add it to
.buildkite/scripts/steps/storybooks/build_and_upload.ts
as recently documented in #160473?