Skip to content

Commit

Permalink
Merge branch 'master' into elastic-prefix-for-eslint-config-kibana
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Aug 27, 2020
2 parents 72309c6 + ca94923 commit 5b99fd0
Show file tree
Hide file tree
Showing 100 changed files with 1,586 additions and 256 deletions.
6 changes: 2 additions & 4 deletions docs/api/using-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ For all APIs, you must use a request header. The {kib} APIs support the `kbn-xsr
By default, you must use `kbn-xsrf` for all API calls, except in the following scenarios:

* The API endpoint uses the `GET` or `HEAD` operations

* The path is whitelisted using the <<settings, `server.xsrf.whitelist`>> setting

* XSRF protections are disabled using the `server.xsrf.disableProtection` setting
* The path is whitelisted using the <<settings-xsrf-whitelist, `server.xsrf.whitelist`>> setting
* XSRF protections are disabled using the <<settings-xsrf-disableProtection, `server.xsrf.disableProtection`>> setting

`Content-Type: application/json`::
Applicable only when you send a payload in the API request. {kib} API requests and responses use JSON.
Expand Down
4 changes: 2 additions & 2 deletions docs/apm/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ users interacting with APM APIs must have <<apm-app-api-user,sufficient privileg
By default, you must use `kbn-xsrf` for all API calls, except in the following scenarios:

* The API endpoint uses the `GET` or `HEAD` operations
* The path is whitelisted using the <<settings, `server.xsrf.whitelist`>> setting
* XSRF protections are disabled using the `server.xsrf.disableProtection` setting
* The path is whitelisted using the <<settings-xsrf-whitelist, `server.xsrf.whitelist`>> setting
* XSRF protections are disabled using the <<settings-xsrf-disableProtection, `server.xsrf.disableProtection`>> setting

`Content-Type: application/json`::
Applicable only when you send a payload in the API request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Constructs a new instance of the `FieldList` class
<b>Signature:</b>

```typescript
constructor(indexPattern: IndexPattern, specs?: FieldSpec[], shortDotsEnable?: boolean, onNotification?: () => void);
constructor(indexPattern: IndexPattern, specs?: FieldSpec[], shortDotsEnable?: boolean, onNotification?: OnNotification);
```

## Parameters
Expand All @@ -19,5 +19,5 @@ constructor(indexPattern: IndexPattern, specs?: FieldSpec[], shortDotsEnable?: b
| indexPattern | <code>IndexPattern</code> | |
| specs | <code>FieldSpec[]</code> | |
| shortDotsEnable | <code>boolean</code> | |
| onNotification | <code>() =&gt; void</code> | |
| onNotification | <code>OnNotification</code> | |

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; [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) &gt; [intervalName](./kibana-plugin-plugins-data-public.indexpattern.intervalname.md)

## IndexPattern.intervalName property

<b>Signature:</b>

```typescript
intervalName: string | undefined;
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export declare class IndexPattern implements IIndexPattern
| [formatField](./kibana-plugin-plugins-data-public.indexpattern.formatfield.md) | | <code>any</code> | |
| [formatHit](./kibana-plugin-plugins-data-public.indexpattern.formathit.md) | | <code>any</code> | |
| [id](./kibana-plugin-plugins-data-public.indexpattern.id.md) | | <code>string</code> | |
| [intervalName](./kibana-plugin-plugins-data-public.indexpattern.intervalname.md) | | <code>string &#124; undefined</code> | |
| [metaFields](./kibana-plugin-plugins-data-public.indexpattern.metafields.md) | | <code>string[]</code> | |
| [sourceFilters](./kibana-plugin-plugins-data-public.indexpattern.sourcefilters.md) | | <code>SourceFilter[]</code> | |
| [timeFieldName](./kibana-plugin-plugins-data-public.indexpattern.timefieldname.md) | | <code>string &#124; undefined</code> | |
| [title](./kibana-plugin-plugins-data-public.indexpattern.title.md) | | <code>string</code> | |
| [type](./kibana-plugin-plugins-data-public.indexpattern.type.md) | | <code>string &#124; undefined</code> | |
| [typeMeta](./kibana-plugin-plugins-data-public.indexpattern.typemeta.md) | | <code>TypeMeta</code> | |
## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@

