Skip to content

Commit

Permalink
Merge branch 'master' into migrate-configs
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 14, 2020
2 parents e7c3e13 + 302c598 commit 86bf35b
Show file tree
Hide file tree
Showing 476 changed files with 9,330 additions and 4,842 deletions.
20 changes: 10 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
'kibana-intake-agent': kibanaPipeline.intakeWorker('kibana-intake', './test/scripts/jenkins_unit.sh'),
'x-pack-intake-agent': kibanaPipeline.intakeWorker('x-pack-intake', './test/scripts/jenkins_xpack.sh'),
'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [
'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', {
retryable('kibana-firefoxSmoke') {
runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke')
}
}),
// 'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', {
// retryable('kibana-firefoxSmoke') {
// runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke')
// }
// }),
'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1),
'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2),
'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3),
Expand All @@ -39,11 +39,11 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
// 'oss-visualRegression': kibanaPipeline.getPostBuildWorker('visualRegression', { runbld('./test/scripts/jenkins_visual_regression.sh', 'Execute kibana-visualRegression') }),
]),
'kibana-xpack-agent': kibanaPipeline.withWorkers('kibana-xpack-tests', { kibanaPipeline.buildXpack() }, [
'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', {
retryable('xpack-firefoxSmoke') {
runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke')
}
}),
// 'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', {
// retryable('xpack-firefoxSmoke') {
// runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke')
// }
// }),
'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1),
'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2),
'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IHttpFetchError extends Error
| Property | Type | Description |
| --- | --- | --- |
| [body](./kibana-plugin-public.ihttpfetcherror.body.md) | <code>any</code> | |
| [name](./kibana-plugin-public.ihttpfetcherror.name.md) | <code>string</code> | |
| [req](./kibana-plugin-public.ihttpfetcherror.req.md) | <code>Request</code> | |
| [request](./kibana-plugin-public.ihttpfetcherror.request.md) | <code>Request</code> | |
| [res](./kibana-plugin-public.ihttpfetcherror.res.md) | <code>Response</code> | |
Expand Down
Binary file modified docs/infrastructure/images/infra-sysmon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/infrastructure/images/infra-view-metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/infrastructure/images/metrics-add-data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/infrastructure/images/metrics-explorer-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logs/images/log-rate-anomalies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logs/images/log-rate-entries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logs/images/log-time-filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logs/images/logs-add-data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logs/images/logs-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/logs/using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ You can also view related application traces or uptime information where availab

[role="screenshot"]
image::logs/images/logs-console.png[Logs Console in Kibana]
// ++ Update this

[float]
[[logs-search]]
Expand Down
6 changes: 5 additions & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- [On the server side](#on-the-server-side)
- [On the client side](#on-the-client-side)
- [Updates an application navlink at runtime](#updates-an-app-navlink-at-runtime)
- [Logging config migration](#logging-config-migration)

Make no mistake, it is going to take a lot of work to move certain plugins to the new platform. Our target is to migrate the entire repo over to the new platform throughout 7.x and to remove the legacy plugin system no later than 8.0, and this is only possible if teams start on the effort now.

Expand Down Expand Up @@ -1655,4 +1656,7 @@ export class MyPlugin implements Plugin {
tooltip: 'Application disabled',
})
}
```
```

### Logging config migration
[Read](./server/logging/README.md#logging-config-migration)
5 changes: 0 additions & 5 deletions src/core/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ This document outlines best practices and patterns for testing Kibana Plugins.
- [Testing dependencies usages](#testing-dependencies-usages)
- [Testing components consuming the dependencies](#testing-components-consuming-the-dependencies)
- [Testing optional plugin dependencies](#testing-optional-plugin-dependencies)
- [Plugin Contracts](#plugin-contracts)

## Strategy

Expand Down Expand Up @@ -1082,7 +1081,3 @@ describe('Plugin', () => {
});
});
```
## Plugin Contracts
_How to test your plugin's exposed API_
42 changes: 37 additions & 5 deletions src/core/public/http/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Fetch', () => {
});
afterEach(() => {
fetchMock.restore();
fetchInstance.removeAllInterceptors();
});

describe('http requests', () => {
Expand Down Expand Up @@ -287,6 +288,42 @@ describe('Fetch', () => {
});
});

it('preserves the name of the original error', async () => {
expect.assertions(1);

const abortError = new DOMException('The operation was aborted.', 'AbortError');

fetchMock.get('*', Promise.reject(abortError));

await fetchInstance.fetch('/my/path').catch(e => {
expect(e.name).toEqual('AbortError');
});
});

it('exposes the request to the interceptors in case of aborted request', async () => {
const responseErrorSpy = jest.fn();
const abortError = new DOMException('The operation was aborted.', 'AbortError');

fetchMock.get('*', Promise.reject(abortError));

fetchInstance.intercept({
responseError: responseErrorSpy,
});

await expect(fetchInstance.fetch('/my/path')).rejects.toThrow();

expect(responseErrorSpy).toHaveBeenCalledTimes(1);
const interceptedResponse = responseErrorSpy.mock.calls[0][0];

expect(interceptedResponse.request).toEqual(
expect.objectContaining({
method: 'GET',
url: 'http://localhost/myBase/my/path',
})
);
expect(interceptedResponse.error.name).toEqual('AbortError');
});

it('should support get() helper', async () => {
fetchMock.get('*', {});
await fetchInstance.get('/my/path', { method: 'POST' });
Expand Down Expand Up @@ -368,11 +405,6 @@ describe('Fetch', () => {
fetchMock.get('*', { foo: 'bar' });
});

afterEach(() => {
fetchMock.restore();
fetchInstance.removeAllInterceptors();
});

it('should make request and receive response', async () => {
fetchInstance.intercept({});

Expand Down
10 changes: 3 additions & 7 deletions src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ export class Fetch {
try {
response = await window.fetch(request);
} catch (err) {
if (err.name === 'AbortError') {
throw err;
} else {
throw new HttpFetchError(err.message, request);
}
throw new HttpFetchError(err.message, err.name ?? 'Error', request);
}

const contentType = response.headers.get('Content-Type') || '';
Expand All @@ -170,11 +166,11 @@ export class Fetch {
}
}
} catch (err) {
throw new HttpFetchError(err.message, request, response, body);
throw new HttpFetchError(err.message, err.name ?? 'Error', request, response, body);
}

if (!response.ok) {
throw new HttpFetchError(response.statusText, request, response, body);
throw new HttpFetchError(response.statusText, 'Error', request, response, body);
}

return { fetchOptions, request, response, body };
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/http/http_fetch_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ import { IHttpFetchError } from './types';

/** @internal */
export class HttpFetchError extends Error implements IHttpFetchError {
public readonly name: string;
public readonly req: Request;
public readonly res?: Response;

constructor(
message: string,
name: string,
public readonly request: Request,
public readonly response?: Response,
public readonly body?: any
) {
super(message);
this.name = name;
this.req = request;
this.res = response;

Expand Down
1 change: 1 addition & 0 deletions src/core/public/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export interface IHttpResponseInterceptorOverrides<TResponseBody = any> {

/** @public */
export interface IHttpFetchError extends Error {
readonly name: string;
readonly request: Request;
readonly response?: Response;
/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ export type IContextProvider<THandler extends HandlerFunction<any>, TContextName
export interface IHttpFetchError extends Error {
// (undocumented)
readonly body?: any;
// (undocumented)
readonly name: string;
// @deprecated (undocumented)
readonly req: Request;
// (undocumented)
Expand Down
148 changes: 145 additions & 3 deletions src/core/server/logging/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Logging
- [Loggers, Appenders and Layouts](#loggers-appenders-and-layouts)
- [Logger hierarchy](#logger-hierarchy)
- [Log level](#log-level)
- [Layouts](#layouts)
- [Pattern layout](#pattern-layout)
- [JSON layout](#json-layout)
- [Configuration](#configuration)
- [Usage](#usage)

The way logging works in Kibana is inspired by `log4j 2` logging framework used by [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#logging).
The main idea is to have consistent logging behaviour (configuration, log format etc.) across the entire Elastic Stack
Expand Down Expand Up @@ -52,12 +60,68 @@ custom appenders, so one should always make the choice explicitly.

There are two types of layout supported at the moment: `pattern` and `json`.

With `pattern` layout it's possible to define a string pattern with special placeholders wrapped into curly braces that
### Pattern layout
With `pattern` layout it's possible to define a string pattern with special placeholders `%conversion_pattern` (see the table below) that
will be replaced with data from the actual log message. By default the following pattern is used:
`[{timestamp}][{level}][{context}] {message}`. Also `highlight` option can be enabled for `pattern` layout so that
`[%date][%level][%logger]%meta %message`. Also `highlight` option can be enabled for `pattern` layout so that
some parts of the log message are highlighted with different colors that may be quite handy if log messages are forwarded
to the terminal with color support.
`pattern` layout uses a sub-set of [log4j2 pattern syntax](https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout)
and **doesn't implement** all `log4j2` capabilities. The conversions that are provided out of the box are:

#### level
Outputs the [level](#log-level) of the logging event.
Example of `%level` output:
```bash
TRACE
DEBUG
INFO
```

##### logger
Outputs the name of the logger that published the logging event.
Example of `%logger` output:
```bash
server
server.http
server.http.Kibana
```

#### message
Outputs the application supplied message associated with the logging event.

#### meta
Outputs the entries of `meta` object data in **json** format, if one is present in the event.
Example of `%meta` output:
```bash
// Meta{from: 'v7', to: 'v8'}
'{"from":"v7","to":"v8"}'
// Meta empty object
'{}'
// no Meta provided
''
```

##### date
Outputs the date of the logging event. The date conversion specifier may be followed by a set of braces containing a name of predefined date format and canonical timezone name.
Timezone name is expected to be one from [TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
Example of `%date` output:

| Conversion pattern | Example |
| ---------------------------------------- | ---------------------------------------------------------------- |
| `%date` | `2012-02-01T14:30:22.011Z` uses `ISO8601` format by default |
| `%date{ISO8601}` | `2012-02-01T14:30:22.011Z` |
| `%date{ISO8601_TZ}` | `2012-02-01T09:30:22.011-05:00` `ISO8601` with timezone |
| `%date{ISO8601_TZ}{America/Los_Angeles}` | `2012-02-01T06:30:22.011-08:00` |
| `%date{ABSOLUTE}` | `09:30:22.011` |
| `%date{ABSOLUTE}{America/Los_Angeles}` | `06:30:22.011` |
| `%date{UNIX}` | `1328106622` |
| `%date{UNIX_MILLIS}` | `1328106622011` |

#### pid
Outputs the process ID.

### JSON layout
With `json` layout log messages will be formatted as JSON strings that include timestamp, log level, context, message
text and any other metadata that may be associated with the log message itself.

Expand Down Expand Up @@ -88,7 +152,7 @@ logging:
kind: console
layout:
kind: pattern
pattern: [{timestamp}][{level}] {message}
pattern: "[%date][%level] %message"
json-file-appender:
kind: file
path: /var/log/kibana-json.log
Expand Down Expand Up @@ -179,3 +243,81 @@ The log will be less verbose with `warn` level for the `server` context:
[2017-07-25T18:54:41.639Z][ERROR][server] Message with `error` log level.
[2017-07-25T18:54:41.639Z][FATAL][server] Message with `fatal` log level.
```

### Logging config migration
Compatibility with the legacy logging system is assured until the end of the `v7` version.
All log messages handled by `root` context are forwarded to the legacy logging service. If you re-write
root appenders, make sure that it contains `default` appender to provide backward compatibility.
**Note**: If you define an appender for a context, the log messages aren't handled by the
`root` context anymore and not forwarded to the legacy logging service.

#### logging.dest
By default logs in *stdout*. With new Kibana logging you can use pre-existing `console` appender or
define a custom one.
```yaml
logging:
loggers:
- context: your-plugin
appenders: [console]
```
Logs in a *file* if given file path. You should define a custom appender with `kind: file`
```yaml
logging:
appenders:
file:
kind: file
path: /var/log/kibana.log
layout:
kind: pattern
loggers:
- context: your-plugin
appenders: [file]
```
#### logging.json
Defines the format of log output. Logs in JSON if `true`. With new logging config you can adjust
the output format with [layouts](#layouts).

#### logging.quiet
Suppresses all logging output other than error messages. With new logging, config can be achieved
with adjusting minimum required [logging level](#log-level)
```yaml
loggers:
- context: my-plugin
appenders: [console]
level: error
# or for all output
logging.root.level: error
```

#### logging.silent:
Suppresses all logging output.
```yaml
logging.root.level: off
```

#### logging.verbose:
Logs all events
```yaml
logging.root.level: all
```

#### logging.timezone
Set to the canonical timezone id to log events using that timezone. New logging config allows
to [specify timezone](#date) for `layout: pattern`.
```yaml
logging:
appenders:
custom-console:
kind: console
layout:
kind: pattern
highlight: true
pattern: "[%level] [%date{ISO8601_TZ}{America/Los_Angeles}][%logger] %message"
```

#### logging.events
Define a custom logger for a specific context.

#### logging.filter
TBD
2 changes: 1 addition & 1 deletion src/core/server/logging/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function createRoot() {
layout: {
highlight: false,
kind: 'pattern',
pattern: '{level}|{context}|{message}',
pattern: '%level|%logger|%message',
},
},
},
Expand Down
Loading

0 comments on commit 86bf35b

Please sign in to comment.