-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable data source audit log to file (#2215)
Signed-off-by: Kristen Tian <tyarong@amazon.com> Signed-off-by: Kristen Tian <tyarong@amazon.com>
- Loading branch information
1 parent
0db1cb6
commit bda8df6
Showing
5 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { schema } from '@osd/config-schema'; | ||
// eslint-disable-next-line @osd/eslint/no-restricted-paths | ||
import { DateConversion } from '../../../src/core/server/logging/layouts/conversions'; | ||
|
||
const patternSchema = schema.string({ | ||
validate: (string) => { | ||
DateConversion.validate!(string); | ||
}, | ||
}); | ||
|
||
const patternLayout = schema.object({ | ||
highlight: schema.maybe(schema.boolean()), | ||
kind: schema.literal('pattern'), | ||
pattern: schema.maybe(patternSchema), | ||
}); | ||
|
||
const jsonLayout = schema.object({ | ||
kind: schema.literal('json'), | ||
}); | ||
|
||
export const fileAppenderSchema = schema.object( | ||
{ | ||
kind: schema.literal('file'), | ||
layout: schema.oneOf([patternLayout, jsonLayout]), | ||
path: schema.string(), | ||
}, | ||
{ | ||
defaultValue: { | ||
kind: 'file', | ||
layout: { | ||
kind: 'pattern', | ||
highlight: true, | ||
}, | ||
path: '/tmp/opensearch-dashboards-data-source-audit.log', | ||
}, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { AuditableEvent, Auditor, Logger, OpenSearchDashboardsRequest } from 'src/core/server'; | ||
|
||
export class LoggingAuditor implements Auditor { | ||
constructor( | ||
private readonly request: OpenSearchDashboardsRequest, | ||
private readonly logger: Logger | ||
) {} | ||
|
||
public withAuditScope(name: string) {} | ||
|
||
public add(event: AuditableEvent) { | ||
const message = event.message; | ||
const meta = { | ||
type: event.type, | ||
}; | ||
this.logger.info(message, meta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters