Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-99447
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Jun 3, 2021
2 parents b163c1b + 08ba260 commit e9b1562
Show file tree
Hide file tree
Showing 360 changed files with 9,043 additions and 2,875 deletions.
129 changes: 129 additions & 0 deletions dev_docs/tutorials/expressions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
id: kibDevTutorialExpressions
slug: /kibana-dev-docs/tutorials/expressions
title: Kibana Expressions Service
summary: Kibana Expressions Service
date: 2021-06-01
tags: ['kibana', 'onboarding', 'dev', 'architecture']
---

## Expressions service

Expression service exposes a registry of reusable functions primary used for fetching and transposing data and a registry of renderer functions that can render data into a DOM element.
Adding functions is easy and so is reusing them. An expression is a chain of functions with provided arguments, which given a single input translates to a single output.
Each expression is representable by a human friendly string which a user can type.

### creating expressions

Here is a very simple expression string:

essql 'select column1, column2 from myindex' | mapColumn name=column3 fn='{ column1 + 3 }' | table


It consists of 3 functions:

- essql which runs given sql query against elasticsearch and returns the results
- `mapColumn`, which computes a new column from existing ones;
- `table`, which prepares the data for rendering in a tabular format.

The same expression could also be constructed in the code:

```ts
import { buildExpression, buildExpressionFunction } from 'src/plugins/expressions';

const expression = buildExpression([
buildExpressionFunction<ExpressionFunctionEssql>('essql', [ q: 'select column1, column2 from myindex' ]),
buildExpressionFunction<ExpressionFunctionMapColumn>('mapColumn', [ name: 'column3', expression: 'column1 + 3' ]),
buildExpressionFunction<ExpressionFunctionTable>('table'),
]
```
Note: Consumers need to be aware which plugin registers specific functions with expressions function registry and import correct type definitions from there.
<DocCallOut title="Server Side Search">
The `expressions` service is available on both server and client, with similar APIs.
</DocCallOut>
### Running expressions
Expression service exposes `execute` method which allows you to execute an expression:
```ts
const executionContract = expressions.execute(expression, input);
const result = await executionContract.getData();
```
<DocCallOut title="Server Side Search">
Check the full spec of execute function [here](https://github.com/elastic/kibana/blob/master/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.execution.md)
</DocCallOut>
In addition, on the browser side, there are two additional ways to run expressions and render the results.
#### React expression renderer component
This is the easiest way to get expressions rendered inside your application.
```ts
<ReactExpressionRenderer expression={expression} />
```
<DocCallOut title="Server Side Search">
Check the full spec of ReactExpressionRenderer component props [here](https://github.com/elastic/kibana/blob/master/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.reactexpressionrendererprops.md)
</DocCallOut>
#### Expression loader
If you are not using React, you can use the loader expression service provides to achieve the same:
```ts
const handler = loader(domElement, expression, params);
```
<DocCallOut title="Server Side Search">
Check the full spec of expression loader params [here](https://github.com/elastic/kibana/blob/master/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iexpressionloaderparams.md)
</DocCallOut>
### Creating new expression functions
Creating a new expression function is easy, just call `registerFunction` method on expressions service setup contract with your function definition:
```ts
const functionDefinition = {
name: 'clog',
args: {},
help: 'Outputs the context to the console',
fn: (input: unknown) => {
// eslint-disable-next-line no-console
console.log(input);
return input;
},
};

expressions.registerFunction(functionDefinition);
```
<DocCallOut title="Server Side Search">
Check the full interface of ExpressionFuntionDefinition [here](https://github.com/elastic/kibana/blob/master/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md)
</DocCallOut>
### Creating new expression renderers
Adding new renderers is just as easy as adding functions:
```ts
const rendererDefinition = {
name: 'debug',
help: 'Outputs the context to the dom element',
render: (domElement, input, handlers) => {
// eslint-disable-next-line no-console
domElement.innerText = JSON.strinfigy(input);
handlers.done();
},
};

expressions.registerRenderer(rendererDefinition);
```
<DocCallOut title="Server Side Search">
Check the full interface of ExpressionRendererDefinition [here](https://github.com/elastic/kibana/blob/master/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionrenderdefinition.md)
</DocCallOut>
24 changes: 21 additions & 3 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,19 @@ The 7.13.1 release includes the following bug fixes.
[float]
[[fixes-v7.13.1]]
=== Bug Fixes
Alerting::
* Adds ignore_above to alerts params mappings to handle immense params {kibana-pull}100726[#100726]
Dashboard::
* Moves the by value migrations for 7.13 {kibana-pull}100622[#100622]
* Fixes JSON editor height in Inspector on Safari {kibana-pull}99032[#99032]
Fleet::
* Adds missing install button for integrations that aren't installed yet {kibana-pull}100370[#100370]
Lens & Visualizations::
* Fixes an issue where upgrading from 7.12.1 to 7.13.0 breaks *TSVB* vizualizations with no timefield defined {kibana-pull}100864[#100864]
Machine Learning::
* Fixes field used in remote desktop protocol (RDP) anomaly detection job to event.type {kibana-pull}100000[#100000]
Management::
* Fixes large integer formatting with decimal part using numeral-js {kibana-pull}99609[#99609]
Querying & Filtering::
* Fixes bug with scripted number range filters {kibana-pull}99554[#99554]
* Using a range query in KQL against a scripted number field now works properly {kibana-pull}99554[#99554]
Sharing::
* Adds appropriate table caption for table listing generated reports {kibana-pull}100118[#100118]
Security::
Expand Down Expand Up @@ -314,12 +319,16 @@ APM::
* Color by span type when there's only one service {kibana-pull}90424[#90424]
* Break down error table api removing the sparklines {kibana-pull}89138[#89138]
Canvas::
* Fixes bug with plot sorting {kibana-pull}98084[#98084]
* Creates a Labs service for Presentation Solutions {kibana-pull}95435[#95435]
Dashboard::
* Only Apply Explicit Input On Copy To {kibana-pull}98083[#98083]
* Makes *Lens* the default editor for creating new panels {kibana-pull}96181[#96181]
* Adds shared toolbar component {kibana-pull}94139[#94139]
* Adds ability to clone drilldowns {kibana-pull}91959[#91959]
Discover::
* Do not set fieldsFromSource when not using fields API {kibana-pull}98575[#98575]
* Fixes wrong sort order with empty sort URL parameter {kibana-pull}97434[#97434]
* Adds an Options menu for switching between the two table modes {kibana-pull}97120[#97120]
* Discover: Limit document table rendering {kibana-pull}96765[#96765]
* Adds runtime field editor to Discover {kibana-pull}96762[#96762]
Expand Down Expand Up @@ -360,6 +369,8 @@ Logs::
* Adds error.stack_trace to the default log formatter {kibana-pull}94906[#94906]
* Support Kibana index patterns in the Logs app settings {kibana-pull}94849[#94849]
Machine Learning::
* Fixes pagination and sorting on trained models list page {kibana-pull}99061[#99061]
* Data Frame Analytics results: ensure model evaluation stats are shown {kibana-pull}97486[#97486]
* UI enhancements for anomaly detection rule type {kibana-pull}97626[#97626]
* Persist apply time range switch setting in anomaly detection job selector flyout {kibana-pull}97407[#97407]
* Anomaly detection rule lookback interval improvements {kibana-pull}97370[#97370]
Expand All @@ -380,6 +391,12 @@ Machine Learning::
* Rename advanced setting ml:fileDataVisualizerMaxFileSize to fileUpload:maxFileSize and increase max geojson upload size to 1GB {kibana-pull}92620[#92620]
* Use indices options in anomaly detection job wizards {kibana-pull}91830[#91830]
Management::
* Fixes search sessions docs link {kibana-pull}98918[#98918]
* Fixes display of expired session state in management {kibana-pull}98915[#98915]
* Transforms/Data Frame Analytics: Fix freezing wizard for indices with massive amounts of fields {kibana-pull}98259[#98259]
* Fixes handling of switching modes & handling of non JSON data {kibana-pull}97983[#97983]
* Fixes copy as cURL {kibana-pull}97968[#97968]
* Fixes field filtering {kibana-pull}97189[#97189]
* Fixes runtime mapping texts to runtime fields, add transform switch modal {kibana-pull}97008[#97008]
* Support max primary shard size rollover field {kibana-pull}96545[#96545]
* Move other bucket into Search Source {kibana-pull}96384[#96384]
Expand Down Expand Up @@ -426,6 +443,7 @@ Platform::
Reporting::
* Re-write CSV Export using SearchSource {kibana-pull}88303[#88303]
Security::
* Forbid setting the Location and Refresh custom response headers {kibana-pull}98129[#98129]
* Adds config properties for HTTP security headers {kibana-pull}97158[#97158]
* Added ability to create API keys {kibana-pull}92610[#92610]
* Expose session invalidation API {kibana-pull}92376[#92376]
Expand Down
13 changes: 11 additions & 2 deletions docs/developer/getting-started/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ In order to support Windows development we currently require you to use one of t

As well as installing https://www.microsoft.com/en-us/download/details.aspx?id=48145[Visual C++ Redistributable for Visual Studio 2015].

In addition we also require you to do the following:

- Install https://www.microsoft.com/en-us/download/details.aspx?id=48145[Visual C++ Redistributable for Visual Studio 2015]
- Enable the https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development[Windows Developer Mode]
- Enable https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-8dot3name[8.3 filename support] by running the following command in a windows command prompt with admin rights `fsutil 8dot3name set 0`

Before running the steps listed below, please make sure you have installed everything
that we require and listed above and that you are running the mentioned commands
through Git bash or WSL.
that we require and listed above and that you are running all the commands from now on through Git bash or WSL.

[discrete]
[[get-kibana-code]]
Expand Down Expand Up @@ -92,6 +97,10 @@ may need to run:
yarn kbn clean
----

NOTE: Running this command is only necessary in rare circumstance where you need to recover
a consistent state when problems arise. If you need to run this command often, complete
this form to provide feedback: https://ela.st/yarn-kbn-clean

If you have failures during `yarn kbn bootstrap` you may have some
corrupted packages in your yarn cache which you can clean with:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ correctiveActions: {
[key: string]: any;
};
};
manualSteps?: string[];
manualSteps: string[];
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DeprecationsDetails

| Property | Type | Description |
| --- | --- | --- |
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' &#124; 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> };</code><br/><code> manualSteps?: string[];</code><br/><code> }</code> | |
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' &#124; 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> };</code><br/><code> manualSteps: string[];</code><br/><code> }</code> | |
| [deprecationType](./kibana-plugin-core-server.deprecationsdetails.deprecationtype.md) | <code>'config' &#124; 'feature'</code> | (optional) Used to identify between different deprecation types. Example use case: in Upgrade Assistant, we may want to allow the user to sort by deprecation type or show each type in a separate tab.<!-- -->Feel free to add new types if necessary. Predefined types are necessary to reduce having similar definitions with different keywords across kibana deprecations. |
| [documentationUrl](./kibana-plugin-core-server.deprecationsdetails.documentationurl.md) | <code>string</code> | |
| [level](./kibana-plugin-core-server.deprecationsdetails.level.md) | <code>'warning' &#124; 'critical' &#124; 'fetch_error'</code> | levels: - warning: will not break deployment upon upgrade - critical: needs to be addressed before upgrade. - fetch\_error: Deprecations service failed to grab the deprecation details for the domain. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfig](./kibana-plugin-plugins-data-public.aggconfig.md) &gt; [getTimeShift](./kibana-plugin-plugins-data-public.aggconfig.gettimeshift.md)

## AggConfig.getTimeShift() method

<b>Signature:</b>

```typescript
getTimeShift(): undefined | moment.Duration;
```
<b>Returns:</b>

`undefined | moment.Duration`

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfig](./kibana-plugin-plugins-data-public.aggconfig.md) &gt; [hasTimeShift](./kibana-plugin-plugins-data-public.aggconfig.hastimeshift.md)

## AggConfig.hasTimeShift() method

<b>Signature:</b>

```typescript
hasTimeShift(): boolean;
```
<b>Returns:</b>

`boolean`

Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ export declare class AggConfig
| [getRequestAggs()](./kibana-plugin-plugins-data-public.aggconfig.getrequestaggs.md) | | |
| [getResponseAggs()](./kibana-plugin-plugins-data-public.aggconfig.getresponseaggs.md) | | |
| [getTimeRange()](./kibana-plugin-plugins-data-public.aggconfig.gettimerange.md) | | |
| [getTimeShift()](./kibana-plugin-plugins-data-public.aggconfig.gettimeshift.md) | | |
| [getValue(bucket)](./kibana-plugin-plugins-data-public.aggconfig.getvalue.md) | | |
| [getValueBucketPath()](./kibana-plugin-plugins-data-public.aggconfig.getvaluebucketpath.md) | | Returns the bucket path containing the main value the agg will produce (e.g. for sum of bytes it will point to the sum, for median it will point to the 50 percentile in the percentile multi value bucket) |
| [hasTimeShift()](./kibana-plugin-plugins-data-public.aggconfig.hastimeshift.md) | | |
| [isFilterable()](./kibana-plugin-plugins-data-public.aggconfig.isfilterable.md) | | |
| [makeLabel(percentageMode)](./kibana-plugin-plugins-data-public.aggconfig.makelabel.md) | | |
| [nextId(list)](./kibana-plugin-plugins-data-public.aggconfig.nextid.md) | <code>static</code> | Calculate the next id based on the ids in this list {<!-- -->array<!-- -->} list - a list of objects with id properties |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfigs](./kibana-plugin-plugins-data-public.aggconfigs.md) &gt; [forceNow](./kibana-plugin-plugins-data-public.aggconfigs.forcenow.md)

## AggConfigs.forceNow property

<b>Signature:</b>

```typescript
forceNow?: Date;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfigs](./kibana-plugin-plugins-data-public.aggconfigs.md) &gt; [getSearchSourceTimeFilter](./kibana-plugin-plugins-data-public.aggconfigs.getsearchsourcetimefilter.md)

## AggConfigs.getSearchSourceTimeFilter() method

<b>Signature:</b>

```typescript
getSearchSourceTimeFilter(forceNow?: Date): RangeFilter[] | {
meta: {
index: string | undefined;
params: {};
alias: string;
disabled: boolean;
negate: boolean;
};
query: {
bool: {
should: {
bool: {
filter: {
range: {
[x: string]: {
gte: string;
lte: string;
};
};
}[];
};
}[];
minimum_should_match: number;
};
};
}[];
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| forceNow | <code>Date</code> | |

<b>Returns:</b>

`RangeFilter[] | {
meta: {
index: string | undefined;
params: {};
alias: string;
disabled: boolean;
negate: boolean;
};
query: {
bool: {
should: {
bool: {
filter: {
range: {
[x: string]: {
gte: string;
lte: string;
};
};
}[];
};
}[];
minimum_should_match: number;
};
};
}[]`

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfigs](./kibana-plugin-plugins-data-public.aggconfigs.md) &gt; [getTimeShiftInterval](./kibana-plugin-plugins-data-public.aggconfigs.gettimeshiftinterval.md)

## AggConfigs.getTimeShiftInterval() method

<b>Signature:</b>

```typescript
getTimeShiftInterval(): moment.Duration | undefined;
```
<b>Returns:</b>

`moment.Duration | undefined`

Loading

0 comments on commit e9b1562

Please sign in to comment.