Skip to content

Commit ebc28a2

Browse files
Merge branch 'master' into tsvb-legend-color-picker
2 parents e4d87e0 + cce6861 commit ebc28a2

File tree

642 files changed

+6083
-4061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

642 files changed

+6083
-4061
lines changed

.eslintrc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ module.exports = {
13161316

13171317
{
13181318
files: [
1319-
// platform-team owned code
1319+
// core-team owned code
13201320
'src/core/**',
13211321
'x-pack/plugins/features/**',
13221322
'x-pack/plugins/licensing/**',
@@ -1325,6 +1325,14 @@ module.exports = {
13251325
'packages/kbn-config-schema',
13261326
'src/plugins/status_page/**',
13271327
'src/plugins/saved_objects_management/**',
1328+
'packages/kbn-analytics/**',
1329+
'packages/kbn-telemetry-tools/**',
1330+
'src/plugins/kibana_usage_collection/**',
1331+
'src/plugins/usage_collection/**',
1332+
'src/plugins/telemetry/**',
1333+
'src/plugins/telemetry_collection_manager/**',
1334+
'src/plugins/telemetry_management_section/**',
1335+
'x-pack/plugins/telemetry_collection_xpack/**',
13281336
],
13291337
rules: {
13301338
'@typescript-eslint/prefer-ts-expect-error': 'error',

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/ @elastic/kibana-core @elastic/
240240
# Security
241241
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core
242242
/src/plugins/security_oss/ @elastic/kibana-security
243+
/src/plugins/spaces_oss/ @elastic/kibana-security
243244
/test/security_functional/ @elastic/kibana-security
244245
/x-pack/plugins/spaces/ @elastic/kibana-security
245246
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security

dev_docs/building_blocks.mdx

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
id: kibBuildingBlocks
3+
slug: /kibana-dev-docs/building-blocks
4+
title: Building blocks
5+
summary: Consider these building blocks when developing your plugin.
6+
date: 2021-02-24
7+
tags: ['kibana','onboarding', 'dev', 'architecture']
8+
---
9+
10+
When building a plugin in Kibana, there are a handful of architectural "building blocks" you can use. Some of these building blocks are "higher-level",
11+
and some are "lower-level". High-level building blocks come
12+
with many built-in capabilities, require less maintenance, and evolve new feature sets over time with little to no
13+
impact on consumers. When developers use high-level building blocks, new features are exposed consistently, across all of Kibana, at the same time.
14+
On the downside, they are not as flexible as our low-level building blocks.
15+
16+
Low-level building blocks
17+
provide greater flexibility, but require more code to stitch them together into a meaningful UX. This results in higher maintenance cost for consumers and greater UI/UX variability
18+
across Kibana.
19+
20+
For example, if an application is using <DocLink id="kibBuildingBlocks" section="index-patterns" text="Index Patterns"/> and
21+
<DocLink id="kibBuildingBlocks" section="search-source" text="Search Source"/>,
22+
their application would automatically support runtime fields. If the app is instead using the
23+
lower-level <DocLink id="kibBuildingBlocks" section="search-strategy" text="Search Strategy"/>, additional work would be required.
24+
25+
Armed with this knowledge, you can choose what works best for your use case!
26+
27+
# Application building blocks
28+
29+
## UI components
30+
31+
The following high-level building blocks can be rendered directly into your application UI.
32+
33+
### Query Bar
34+
35+
The <DocLink id="kibDataPlugin" text="Data plugin"/> provides a high-level Query Bar component that comes with support for Lucene, KQL, Saved Queries,
36+
and <DocLink id="kibBuildingBlocks" section="index-patterns" text="Index Patterns"/>.
37+
38+
If you would like to expose the ability to search and filter on Elasticsearch data, the Query Bar provided by the
39+
<DocLink id="kibDataPlugin" text="Data plugin"/>
40+
is your go-to building block.
41+
42+
**Github labels**: `Team:AppServices`, `Feature:QueryBar`
43+
44+
### Dashboard Embeddable
45+
46+
Add a Dashboard Embeddable directly inside your application to provide users with a set of visualizations and graphs that work seamlessly
47+
with the <DocLink id="kibBuildingBlocks" section="query-bar" text="Query Bar"/>. Every feature that is added to a registered
48+
<DocLink id="kibBuildingBlocks" section="embeddables" text="Embeddable"/>
49+
(Lens, Maps, Saved Searches and more) will be available automatically, as well as any
50+
<DocLink id="kibBuildingBlocks" section="ui-actions--triggers" text="UI Actions"/> that are
51+
added to the Embeddable context menu panel (for example, drilldowns, custom panel time ranges, and "share to" features).
52+
53+
The Dashboard Embeddable is one of the highest-level UI components you can add to your application.
54+
55+
**Github labels**: `Team:Presentation`, `Feature:Dashboard`
56+
57+
### Lens Embeddable
58+
59+
Check out the Lens Embeddable if you wish to show users visualizations based on Elasticsearch data without worrying about query building and chart rendering. It's built on top of the
60+
<DocLink id="kibBuildingBlocks" section="expressions" text="Expression language"/>, and integrates with
61+
<DocLink id="kibBuildingBlocks" section="index-patterns" text="Index Patterns"/>
62+
and <DocLink id="kibBuildingBlocks" section="ui-actions--triggers" text="UI Actions"/>. Using the same configuration, it's also possible to link to
63+
a prefilled Lens editor, allowing the user to drill deeper and explore their data.
64+
65+
**Github labels**: `Team:KibanaApp`, `Feature:Lens`
66+
67+
### Map Embeddable
68+
69+
Check out the Map Embeddable if you wish to embed a map in your application.
70+
71+
**Github labels**: `Team:Geo`
72+
73+
## Searching
74+
75+
### Index Patterns
76+
77+
<DocLink id="kibDataPlugin" section="index-patterns-api" text="Index Patterns"/> are a high-level, space-aware abstraction layer that sits
78+
above Data Streams and Elasticsearch indices. Index Patterns provide users the
79+
ability to define and customize the data they wish to search and filter on, on a per-space basis. For example, users can specify a set of indices,
80+
and they can customize the field list with runtime fields, formatting options and custom labels.
81+
82+
Index Patterns are used in many other high-level building blocks so we highly recommend you consider this building block for your search needs.
83+
84+
**Github labels**: `Team:AppServices`, `Feature:Index Patterns`
85+
86+
### Search Source
87+
88+
<DocLink id="kibDataPlugin" section="searchsource" text="Search Source"/> is a high-level search service offered by the
89+
<DocLink id="kibDataPlugin" section="searchsource" text="Data plugin"/>. It requires an
90+
<DocLink id="kibBuildingBlocks" section="index-patterns" text="Index Pattern"/>, and abstracts away the raw ES DSL and search endpoint. Internally
91+
it uses the ES <DocLink id="kibBuildingBlocks" section="search-strategies" text="Search Strategy"/>. Use Search Source if you need to query data
92+
from Elasticsearch, and you aren't already using one of the high-level UI Components that handles this internally.
93+
94+
**Github labels**: `Team:AppServices`, `Feature:Search`
95+
96+
### Search Strategies
97+
98+
Search Strategies are a low-level building block that abstracts away search details, like what REST endpoint is being called. The ES Search Strategy
99+
is a very lightweight abstraction layer that sits just above querying ES with the elasticsearch-js client. Other search stragies are offered for other
100+
languages, like EQL and SQL. These are very low-level building blocks so expect a lot of glue work to make these work with the higher-level abstractions.
101+
102+
**Github labels**: `Team:AppServices`, `Feature:Search`
103+
104+
### Expressions
105+
106+
Expressions are a low-level building block that can be used if you have advanced search needs that requiring piping results into additional functionality, like
107+
joining and manipulating data. Lens and Canvas are built on top of Expressions. Most developers should be able to use
108+
<DocLink id="kibBuildingBlocks" section="lens-embeddable" text="Lens"/> or
109+
<DocLink id="kibBuildingBlocks" section="search-source" text="Search Source"/>, rather than need to access the Expression language directly.
110+
111+
**Github labels**: `Team:AppServices`, `Feature:ExpressionLanguage`
112+
113+
## Saved Objects
114+
115+
<DocLink id="kibDevDocsSavedObjectsIntro" text="Saved Objects" /> should be used if you need to persist application-level information. If you were building a TODO
116+
application, each TODO item would be a `Saved Object`. Saved objects come pre-wired with support for bulk export/import, security features like space sharing and
117+
space isolation, and tags.
118+
119+
**Github labels**: `Team:Core`, `Feature:Saved Objects`
120+
121+
# Integration building blocks
122+
123+
Use the following building blocks to create an inter-connected, cross-application, holistic Kibana experience. These building blocks allow you to expose functionality
124+
that promotes your own application into other applications, as well as help developers of other applications integrate into your app.
125+
126+
## UI Actions & Triggers
127+
128+
Integrate custom actions into other applications by registering UI Actions attached to existing triggers. For example, the Maps
129+
application could register a UI Action called "View in Maps" to appear any time the user clicked a geo field to filter on.
130+
131+
**Github labels**: `Team:AppServices`, `Feature:UIActions`
132+
133+
## Embeddables
134+
135+
Embeddables help you integrate your application with the Dashboard application. Register your custom UI Widget as an Embeddable and users will
136+
be able to add it as a panel on a Dashboard. With a little extra work, it can also be exposed in Canvas workpads.
137+
138+
**Github labels**: `Team:AppServices`, `Feature:Embeddables`

docs/developer/plugin-list.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ which also contains the timelion APIs and backend, look at the vis_type_timelion
224224
|This plugins contains helpers to redirect legacy URLs. It can be used to forward old URLs to their new counterparts.
225225
226226
227-
|{kib-repo}blob/{branch}/src/plugins/usage_collection/README.md[usageCollection]
227+
|{kib-repo}blob/{branch}/src/plugins/usage_collection/README.mdx[usageCollection]
228228
|The Usage Collection Service defines a set of APIs for other plugins to report the usage of their features. At the same time, it provides necessary the APIs for other services (i.e.: telemetry, monitoring, ...) to consume that usage data.
229229
230230

src/core/CONVENTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class Plugin {
285285

286286
#### Usage Collection
287287

288-
For creating and registering a Usage Collector. Collectors should be defined in a separate directory `server/collectors/`. You can read more about usage collectors on `src/plugins/usage_collection/README.md`.
288+
For creating and registering a Usage Collector. Collectors should be defined in a separate directory `server/collectors/`. You can read more about usage collectors on `src/plugins/usage_collection/README.mdx`.
289289

290290
```ts
291291
// server/collectors/register.ts

src/core/server/saved_objects/service/lib/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ export class SavedObjectsRepository {
16401640
*
16411641
* When using incrementCounter for collecting usage data, you need to ensure
16421642
* that usage collection happens on a best-effort basis and doesn't
1643-
* negatively affect your plugin or users. See https://github.com/elastic/kibana/blob/master/src/plugins/usage_collection/README.md#tracking-interactions-with-incrementcounter)
1643+
* negatively affect your plugin or users. See https://github.com/elastic/kibana/blob/master/src/plugins/usage_collection/README.mdx#tracking-interactions-with-incrementcounter)
16441644
*
16451645
* @example
16461646
* ```ts

src/plugins/discover/public/application/components/create_discover_grid_directive.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66
* Side Public License, v 1.
77
*/
88

9-
import * as React from 'react';
9+
import React, { useState } from 'react';
1010
import { I18nProvider } from '@kbn/i18n/react';
1111
import { DiscoverGrid, DiscoverGridProps } from './discover_grid/discover_grid';
1212
import { getServices } from '../../kibana_services';
13+
import { ElasticSearchHit } from '../doc_views/doc_views_types';
1314

1415
export const DataGridMemoized = React.memo((props: DiscoverGridProps) => (
1516
<DiscoverGrid {...props} />
1617
));
1718

1819
export function DiscoverGridEmbeddable(props: DiscoverGridProps) {
20+
const [expandedDoc, setExpandedDoc] = useState<ElasticSearchHit | undefined>(undefined);
21+
1922
return (
2023
<I18nProvider>
21-
<DataGridMemoized {...props} services={getServices()} />
24+
<DataGridMemoized
25+
{...props}
26+
setExpandedDoc={setExpandedDoc}
27+
expandedDoc={expandedDoc}
28+
services={getServices()}
29+
/>
2230
</I18nProvider>
2331
);
2432
}

src/plugins/es_ui_shared/__packages_do_not_import__/errors/es_error_parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ interface ParsedError {
1111
cause: string[];
1212
}
1313

14-
const getCause = (obj: any = {}, causes: string[] = []): string[] => {
14+
export const getEsCause = (obj: any = {}, causes: string[] = []): string[] => {
1515
const updated = [...causes];
1616

1717
if (obj.caused_by) {
1818
updated.push(obj.caused_by.reason);
1919

2020
// Recursively find all the "caused by" reasons
21-
return getCause(obj.caused_by, updated);
21+
return getEsCause(obj.caused_by, updated);
2222
}
2323

2424
return updated.filter(Boolean);
@@ -27,7 +27,7 @@ const getCause = (obj: any = {}, causes: string[] = []): string[] => {
2727
export const parseEsError = (err: string): ParsedError => {
2828
try {
2929
const { error } = JSON.parse(err);
30-
const cause = getCause(error);
30+
const cause = getEsCause(error);
3131
return {
3232
message: error.reason,
3333
cause,

src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { ApiError } from '@elastic/elasticsearch';
1010
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
1111
import { IKibanaResponse, KibanaResponseFactory } from 'kibana/server';
12+
import { getEsCause } from './es_error_parser';
1213

1314
interface EsErrorHandlerParams {
1415
error: ApiError;
@@ -34,7 +35,15 @@ export const handleEsError = ({
3435
const { statusCode, body } = error as ResponseError;
3536
return response.customError({
3637
statusCode,
37-
body: { message: body.error?.reason },
38+
body: {
39+
message: body.error?.reason,
40+
attributes: {
41+
// The full original ES error object
42+
error: body.error,
43+
// We assume that this is an ES error object with a nested caused by chain if we can see the "caused_by" field at the top-level
44+
causes: body.error?.caused_by ? getEsCause(body.error) : undefined,
45+
},
46+
},
3847
});
3948
}
4049
// Case: default

src/plugins/kibana_usage_collection/server/collectors/kibana/get_saved_object_counts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getSavedObjectsCounts } from './get_saved_object_counts';
1212
export function mockGetSavedObjectsCounts(params: any) {
1313
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
1414
esClient.search.mockResolvedValue(
15-
// @ts-ignore we only care about the response body
15+
// @ts-expect-error we only care about the response body
1616
{
1717
body: { ...params },
1818
}

0 commit comments

Comments
 (0)