const url = 'https://example.com/api/v0/serve';const options = { method: 'POST', headers: {'X-Tenzir-Token': '<X-Tenzir-Token>', 'Content-Type': 'application/json'}, body: '{"serve_id":"query-1","max_events":1024,"min_events":1,"timeout":"5s","schema":"exact"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v0/serve \ --header 'Content-Type: application/json' \ --header 'X-Tenzir-Token: <X-Tenzir-Token>' \ --data '{ "serve_id": "query-1", "max_events": 1024, "min_events": 1, "timeout": "5s", "schema": "exact" }'Reads events from an existing pipeline output stream. By default, the endpoint uses long polling (timeout: 5s) and returns as soon as at least one event is available (min_events: 1).
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Pipeline output request.
object
The output stream identifier returned when the pipeline was launched.
The continuation token from the previous response. Omit this field for the initial request.
The maximum number of events to return.
The minimum number of events to wait for before returning.
The maximum time to spend on the request. Reaching the timeout returns the available events and is not an error. The timeout must not be greater than 10 seconds.
The schema representation to include in the response. Use exact for a representation that matches Tenzir’s type system exactly, and never to omit schema definitions.
Example
{ "serve_id": "query-1", "max_events": 1024, "min_events": 1, "timeout": "5s", "schema": "exact"}Responses
Section titled “ Responses ”Events are available, the timeout was reached, or the pipeline reached a terminal state.
object
The token to use when reading the next batch. The value is null when the pipeline reached a terminal state.
The pipeline state at the time of the request.
The schemas for the returned events. This field is omitted when the request sets schema to never.
object
The unique schema identifier.
The schema definition in JSON format.
The returned events.
object
The unique schema identifier.
The event data in JSON format.
object
Example
{ "next_continuation_token": "340ce2j", "state": "running", "schemas": [ { "schema_id": "c631d301e4b18f4", "definition": { "name": "tenzir.summarize", "kind": "record", "type": "tenzir.summarize", "attributes": {}, "path": [], "fields": [] } } ], "events": [ { "schema_id": "c631d301e4b18f4", "data": { "timestamp": "2023-04-26T12:00:00Z", "schema": "zeek.conn", "events": 50 } } ]}The request body is invalid.
object
The error message.
Example
{ "error": "Invalid arguments"}