Skip to content

Commit 91a6dfd

Browse files
committed
[Event Log] Extended README.md with the documentation for a REST API and Start plugin contract.
1 parent 1f1f703 commit 91a6dfd

1 file changed

Lines changed: 77 additions & 1 deletion

File tree

x-pack/plugins/event_log/README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ history records associated with specific saved object ids.
164164

165165
## API
166166

167+
Event Log plugin returns a service instance from setup() and client service from start() methods.
168+
169+
### Setup
167170
```typescript
168171
// IEvent is a TS type generated from the subset of ECS supported
169172

170-
// the NP plugin returns a service instance from setup() and start()
171173
export interface IEventLogService {
172174
registerProviderActions(provider: string, actions: string[]): void;
173175
isProviderActionRegistered(provider: string, action: string): boolean;
@@ -237,6 +239,80 @@ properties `start`, `end`, and `duration` in the event. For example:
237239
It's anticipated that more "helper" methods like this will be provided in the
238240
future.
239241

242+
### Start
243+
```typescript
244+
245+
export interface IEventLogClientService {
246+
getClient(request: KibanaRequest): IEventLogClient;
247+
}
248+
249+
export interface IEventLogClient {
250+
findEventsBySavedObjectIds(
251+
type: string,
252+
ids: string[],
253+
options?: Partial<FindOptionsType>
254+
): Promise<QueryEventsBySavedObjectResult>;
255+
}
256+
```
257+
258+
The plugin exposes an `IEventLogClientService` object to plugins that pre-req it.
259+
Those plugins need to call `getClient(request)` to get the event log client.
260+
261+
## Experimental RESTful API
262+
263+
Using of the event log allows you to retrive the events for a given saved object type by the specified set of IDs.
264+
API listed below is experimental and could be changed or removed in the future.
265+
266+
### `GET /api/event_log/{type}/{id}/_find`: Get events for a given saved object type by the ID
267+
268+
Collects events information from the event log for the selected saved object by type and ID.
269+
270+
Params:
271+
272+
|Property|Description|Type|
273+
|---|---|---|
274+
|type|The type of the saved object whose events you're trying to get.|string|
275+
|id|The id of the saved object.|string|
276+
277+
Query:
278+
279+
|Property|Description|Type|
280+
|---|---|---|
281+
|page|The page number.|number|
282+
|per_page|The number of alerts to return per page.|number|
283+
|sort_field|Sorts the response. Could be an event fields returned in the response.|string|
284+
|sort_order|Sort direction, either `asc` or `desc`.|string|
285+
|filter|A <<kuery-query, KQL>> string that you filter with an attribute from the event. It should look like event.action: "execute".|string|
286+
|start|The date to start looking for saved object events in the event log. Either an ISO date string, or a duration string indicating time since now.|string|
287+
|end|The date to end looking for saved object events in the event log. Either an ISO date string, or a duration string indicating time since now.|string|
288+
289+
### `POST /api/event_log/{type}/_find`: Retrive events for a given saved object type by the IDs
290+
291+
Collects events information from the event log for the selected saved object by type and a set of the IDs.
292+
293+
Params:
294+
295+
|Property|Description|Type|
296+
|---|---|---|
297+
|type|The type of the saved object whose events you're trying to get.|string|
298+
299+
Query:
300+
301+
|Property|Description|Type|
302+
|---|---|---|
303+
|page|The page number.|number|
304+
|per_page|The number of alerts to return per page.|number|
305+
|sort_field|Sorts the response. Could be an event fields returned in the response.|string|
306+
|sort_order|Sort direction, either `asc` or `desc`.|string|
307+
|filter|A <<kuery-query, KQL>> string that you filter with an attribute from the event. It should look like event.action: "execute".|string|
308+
|start|The date to start looking for saved object events in the event log. Either an ISO date string, or a duration string indicating time since now.|string|
309+
|end|The date to end looking for saved object events in the event log. Either an ISO date string, or a duration string indicating time since now.|string|
310+
311+
Body:
312+
313+
|Property|Description|Type|
314+
|---|---|---|
315+
|ids|The array ids of the saved object.|string array|
240316

241317
## Stored data
242318

0 commit comments

Comments
 (0)