This documentation contains work-in-progress information for future Elastic Stack and Cloud releases. Use the version selector to view supported release docs. It also contains some Elastic Cloud serverless information. Check out our serverless docs for more details.
Post Event to an Analytics Collection
editPost Event to an Analytics Collection
editThis functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
Post an event to a Behavioral Analytics Collection.
Request
editPOST _application/analytics/<collection_name>/event/<event_type>
Path parameters
edit-
<collection_name>
- (Required, string) Analytics collection name you want to ingest event in.
-
<event_type>
-
(Required, string) Analytics event type. Can be one of
page_view
,search
,search_click
.
Request body
editFull request body parameters can be found in: Events reference.
Prerequisites
editRequires the post_behavioral_analytics_event
cluster privilege.
Response codes
edit-
202
- Event has been accepted and will be ingested.
-
404
-
Analytics Collection
<collection_name>
does not exists. -
400
- Occurs either when the event type is unknown or when event payload contains invalid data.
Examples
editThe following example send a search_click
event to an Analytics Collection called my_analytics_collection
:
resp = client.search_application.post_behavioral_analytics_event( collection_name="my_analytics_collection", event_type="search_click", body={ "session": { "id": "1797ca95-91c9-4e2e-b1bd-9c38e6f386a9" }, "user": { "id": "5f26f01a-bbee-4202-9298-81261067abbd" }, "search": { "query": "search term", "results": { "items": [ { "document": { "id": "123", "index": "products" } } ], "total_results": 10 }, "sort": { "name": "relevance" }, "search_application": "website" }, "document": { "id": "123", "index": "products" } }, ) print(resp)
const response = await client.searchApplication.postBehavioralAnalyticsEvent({ collection_name: "my_analytics_collection", event_type: "search_click", body: { session: { id: "1797ca95-91c9-4e2e-b1bd-9c38e6f386a9", }, user: { id: "5f26f01a-bbee-4202-9298-81261067abbd", }, search: { query: "search term", results: { items: [ { document: { id: "123", index: "products", }, }, ], total_results: 10, }, sort: { name: "relevance", }, search_application: "website", }, document: { id: "123", index: "products", }, }, }); console.log(response);
POST _application/analytics/my_analytics_collection/event/search_click { "session": { "id": "1797ca95-91c9-4e2e-b1bd-9c38e6f386a9" }, "user": { "id": "5f26f01a-bbee-4202-9298-81261067abbd" }, "search":{ "query": "search term", "results": { "items": [ { "document": { "id": "123", "index": "products" } } ], "total_results": 10 }, "sort": { "name": "relevance" }, "search_application": "website" }, "document":{ "id": "123", "index": "products" } }