```typescript
prepBody(): {
[key: string]: any;
title: string;
timeFieldName: string | undefined;
intervalName: string | undefined;
sourceFilters: string | undefined;
fields: string | undefined;
fieldFormatMap: string | undefined;
type: string | undefined;
typeMeta: string | undefined;
};
```
<b>Returns:</b>

`{
[key: string]: any;
title: string;
timeFieldName: string | undefined;
intervalName: string | undefined;
sourceFilters: string | undefined;
fields: string | undefined;
fieldFormatMap: string | undefined;
type: string | undefined;
typeMeta: string | undefined;
}`

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; [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) &gt; [sourceFilters](./kibana-plugin-plugins-data-public.indexpattern.sourcefilters.md)

## IndexPattern.sourceFilters property

<b>Signature:</b>

```typescript
sourceFilters?: SourceFilter[];
```
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; [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) &gt; [type](./kibana-plugin-plugins-data-public.indexpattern.type.md)

## IndexPattern.type property

<b>Signature:</b>

```typescript
type: string | undefined;
```
43 changes: 24 additions & 19 deletions docs/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<titleabbrev>Monitoring settings</titleabbrev>
++++

By default, the Monitoring application is enabled, but data collection
is disabled. When you first start {kib} monitoring, you are prompted to
enable data collection. If you are using {stack-security-features}, you must be
signed in as a user with the `cluster:manage` privilege to enable
data collection. The built-in `superuser` role has this privilege and the
built-in `elastic` user has this role.
By default, *{stack-monitor-app}* is enabled, but data collection is disabled.
When you first start {kib} monitoring, you are prompted to enable data
collection. If you are using {stack-security-features}, you must be signed in as
a user with the `cluster:manage` privilege to enable data collection. The
built-in `superuser` role has this privilege and the built-in `elastic` user has
this role.

You can adjust how monitoring data is
collected from {kib} and displayed in {kib} by configuring settings in the
Expand Down Expand Up @@ -49,7 +49,7 @@ For more information, see
in {kib} to the {es} monitoring cluster and to verify licensing status on the {es}
monitoring cluster. +
+
Every other request performed by the Stack Monitoring UI to the monitoring {es}
Every other request performed by *{stack-monitor-app}* to the monitoring {es}
cluster uses the authenticated user's credentials, which must be the same on
both the {es} monitoring cluster and the {es} production cluster. +
+
Expand All @@ -60,7 +60,7 @@ For more information, see
in {kib} to the {es} monitoring cluster and to verify licensing status on the {es}
monitoring cluster. +
+
Every other request performed by the Stack Monitoring UI to the monitoring {es}
Every other request performed by *{stack-monitor-app}* to the monitoring {es}
cluster uses the authenticated user's credentials, which must be the same on
both the {es} monitoring cluster and the {es} production cluster. +
+
Expand All @@ -83,7 +83,7 @@ These settings control how data is collected from {kib}.
|===
| `monitoring.kibana.collection.enabled`
| Set to `true` (default) to enable data collection from the {kib} NodeJS server
for {kib} Dashboards to be featured in the Monitoring.
for {kib} dashboards to be featured in *{stack-monitor-app}*.

| `monitoring.kibana.collection.interval`
| Specifies the number of milliseconds to wait in between data sampling on the
Expand All @@ -96,16 +96,26 @@ These settings control how data is collected from {kib}.
[[monitoring-ui-settings]]
==== Monitoring UI settings

These settings adjust how the {kib} Monitoring page displays monitoring data.
These settings adjust how *{stack-monitor-app}* displays monitoring data.
However, the defaults work best in most circumstances. For more information
about configuring {kib}, see
{kibana-ref}/settings.html[Setting Kibana Server Properties].
{kibana-ref}/settings.html[Setting {kib} server properties].

