Starts an HTTP server that streams events as NDJSON to connected clients.
serve_http url:string, [path=string, method=string, responses=record, max_connections=int, tls=record]Description
Section titled “Description”The serve_http operator starts an HTTP server and streams pipeline events as
NDJSON to any HTTP client that
connects. Each connected client receives a copy of every event.
The operator waits for at least one client to connect before delivering data. When the pipeline finishes, the server shuts down and all client connections are closed.
Clients that connect to a path other than the stream path, or use the wrong HTTP
method, receive a 404 or 405 response respectively. Use the responses
option to serve static content on additional paths, such as health checks.
url: string
Section titled “url: string”The endpoint to listen on. Must have the form <host>:<port>. Use 0.0.0.0 to
accept connections on all interfaces.
path = string (optional)
Section titled “path = string (optional)”The URL path that clients connect to for the event stream.
Defaults to "/".
method = string (optional)
Section titled “method = string (optional)”The HTTP method that clients must use to connect to the stream.
Defaults to "GET".
responses = record (optional)
Section titled “responses = record (optional)”Serve fixed responses on auxiliary paths that are separate from the event stream. This is useful for health checks or status endpoints. For example:
responses={ "/health": {code: 200, content_type: "text/plain", body: "ok"},}Clients hitting /health receive the static body defined here, while clients
connecting to the stream path receive the live NDJSON event stream from the
pipeline.
Each route must be a record with code, content_type, and body fields. The
stream path itself cannot appear in responses.
max_connections = int (optional)
Section titled “max_connections = int (optional)”The maximum number of simultaneous client connections to accept.
Defaults to 128.
tls = record (optional)
Section titled “tls = record (optional)”TLS configuration. Provide an empty record (tls={}) to enable TLS with
defaults or set fields to customize it.
{ skip_peer_verification: bool, // skip certificate verification. cacert: string, // CA bundle to verify peers. certfile: string, // client certificate to present. keyfile: string, // private key for the client certificate. min_version: string, // minimum TLS version (`"1.0"`, `"1.1"`, `"1.2"`, "1.3"`). ciphers: string, // OpenSSL cipher list string. client_ca: string, // CA to validate client certificates. require_client_cert, // require clients to present a certificate.}The client_ca and require_client_cert options are only applied
for operators that accept incoming client connections, and otherwise
ignored.
Any value not specified in the record will either be picked up from the configuration or if not configured will not be used by the operator.
See the Node TLS Setup guide for more details.
Examples
Section titled “Examples”Stream events to HTTP clients
Section titled “Stream events to HTTP clients”Serve events on port 8080. Any HTTP client connecting to http://host:8080/
receives the events as NDJSON:
exportserve_http "0.0.0.0:8080"Connect with curl:
curl http://localhost:8080/Serve on a custom path and method
Section titled “Serve on a custom path and method”Require clients to POST to /events:
exportserve_http "0.0.0.0:8080", path="/events", method="post"Add a health check endpoint
Section titled “Add a health check endpoint”Expose a health endpoint alongside the event stream:
exportserve_http "0.0.0.0:8080", responses={ "/health": {code: 200, content_type: "text/plain", body: "ok"}, }Serve over HTTPS
Section titled “Serve over HTTPS”exportserve_http "0.0.0.0:8443", tls={ certfile: "/path/to/cert.pem", keyfile: "/path/to/key.pem", }