Skip to content

Commit

Permalink
Merge branch 'master' into fix/99660-uptime-alerts-check-monitor-stat…
Browse files Browse the repository at this point in the history
…us-by-monitor.timespan
  • Loading branch information
kibanamachine committed Jul 12, 2021
2 parents 0008224 + 832d349 commit 06a3d81
Show file tree
Hide file tree
Showing 498 changed files with 10,786 additions and 4,270 deletions.
61 changes: 61 additions & 0 deletions dev_docs/tutorials/debugging.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
id: kibDevTutorialDebugging
slug: /kibana-dev-docs/tutorial/debugging
title: Debugging in development
summary: Learn how to debug Kibana while running from source
date: 2021-04-26
tags: ['kibana', 'onboarding', 'dev', 'tutorials', 'debugging']
---

There are multiple ways to go about debugging Kibana when running from source.

## Debugging using Chrome DevTools

You will need to run Node using `--inspect` or `--inspect-brk` in order to enable the inspector. Additional information can be found in the [Node.js docs](https://nodejs.org/en/docs/guides/debugging-getting-started/).

Once Node is running with the inspector enabled, you can open `chrome://inspect` in your Chrome browser. You should see a remote target for the inspector running. Click "inspect". You can now begin using the debugger.

Next we will go over how to exactly enable the inspector for different aspects of the codebase.

### Jest Unit Tests

You will need to run Jest directly from the Node script:

`node --inspect-brk scripts/jest [TestPathPattern]`

### Functional Test Runner

`node --inspect-brk scripts/functional_test_runner`

### Development Server

`node --inspect-brk scripts/kibana`

## Debugging using logging

When running Kibana, it's sometimes helpful to enable verbose logging.

`yarn start --verbose`

Using verbose logging usually results in much more information than you're interested in. The [logging documentation](https://www.elastic.co/guide/en/kibana/current/logging-settings.html) covers ways to change the log level of certain types.

In the following example of a configuration stored in `config/kibana.dev.yml` we are logging all Elasticsearch queries and any logs created by the Management plugin.

```
logging:
appenders:
console:
type: console
layout:
type: pattern
highlight: true
root:
appenders: [default, console]
level: info
loggers:
- name: plugins.management
level: debug
- name: elasticsearch.query
level: debug
```
31 changes: 22 additions & 9 deletions docs/discover/search-sessions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,28 @@ behaves differently:
[float]
==== Limitations

Certain visualization features do not fully support background search sessions yet. If a dashboard using these features gets restored,
all panels using unsupported features won't load immediately, but instead send out additional data requests which can take a while to complete.
In this case a warning *Your search session is still running* will be shown.
Certain visualization features do not fully support background search sessions. If a dashboard
using these features is restored,
all panels using unsupported features won't load immediately, but instead send out additional
data requests, which can take a while to complete.
The warning *Your search session is still running* is shown.

You can either wait for these additional requests to complete or come back to the dashboard later when all data requests have been finished.
You can either wait for these additional requests to complete or come back to the dashboard later
when all data requests have finished.

A panel on a dashboard can behave like this if one of the following features is used:
* *Lens* - A *top values* dimension with an enabled setting *Group other values as "Other"* (configurable in the *Advanced* section of the dimension)
* *Lens* - An *intervals* dimension is used
* *Aggregation based* visualizations - A *terms* aggregation is used with an enabled setting *Group other values in separate bucket*
* *Aggregation based* visualizations - A *histogram* aggregation is used
* *Maps* - Layers using joins, blended layers or tracks layers are used

**Lens**

* A *top values* dimension with an enabled *Group other values as "Other"* setting.
This is configurable in the *Advanced* section of the dimension.
* An *intervals* dimension.

**Aggregation based** visualizations

* A *terms* aggregation with an enabled *Group other values in separate bucket* setting.
* A *histogram* aggregation.

**Maps**

* Layers using joins, blended layers, or tracks layers.
3 changes: 0 additions & 3 deletions docs/user/dashboard/lens-advanced.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ image::images/lens_advanced_5_2.png[Line chart with cumulative sum of orders mad
*Lens* allows you to compare the currently selected time range with historical data using the *Time shift* option. To calculate the percent
change, use *Formula*.

Time shifts can be used on any metric. The special shift *previous* will show the time window preceding the currently selected one, spanning the same duration.
For example, if *Last 7 days* is selected in the time filter, *previous* will show data from 14 days ago to 7 days ago.

If multiple time shifts are used in a single chart, a multiple of the date histogram interval should be chosen - otherwise data points might not line up in the chart and empty spots can occur.
For example, if a daily interval is used, shifting one series by *36h*, and another one by *1d*, is not recommended. In this scenario, either reduce the interval to *12h*, or create two separate charts.

Expand Down
4 changes: 3 additions & 1 deletion examples/expressions_explorer/public/render_expressions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ interface Props {
}

export function RenderExpressionsExample({ expressions, inspector }: Props) {
const [expression, updateExpression] = useState('markdown "## expressions explorer rendering"');
const [expression, updateExpression] = useState(
'markdownVis "## expressions explorer rendering"'
);

const expressionChanged = (value: string) => {
updateExpression(value);
Expand Down
2 changes: 1 addition & 1 deletion examples/expressions_explorer/public/run_expressions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface Props {
}

export function RunExpressionsExample({ expressions, inspector }: Props) {
const [expression, updateExpression] = useState('markdown "## expressions explorer"');
const [expression, updateExpression] = useState('markdownVis "## expressions explorer"');
const [result, updateResult] = useState<unknown>({});

const expressionChanged = (value: string) => {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set",
"@elastic/search-ui-app-search-connector": "^1.6.0",
"@elastic/ui-ace": "0.2.3",
"@emotion/react": "^11.4.0",
"@hapi/accept": "^5.0.2",
"@hapi/boom": "^9.1.1",
"@hapi/cookie": "^11.0.2",
Expand Down Expand Up @@ -351,7 +352,7 @@
"react-moment-proptypes": "^1.7.0",
"react-monaco-editor": "^0.41.2",
"react-popper-tooltip": "^2.10.1",
"react-query": "^3.13.10",
"react-query": "^3.18.1",
"react-redux": "^7.2.0",
"react-resizable": "^1.7.5",
"react-resize-detector": "^4.2.0",
Expand Down Expand Up @@ -454,6 +455,8 @@
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^6.0.0",
"@emotion/babel-preset-css-prop": "^11.2.0",
"@emotion/jest": "^11.3.0",
"@istanbuljs/schema": "^0.1.2",
"@jest/reporters": "^26.6.2",
"@kbn/babel-code-parser": "link:bazel-bin/packages/kbn-babel-code-parser",
Expand Down
10 changes: 9 additions & 1 deletion packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { USES_STYLED_COMPONENTS } = require('@kbn/dev-utils');

module.exports = {
extends: [
'./javascript.js',
Expand Down Expand Up @@ -79,7 +81,13 @@ module.exports = {
from: 'react-intl',
to: '@kbn/i18n/react',
disallowedMessage: `import from @kbn/i18n/react instead`
}
},
{
from: 'styled-components',
to: false,
exclude: USES_STYLED_COMPONENTS,
disallowedMessage: `Prefer using @emotion/react instead. To use styled-components, ensure you plugin is enabled in @kbn/dev-utils/src/babel.ts.`
},
],
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-babel-preset/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DEPS = [
"@npm//@babel/preset-env",
"@npm//@babel/preset-react",
"@npm//@babel/preset-typescript",
"@npm//@emotion/babel-preset-css-prop",
"@npm//babel-plugin-add-module-exports",
"@npm//babel-plugin-styled-components",
"@npm//babel-plugin-transform-react-remove-prop-types",
Expand Down
34 changes: 26 additions & 8 deletions packages/kbn-babel-preset/webpack_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

const { USES_STYLED_COMPONENTS } = require.resolve('@kbn/dev-utils');

module.exports = () => {
return {
presets: [
Expand All @@ -21,14 +23,6 @@ module.exports = () => {
],
require('./common_preset'),
],
plugins: [
[
require.resolve('babel-plugin-styled-components'),
{
fileName: false,
},
],
],
env: {
production: {
plugins: [
Expand All @@ -42,5 +36,29 @@ module.exports = () => {
],
},
},
overrides: [
{
include: USES_STYLED_COMPONENTS,
plugins: [
[
require.resolve('babel-plugin-styled-components'),
{
fileName: false,
},
],
],
},
{
exclude: USES_STYLED_COMPONENTS,
presets: [
[
require.resolve('@emotion/babel-preset-css-prop'),
{
labelFormat: '[local]',
},
],
],
},
],
};
};
3 changes: 2 additions & 1 deletion packages/kbn-crypto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/node-forge",
"@npm//@types/testing-library__jest-dom",
"@npm//resize-observer-polyfill"
"@npm//resize-observer-polyfill",
"@npm//@emotion/react",
]

DEPS = SRC_DEPS + TYPES_DEPS
Expand Down
11 changes: 11 additions & 0 deletions packages/kbn-dev-utils/src/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ export async function transformFileWithBabel(file: File) {
file.extname = '.js';
transformedFiles.add(file);
}

/**
* Synchronized regex list of files that use `styled-components`.
* Used by `kbn-babel-preset` and `elastic-eslint-config-kibana`.
*/
export const USES_STYLED_COMPONENTS = [
/packages[\/\\]kbn-ui-shared-deps[\/\\]/,
/src[\/\\]plugins[\/\\](data|kibana_react)[\/\\]/,
/x-pack[\/\\]plugins[\/\\](apm|beats_management|cases|fleet|infra|lists|observability|osquery|security_solution|timelines|uptime)[\/\\]/,
/x-pack[\/\\]test[\/\\]plugin_functional[\/\\]plugins[\/\\]resolver_test[\/\\]/,
];
23 changes: 22 additions & 1 deletion packages/kbn-eslint-plugin-eslint/rules/module_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ module.exports = {
disallowedMessage: {
type: 'string',
},
include: {
type: 'array',
},
exclude: {
type: 'array',
},
},
anyOf: [
{
Expand All @@ -95,7 +101,22 @@ module.exports = {
],
},
create: (context) => {
const mappings = context.options[0];
const filename = path.relative(KIBANA_ROOT, context.getFilename());

const mappings = context.options[0].filter((mapping) => {
// exclude mapping rule if it is explicitly excluded from this file
if (mapping.exclude && mapping.exclude.some((p) => p.test(filename))) {
return false;
}

// if this mapping rule is only included in specific files, optionally include it
if (mapping.include) {
return mapping.include.some((p) => p.test(filename));
}

// include all mapping rules by default
return true;
});

return {
ImportDeclaration(node) {
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-rule-data-utils/src/technical_field_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const RULE_NAME = 'rule.name' as const;
const RULE_CATEGORY = 'rule.category' as const;
const TAGS = 'tags' as const;
const PRODUCER = `${ALERT_NAMESPACE}.producer` as const;
const OWNER = `${ALERT_NAMESPACE}.owner` as const;
const ALERT_ID = `${ALERT_NAMESPACE}.id` as const;
const ALERT_UUID = `${ALERT_NAMESPACE}.uuid` as const;
const ALERT_START = `${ALERT_NAMESPACE}.start` as const;
Expand All @@ -40,6 +41,7 @@ const fields = {
RULE_CATEGORY,
TAGS,
PRODUCER,
OWNER,
ALERT_ID,
ALERT_UUID,
ALERT_START,
Expand All @@ -62,6 +64,7 @@ export {
RULE_CATEGORY,
TAGS,
PRODUCER,
OWNER,
ALERT_ID,
ALERT_UUID,
ALERT_START,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* 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.
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// Similar to the src/core/server/saved_objects/version/decode_version.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* 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.
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-securitysolution-es-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

export * from './bad_request_error';
export * from './create_boostrap_index';
export * from './decode_version';
export * from './delete_all_index';
export * from './delete_policy';
export * from './delete_template';
export * from './elasticsearch_client';
export * from './encode_hit_version';
export * from './get_index_aliases';
export * from './get_index_count';
export * from './get_index_exists';
Expand Down
20 changes: 19 additions & 1 deletion packages/kbn-storybook/lib/default_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
* Side Public License, v 1.
*/

import * as path from 'path';
import { StorybookConfig } from '@storybook/core/types';
import { REPO_ROOT } from './constants';

const toPath = (_path: string) => path.join(REPO_ROOT, _path);
export const defaultConfig: StorybookConfig = {
addons: ['@kbn/storybook/preset', '@storybook/addon-a11y', '@storybook/addon-essentials'],
stories: ['../**/*.stories.tsx'],
Expand All @@ -22,6 +25,21 @@ export const defaultConfig: StorybookConfig = {

config.node = { fs: 'empty' };

return config;
// Remove when @storybook has moved to @emotion v11
// https://github.com/storybookjs/storybook/issues/13145
const emotion11CompatibleConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
'@emotion/core': toPath('node_modules/@emotion/react'),
'@emotion/styled': toPath('node_modules/@emotion/styled'),
'emotion-theming': toPath('node_modules/@emotion/react'),
},
},
};

return emotion11CompatibleConfig;
},
};
Loading

0 comments on commit 06a3d81

Please sign in to comment.