[cols="2*<"]
|===
| `monitoring.ui.elasticsearch.logFetchCount`
| Specifies the number of log entries to display in the Monitoring UI. Defaults to
`10`. The maximum value is `50`.
| Specifies the number of log entries to display in *{stack-monitor-app}*.
Defaults to `10`. The maximum value is `50`.

| `monitoring.ui.enabled`
| Set to `false` to hide *{stack-monitor-app}*. The monitoring back-end
continues to run as an agent for sending {kib} stats to the monitoring
cluster. Defaults to `true`.

| `monitoring.ui.logs.index`
| Specifies the name of the indices that are shown on the
<<logs-monitor-page,*Logs*>> page in *{stack-monitor-app}*. The default value
is `filebeat-*`.

| `monitoring.ui.max_bucket_size`
| Specifies the number of term buckets to return out of the overall terms list when
Expand All @@ -120,18 +130,13 @@ about configuring {kib}, see
`monitoring.ui.collection.interval` in `elasticsearch.yml`, use the same
value in this setting.

| `monitoring.ui.enabled`
| Set to `false` to hide the Monitoring UI in {kib}. The monitoring back-end
continues to run as an agent for sending {kib} stats to the monitoring
cluster. Defaults to `true`.

|===

[float]
[[monitoring-ui-cgroup-settings]]
===== Monitoring UI container settings

The Monitoring UI exposes the Cgroup statistics that we collect for you to make
*{stack-monitor-app}* exposes the Cgroup statistics that we collect for you to make
better decisions about your container performance, rather than guessing based on
the overall machine performance. If you are not running your applications in a
container, then Cgroup statistics are not useful.
Expand Down
5 changes: 4 additions & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ all http requests to https over the port configured as `server.port`.
| An array of supported protocols with versions.
Valid protocols: `TLSv1`, `TLSv1.1`, `TLSv1.2`. *Default: TLSv1.1, TLSv1.2*

| `server.xsrf.whitelist:`
| [[settings-xsrf-whitelist]] `server.xsrf.whitelist:`
| It is not recommended to disable protections for
arbitrary API endpoints. Instead, supply the `kbn-xsrf` header.
The `server.xsrf.whitelist` setting requires the following format:
Expand All @@ -592,6 +592,9 @@ The `server.xsrf.whitelist` setting requires the following format:
[cols="2*<"]
|===

| [[settings-xsrf-disableProtection]] `server.xsrf.disableProtection:`
| Setting this to `true` will completely disable Cross-site request forgery protection in Kibana. This is not recommended. *Default: `false`*

| `status.allowAnonymous:`
| If authentication is enabled,
setting this to `true` enables unauthenticated users to access the {kib}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
);

merge(extraCliOptions);
merge(readKeystore(get('path.data')));
merge(readKeystore());

return rawConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class FieldList extends Array<IndexPatternField> implements IIndexPattern
indexPattern: IndexPattern,
specs: FieldSpec[] = [],
shortDotsEnable = false,
onNotification = () => {}
onNotification: OnNotification = () => {}
) {
super();
this.indexPattern = indexPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@ jest.mock('../../field_mapping', () => {
id: true,
title: true,
fieldFormatMap: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => []),
},
fields: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation((fields) => fields),
},
sourceFilters: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => undefined),
},
typeMeta: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => undefined),
},
})),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ interface IndexPatternDeps {
}

