Skip to content

Commit

Permalink
Merge branch 'master' into task/canary-advanced-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 1, 2021
2 parents b037ff0 + 77f0a2a commit 17fe926
Show file tree
Hide file tree
Showing 310 changed files with 6,489 additions and 2,441 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"console": "src/plugins/console",
"core": "src/core",
"discover": "src/plugins/discover",
"bfetch": "src/plugins/bfetch",
"dashboard": "src/plugins/dashboard",
"data": "src/plugins/data",
"embeddableApi": "src/plugins/embeddable",
Expand Down
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>
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-core-server](./kibana-plugin-core-server.md) &gt; [DeprecationsDetails](./kibana-plugin-core-server.deprecationsdetails.md) &gt; [deprecationType](./kibana-plugin-core-server.deprecationsdetails.deprecationtype.md)

## DeprecationsDetails.deprecationType property

(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.

<b>Signature:</b>

```typescript
deprecationType?: 'config' | 'feature';
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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> | |
| [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. |
| [message](./kibana-plugin-core-server.deprecationsdetails.message.md) | <code>string</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.addScriptedField() method

> Warning: This API is now obsolete.
>
>
Add scripted field to field list

<b>Signature:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.getNonScriptedFields() method

> Warning: This API is now obsolete.
>
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.getScriptedFields() method

> Warning: This API is now obsolete.
>
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.removeScriptedField() method

> Warning: This API is now obsolete.
>
>
Remove scripted field from field list

<b>Signature:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.addScriptedField() method

> Warning: This API is now obsolete.
>
>
Add scripted field to field list

<b>Signature:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.getNonScriptedFields() method

> Warning: This API is now obsolete.
>
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.getScriptedFields() method

> Warning: This API is now obsolete.
>
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## IndexPattern.removeScriptedField() method

> Warning: This API is now obsolete.
>
>
Remove scripted field from field list

<b>Signature:</b>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions docs/user/dashboard/lens.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ A subset of *Lens* visualizations support value labels.
[role="screenshot"]
image::images/lens_value_labels_xychart_toggle.png[Lens Bar chart value labels menu]

NOTE: In bar charts, you are unable to move the label positions.

* *Pie*, *Donut*, and *Treemap*
+
[role="screenshot"]
Expand Down Expand Up @@ -243,6 +245,9 @@ refer to <<explore-fields-in-your-data,Explore the fields in your data>>.

Sorting dimensions in visualizations is unsupported in *Lens*.

You can sort the dimensions for a single column in data tables: click the column header, then select the sorting criteria you want to use.
If you use the dimension as `Columns`, then all the columns that belong to the same dimension are sorted in the table.

[float]
[[is-it-possible-to-use-saved-serches-in-lens]]
===== How do I visualize saved searches?
Expand All @@ -254,3 +259,47 @@ Visualizing saved searches in unsupported in *Lens*.
===== How do I change the number of suggestions?

Configuring the *Suggestions* that *Lens* automatically populates is unsupported.

[float]
[[is-it-possible-to-use-different-indexpatterns-in-lens]]
===== Can I visualize multiple index patterns in a single visualization?

You can create *Bar*, *Line* and *Area* charts from multiple index patterns.

Each *Layer* in a visualization is associated with an index pattern and mutiple *Layers* can be combined together within the same visualization. Each *Layer* also has a chart switcher button in order to select the best type of visualization for the specific dataset.
You can also change the index pattern for a single *Layer*.

[float]
[[why-my-field-x-is-missing-from-the-fields-list]]
===== Why is my field X missing from the fields list?

*Lens* does not support the visualization of full-text fields, therefore it is not showing them in the data summary.

[float]
[[how-to-handle-gaps-in-time-series-visualizations]]
===== How do I handle gaps in time series visualizations?

*Lens* provides a set of features to handle missing values for *Area* and *Line* charts, which is useful for sparse data in time series data.

To select a different way to represent missing values, open the *Visual options* menu, then select how to handle missing values. The default is to hide the missing values.
+
[role="screenshot"]
image::images/lens_missing_values_strategy.png[Lens Missing values strategies menu]

[float]
[[is-it-possible-to-change-the-scale-of-Y-axis]]
===== Is it possible to statically define the scale of the y-axis in a visualization?

The ability to start the y-axis from another value than 0, or use a logarithmic scale, is unsupported in *Lens*.

[float]
[[is-it-possible-to-have-pagination-for-datatable]]
===== Is it possible to have pagination in a data table?

Pagination in a data table is unsupported in *Lens*. However, the <<types-of-visualizations,aggregation-based data table>> supports pagination.

[float]
[[is-it-possible-to-have-more-than-one-Y-axis-scale]]
===== Is it possible to have more than one y-axis scale in visualizations?

*Lens* lets you pick, for each Y dimension, up to two distinct axis: *left* and *right*. Each axis can have a different scale.
58 changes: 2 additions & 56 deletions docs/user/production-considerations/production.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* <<configuring-kibana-shield>>
* <<csp-strict-mode>>
* <<enabling-ssl>>
* <<load-balancing-es>>
* <<load-balancing-kibana>>
* <<accessing-load-balanced-kibana>>
* <<high-availability>>
Expand All @@ -22,9 +21,8 @@ Kibana instances that are all connected to the same Elasticsearch instance.

While Kibana isn't terribly resource intensive, we still recommend running Kibana
separate from your Elasticsearch data or master nodes. To distribute Kibana
traffic across the nodes in your Elasticsearch cluster, you can run Kibana
and an Elasticsearch client node on the same machine. For more information, see
<<load-balancing-es, Load balancing across multiple Elasticsearch nodes>>.
traffic across the nodes in your Elasticsearch cluster,
you can configure Kibana to use a list of Elasticsearch hosts.

[float]
[[configuring-kibana-shield]]
Expand Down Expand Up @@ -69,58 +67,6 @@ csp.strict: true

See <<configuring-tls>>.

[float]
[[load-balancing-es]]
=== Load Balancing across multiple {es} nodes
If you have multiple nodes in your Elasticsearch cluster, the easiest way to distribute Kibana requests
across the nodes is to run an Elasticsearch _Coordinating only_ node on the same machine as Kibana.
Elasticsearch Coordinating only nodes are essentially smart load balancers that are part of the cluster. They
process incoming HTTP requests, redirect operations to the other nodes in the cluster as needed, and
gather and return the results. For more information, see
{ref}/modules-node.html[Node] in the Elasticsearch reference.

To use a local client node to load balance Kibana requests:

. Install Elasticsearch on the same machine as Kibana.
. Configure the node as a Coordinating only node. In `elasticsearch.yml`, set `node.data`, `node.master` and `node.ingest` to `false`:
+
[source,js]
--------
# 3. You want this node to be neither master nor data node nor ingest node, but
# to act as a "search load balancer" (fetching data from nodes,
# aggregating results, etc.)
#
node.master: false
node.data: false
node.ingest: false
--------
. Configure the client node to join your Elasticsearch cluster. In `elasticsearch.yml`, set the `cluster.name` to the
name of your cluster.
+
[source,js]
--------
cluster.name: "my_cluster"
--------
. Check your transport and HTTP host configs in `elasticsearch.yml` under `network.host` and `transport.host`. The `transport.host` needs to be on the network reachable to the cluster members, the `network.host` is the network for the HTTP connection for Kibana (localhost:9200 by default).
+
[source,js]
--------
network.host: localhost
http.port: 9200
# by default transport.host refers to network.host
transport.host: <external ip>
transport.tcp.port: 9300 - 9400
--------
. Make sure Kibana is configured to point to your local client node. In `kibana.yml`, the `elasticsearch.hosts` setting should be set to
`["localhost:9200"]`.
+
[source,js]
--------
# The Elasticsearch instance to use for all your queries.
elasticsearch.hosts: ["http://localhost:9200"]
--------

[float]
[[load-balancing-kibana]]
=== Load balancing across multiple Kibana instances
Expand Down
Loading

0 comments on commit 17fe926

Please sign in to comment.