Skip to content

Commit 702e795

Browse files
authored
Fix ECS HTTP scheme and improve docs (#86612) (#86632)
1 parent 1aeb6ed commit 702e795

3 files changed

Lines changed: 191 additions & 20 deletions

File tree

docs/user/security/audit-logging.asciidoc

Lines changed: 188 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ For information on how to configure `xpack.security.audit.appender`, refer to
4747

4848
Refer to the table of events that can be logged for auditing purposes.
4949

50-
Each event is broken down into `category`, `type`, `action` and `outcome` fields
50+
Each event is broken down into <<field-event-category, category>>, <<field-event-type, type>>, <<field-event-action, action>> and <<field-event-outcome, outcome>> fields
5151
to make it easy to filter, query and aggregate the resulting logs.
5252

53+
Refer to <<xpack-security-ecs-audit-schema>> for a table of fields that get logged with audit event.
54+
5355
[NOTE]
5456
============================================================================
5557
To ensure that a record of every operation is persisted even in case of an
@@ -230,3 +232,188 @@ Refer to the corresponding {es} logs for potential write errors.
230232
| `http_request`
231233
| `unknown` | User is making an HTTP request.
232234
|======
235+
236+
237+
[[xpack-security-ecs-audit-schema]]
238+
==== ECS audit schema
239+
240+
Audit logs are written in JSON using https://www.elastic.co/guide/en/ecs/1.6/index.html[Elastic Common Schema (ECS)] specification.
241+
242+
[cols="2*<"]
243+
|======
244+
245+
2+a| ===== Base Fields
246+
247+
| *Field*
248+
| *Description*
249+
250+
| `@timestamp`
251+
| Time when the event was generated.
252+
253+
Example: `2016-05-23T08:05:34.853Z`
254+
255+
| `message`
256+
| Human readable description of the event.
257+
258+
2+a| ===== Event Fields
259+
260+
| *Field*
261+
| *Description*
262+
263+
| [[field-event-action]] `event.action`
264+
| The action captured by the event.
265+
266+
Refer to <<xpack-security-ecs-audit-logging>> for a table of possible actions.
267+
268+
| [[field-event-category]] `event.category`
269+
| High level category associated with the event.
270+
271+
This field is closely related to `event.type`, which is used as a subcategory.
272+
273+
Possible values:
274+
`database`,
275+
`web`,
276+
`authentication`
277+
278+
| [[field-event-type]] `event.type`
279+
| Subcategory associated with the event.
280+
281+
This field can be used along with the `event.category` field to enable filtering events down to a level appropriate for single visualization.
282+
283+
Possible values:
284+
`creation`,
285+
`access`,
286+
`change`,
287+
`deletion`
288+
289+
| [[field-event-outcome]] `event.outcome`
290+
| Denotes whether the event represents a success or failure.
291+
292+
Possible values:
293+
`success`,
294+
`failure`,
295+
`unknown`
296+
297+
2+a| ===== User Fields
298+
299+
| *Field*
300+
| *Description*
301+
302+
| `user.name`
303+
| Login name of the user.
304+
305+
Example: `jdoe`
306+
307+
| `user.roles[]`
308+
| Set of user roles at the time of the event.
309+
310+
Example: `[kibana_admin, reporting_user]`
311+
312+
2+a| ===== Kibana Fields
313+
314+
| *Field*
315+
| *Description*
316+
317+
| `kibana.space_id`
318+
| ID of the space associated with the event.
319+
320+
Example: `default`
321+
322+
| `kibana.session_id`
323+
| ID of the user session associated with the event.
324+
325+
Each login attempt results in a unique session id.
326+
327+
| `kibana.saved_object.type`
328+
| Type of saved object associated with the event.
329+
330+
Example: `dashboard`
331+
332+
| `kibana.saved_object.id`
333+
| ID of the saved object associated with the event.
334+
335+
| `kibana.authentication_provider`
336+
| Name of the authentication provider associated with the event.
337+
338+
Example: `my-saml-provider`
339+
340+
| `kibana.authentication_type`
341+
| Type of the authentication provider associated with the event.
342+
343+
Example: `saml`
344+
345+
| `kibana.authentication_realm`
346+
| Name of the Elasticsearch realm that has authenticated the user.
347+
348+
Example: `native`
349+
350+
| `kibana.lookup_realm`
351+
| Name of the Elasticsearch realm where the user details were retrieved from.
352+
353+
Example: `native`
354+
355+
| `kibana.add_to_spaces[]`
356+
| Set of space IDs that a saved object is being shared to as part of the event.
357+
358+
Example: `[default, marketing]`
359+
360+
| `kibana.delete_from_spaces[]`
361+
| Set of space IDs that a saved object is being removed from as part of the event.
362+
363+
Example: `[marketing]`
364+
365+
2+a| ===== Error Fields
366+
367+
| *Field*
368+
| *Description*
369+
370+
| `error.code`
371+
| Error code describing the error.
372+
373+
| `error.message`
374+
| Error message.
375+
376+
2+a| ===== HTTP and URL Fields
377+
378+
| *Field*
379+
| *Description*
380+
381+
| `http.request.method`
382+
| HTTP request method.
383+
384+
Example: `get`, `post`, `put`, `delete`
385+
386+
| `url.domain`
387+
| Domain of the url.
388+
389+
Example: `www.elastic.co`
390+
391+
| `url.path`
392+
| Path of the request.
393+
394+
Example: `/search`
395+
396+
| `url.port`
397+
| Port of the request.
398+
399+
Example: `443`
400+
401+
| `url.query`
402+
| The query field describes the query string of the request.
403+
404+
Example: `q=elasticsearch`
405+
406+
| `url.scheme`
407+
| Scheme of the request.
408+
409+
Example: `https`
410+
411+
2+a| ===== Tracing Fields
412+
413+
| *Field*
414+
| *Description*
415+
416+
| `trace.id`
417+
| Unique identifier allowing events of the same transaction from {kib} and {es} to be be correlated.
418+
419+
|======

x-pack/plugins/security/server/audit/audit_events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('#httpRequestEvent', () => {
284284
"path": "/path",
285285
"port": undefined,
286286
"query": undefined,
287-
"scheme": "http:",
287+
"scheme": "http",
288288
},
289289
}
290290
`);
@@ -321,7 +321,7 @@ describe('#httpRequestEvent', () => {
321321
"path": "/original/path",
322322
"port": undefined,
323323
"query": "query=param",
324-
"scheme": "http:",
324+
"scheme": "http",
325325
},
326326
}
327327
`);