export class IndexPattern implements IIndexPattern {
[key: string]: any;

public id?: string;
public title: string = '';
public fieldFormatMap: any;
public typeMeta?: TypeMeta;
public fields: IIndexPatternFieldList & { toSpec: () => FieldSpec[] };
public timeFieldName: string | undefined;
public intervalName: string | undefined;
public type: string | undefined;
public formatHit: any;
public formatField: any;
public flattenHit: any;
Expand All @@ -72,7 +72,7 @@ export class IndexPattern implements IIndexPattern {
private version: string | undefined;
private savedObjectsClient: SavedObjectsClientCommon;
private patternCache: PatternCache;
private sourceFilters?: SourceFilter[];
public sourceFilters?: SourceFilter[];
private originalBody: { [key: string]: any } = {};
public fieldsFetcher: any; // probably want to factor out any direct usage and change to private
private shortDotsEnable: boolean = false;
Expand Down Expand Up @@ -126,7 +126,7 @@ export class IndexPattern implements IIndexPattern {
this.shortDotsEnable = shortDotsEnable;
this.metaFields = metaFields;

this.fields = new FieldList(this, [], this.shortDotsEnable, this.onUnknownType);
this.fields = new FieldList(this, [], this.shortDotsEnable, this.onNotification);

this.apiClient = apiClient;
this.fieldsFetcher = createFieldsFetcher(this, apiClient, metaFields);
Expand Down Expand Up @@ -226,10 +226,13 @@ export class IndexPattern implements IIndexPattern {
response[name] = fieldMapping._deserialize(response[name]);
});

// give index pattern all of the values
const fieldList = this.fields;
_.assign(this, response);
this.fields = fieldList;
this.title = response.title;
this.timeFieldName = response.timeFieldName;
this.intervalName = response.intervalName;
this.sourceFilters = response.sourceFilters;
this.fieldFormatMap = response.fieldFormatMap;
this.type = response.type;
this.typeMeta = response.typeMeta;

if (!this.title && this.id) {
this.title = this.id;
Expand Down Expand Up @@ -430,18 +433,16 @@ export class IndexPattern implements IIndexPattern {
}

prepBody() {
const body: { [key: string]: any } = {};

// serialize json fields
_.forOwn(this.mapping, (fieldMapping, fieldName) => {
if (!fieldName || this[fieldName] == null) return;

body[fieldName] = fieldMapping._serialize
? fieldMapping._serialize(this[fieldName])
: this[fieldName];
});

return body;
return {
title: this.title,
timeFieldName: this.timeFieldName,
intervalName: this.intervalName,
sourceFilters: this.mapping.sourceFilters._serialize!(this.sourceFilters),
fields: this.mapping.fields._serialize!(this.fields),
fieldFormatMap: this.mapping.fieldFormatMap._serialize!(this.fieldFormatMap),
type: this.type,
typeMeta: this.mapping.typeMeta._serialize!(this.mapping),
};
}

getFormatterForField(field: IndexPatternField | IndexPatternField['spec']): FieldFormat {
Expand Down Expand Up @@ -485,10 +486,14 @@ export class IndexPattern implements IIndexPattern {
async save(saveAttempts: number = 0): Promise<void | Error> {
if (!this.id) return;
const body = this.prepBody();
// What keys changed since they last pulled the index pattern
const originalChangedKeys = Object.keys(body).filter(
(key) => body[key] !== this.originalBody[key]
);

const originalChangedKeys: string[] = [];
Object.entries(body).forEach(([key, value]) => {
if (value !== this.originalBody[key]) {
originalChangedKeys.push(key);
}
});

return this.savedObjectsClient
.update(savedObjectType, this.id, body, { version: this.version })
.then((resp) => {
Expand Down Expand Up @@ -519,8 +524,12 @@ export class IndexPattern implements IIndexPattern {
// and ensure we ignore the key if the server response
// is the same as the original response (since that is expected
// if we made a change in that key)
const serverChangedKeys = Object.keys(updatedBody).filter((key) => {
return updatedBody[key] !== body[key] && this.originalBody[key] !== updatedBody[key];

const serverChangedKeys: string[] = [];
Object.entries(updatedBody).forEach(([key, value]) => {
if (value !== (body as any)[key] && value !== this.originalBody[key]) {
serverChangedKeys.push(key);
}
});

let unresolvedCollision = false;
Expand All @@ -545,7 +554,7 @@ export class IndexPattern implements IIndexPattern {

// Set the updated response on this object
serverChangedKeys.forEach((key) => {
this[key] = samePattern[key];
(this as any)[key] = (samePattern as any)[key];
});
this.version = samePattern.version;

Expand Down
Loading

0 comments on commit 5b99fd0

Please sign in to comment.