Skip to content

Commit

Permalink
Unify Kibana & Elasticsearch logging config keys (#90764)
Browse files Browse the repository at this point in the history
* align logging config with ES. rename kind to type.

* rename file "path" to "fileName"

* rename logger "context" to "name"

* update audit log docs and tests

* update docs

* fix integration tests

* update deprecations for audit appender

* add tests for audit logging deprecations

* fix eslint problem

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
mshustov and kibanamachine authored Feb 16, 2021
1 parent db6cd86 commit 312351c
Show file tree
Hide file tree
Showing 51 changed files with 468 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Customize the configuration for the plugins.data.search context.
core.logging.configure(
of({
appenders: new Map(),
loggers: [{ context: 'search', appenders: ['default'] }]
loggers: [{ name: 'search', appenders: ['default'] }]
})
)

Expand Down
22 changes: 11 additions & 11 deletions docs/settings/security-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -356,26 +356,26 @@ To enable the <<xpack-security-ecs-audit-logging, ECS audit logger>>, specify wh
[source,yaml]
----------------------------------------
xpack.security.audit.appender:
kind: rolling-file
path: ./audit.log
type: rolling-file
fileName: ./audit.log
policy:
kind: time-interval
type: time-interval
interval: 24h <1>
strategy:
kind: numeric
type: numeric
max: 10 <2>
layout:
kind: json
type: json
----------------------------------------
<1> Rotates log files every 24 hours.
<2> Keeps maximum of 10 log files before deleting older ones.

| `xpack.security.audit.appender.kind`
| `xpack.security.audit.appender.type`
| Required. Specifies where audit logs should be written to. Allowed values are `console`, `file`, or `rolling-file`.

Refer to <<audit-logging-file-appender>> and <<audit-logging-rolling-file-appender>> for appender specific settings.

| `xpack.security.audit.appender.layout.kind`
| `xpack.security.audit.appender.layout.type`
| Required. Specifies how audit logs should be formatted. Allowed values are `json` or `pattern`.

Refer to <<audit-logging-pattern-layout>> for layout specific settings.
Expand All @@ -396,7 +396,7 @@ The `file` appender writes to a file and can be configured using the following s

[cols="2*<"]
|======
| `xpack.security.audit.appender.path`
| `xpack.security.audit.appender.fileName`
| Required. Full file path the log file should be written to.
|======

Expand All @@ -408,14 +408,14 @@ The `rolling-file` appender writes to a file and rotates it using a rolling stra

[cols="2*<"]
|======
| `xpack.security.audit.appender.path`
| `xpack.security.audit.appender.fileName`
| Required. Full file path the log file should be written to.

| `xpack.security.audit.appender.policy.kind`
| `xpack.security.audit.appender.policy.type`
| Specifies when a rollover should occur. Allowed values are `size-limit` and `time-interval`. *Default:* `time-interval`.

Refer to <<audit-logging-size-limit-policy>> and <<audit-logging-time-interval-policy>> for policy specific settings.
| `xpack.security.audit.appender.strategy.kind`
| `xpack.security.audit.appender.strategy.type`
| Specifies how the rollover should occur. Only allowed value is currently `numeric`. *Default:* `numeric`

Refer to <<audit-logging-numeric-strategy>> for strategy specific settings.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class LegacyObjectToConfigAdapter extends ObjectToConfigAdapter {
const loggingConfig = {
appenders: {
...appenders,
default: { kind: 'legacy-appender', legacyLoggingConfig },
default: { type: 'legacy-appender', legacyLoggingConfig },
},
root: { level: 'info', ...root },
loggers,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/core_usage_data/core_usage_data_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class CoreUsageDataService implements CoreService<CoreUsageDataSetup, Cor
logging: {
appendersTypesUsed: Array.from(
Array.from(this.loggingConfig?.appenders.values() ?? [])
.reduce((acc, a) => acc.add(a.kind), new Set<string>())
.reduce((acc, a) => acc.add(a.type), new Set<string>())
.values()
),
loggersConfiguredCount: this.loggingConfig?.loggers.length ?? 0,
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/http/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ describe('request logging', () => {
silent: true,
appenders: {
'test-console': {
kind: 'console',
type: 'console',
layout: {
kind: 'pattern',
type: 'pattern',
pattern: '%level|%logger|%message|%meta',
},
},
},
loggers: [
{
context: 'http.server.response',
name: 'http.server.response',
appenders: ['test-console'],
level: 'debug',
},
Expand Down Expand Up @@ -96,16 +96,16 @@ describe('request logging', () => {
silent: true,
appenders: {
'test-console': {
kind: 'console',
type: 'console',
layout: {
kind: 'pattern',
type: 'pattern',
pattern: '%level|%logger|%message|%meta',
},
},
},
loggers: [
{
context: 'http.server.response',
name: 'http.server.response',
appenders: ['test-console'],
level: 'debug',
},
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/legacy/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ function createRoot(legacyLoggingConfig: LegacyLoggingConfig = {}) {
// platform config
appenders: {
'test-console': {
kind: 'console',
type: 'console',
layout: {
highlight: false,
kind: 'pattern',
type: 'pattern',
},
},
},
loggers: [
{
context: 'test-file',
name: 'test-file',
appenders: ['test-console'],
level: 'info',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ afterEach(() => (LegacyLoggingServer as any).mockClear());

test('`configSchema` creates correct schema.', () => {
const appenderSchema = LegacyAppender.configSchema;
const validConfig = { kind: 'legacy-appender', legacyLoggingConfig: { verbose: true } };
const validConfig = { type: 'legacy-appender', legacyLoggingConfig: { verbose: true } };
expect(appenderSchema.validate(validConfig)).toEqual({
kind: 'legacy-appender',
type: 'legacy-appender',
legacyLoggingConfig: { verbose: true },
});

const wrongConfig = { kind: 'not-legacy-appender' };
const wrongConfig = { type: 'not-legacy-appender' };
expect(() => appenderSchema.validate(wrongConfig)).toThrow();
});

Expand Down
4 changes: 2 additions & 2 deletions src/core/server/legacy/logging/appenders/legacy_appender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DisposableAppender, LogRecord } from '@kbn/logging';
import { LegacyVars } from '../../types';

export interface LegacyAppenderConfig {
kind: 'legacy-appender';
type: 'legacy-appender';
legacyLoggingConfig?: any;
}

Expand All @@ -22,7 +22,7 @@ export interface LegacyAppenderConfig {
*/
export class LegacyAppender implements DisposableAppender {
public static configSchema = schema.object({
kind: schema.literal('legacy-appender'),
type: schema.literal('legacy-appender'),
legacyLoggingConfig: schema.any(),
});

Expand Down
Loading

0 comments on commit 312351c

Please sign in to comment.