x-pack/plugins/security/server/audit/audit_events.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@ export interface AuditEvent {
2828
category?: EventCategory;
2929
type?: EventType;
3030
outcome?: EventOutcome;
31-
module?: string;
32-
dataset?: string;
3331
};
3432
user?: {
3533
name: string;
36-
email?: string;
37-
full_name?: string;
38-
hash?: string;
3934
roles?: readonly string[];
4035
};
4136
kibana?: {
@@ -87,17 +82,10 @@ export interface AuditEvent {
8782
http?: {
8883
request?: {
8984
method?: string;
90-
body?: {
91-
content: string;
92-
};
93-
};
94-
response?: {
95-
status_code?: number;
9685
};
9786
};
9887
url?: {
9988
domain?: string;
100-
full?: string;
10189
path?: string;
10290
port?: number;
10391
query?: string;
@@ -108,14 +96,10 @@ export interface AuditEvent {
10896
export enum EventCategory {
10997
DATABASE = 'database',
11098
WEB = 'web',
111-
IAM = 'iam',
11299
AUTHENTICATION = 'authentication',
113-
PROCESS = 'process',
114100
}
115101

116102
export enum EventType {
117-
USER = 'user',
118-
GROUP = 'group',
119103
CREATION = 'creation',
120104
ACCESS = 'access',
121105
CHANGE = 'change',
@@ -152,7 +136,7 @@ export function httpRequestEvent({ request }: HttpRequestParams): AuditEvent {
152136
path: url.pathname,
153137
port: url.port ? parseInt(url.port, 10) : undefined,
154138
query: url.search ? url.search.slice(1) : undefined,
155-
scheme: url.protocol,
139+
scheme: url.protocol ? url.protocol.substr(0, url.protocol.length - 1) : undefined,
156140
},
157141
};
158142
}

0 commit comments

Comments
 (0)