-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Initial pipelines docs #18595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial pipelines docs #18595
Changes from 66 commits
01564e4
e0cc62f
1dfcc0d
4ab692a
4afaa0e
72381fc
112140e
51ce611
dedafff
8ffc4bc
9f6d180
31bdfe1
b4fcf86
69d9dd5
59a1902
2631676
4511e58
4c940f7
5184319
38cb4b4
ff67c0e
a8392d1
8cd419a
f231b40
ce0c086
f73c367
1ace647
9166d38
7784a6a
8b37f29
45175ca
fef991b
436084b
420eae7
80a4d85
eeea924
ca49906
80f0ae4
20f8814
bf20e02
4f74185
85fa5bd
b9cdb1a
8781ded
4df10ad
85af8d4
dc61631
cff26ee
924796d
33137ac
152dd1c
fe1aefa
09646a4
2fcd519
09b61c2
be960d7
f237dea
41bbabf
a95fb41
f04c9eb
e1a8c28
3af05d6
ed87e98
c87125d
a9196f6
2c5d9f8
8b41ff4
88f5c53
38a5bc1
047106b
28363ce
759a8b0
4f2ff46
36c5679
31e9b75
16222db
d884e01
9a3da5d
73d7457
5a60392
db61fa0
2e3bd0a
45b0c23
900ba16
a203abc
f257f1e
85a14a5
5ee167f
658dd38
686d709
d6524f2
447a1bd
7dcde9e
ae072d8
591e655
1327639
47ec978
525cc91
e1a1970
b452a6d
f75a3ec
5bdc9f8
da23c75
c54275c
bdb1652
235c256
af6301c
00b8105
e07dd28
48b564d
b2aa8bc
37feeed
7f80c98
3b26f53
6f7193a
f66a13b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| title: Configure HTTP Endpoint | ||
| pcx_content_type: concept | ||
| sidebar: | ||
| order: 1 | ||
| head: | ||
| - tag: title | ||
| content: Configure HTTP Endpoint | ||
| --- | ||
|
|
||
| import { Render, PackageManagers } from "~/components"; | ||
|
|
||
| Pipelines support data ingestion over HTTP. When you create a new pipeline, you'll receive a globally scalable ingestion endpoint. To ingest data, make HTTP POST requests to the endpoint. | ||
|
|
||
|
|
||
| ```sh | ||
| $ npx wrangler pipelines create [PIPELINE-NAME] --r2-bucket [R2-BUCKET-NAME] | ||
|
|
||
| 🌀 Creating pipeline named "[PIPELINE-NAME]" | ||
| ✅ Successfully created pipeline [PIPELINE-NAME] with ID [PIPELINE-ID] | ||
|
|
||
| You can now send data to your pipeline with: | ||
| curl "https://<PIPELINE-ID>.pipelines.cloudflare.com/" -d '[{ "foo":"bar" }]' | ||
| ``` | ||
|
|
||
| ## Accepted data formats | ||
| Pipelines accept arrays of valid JSON objects. You can send multiple objects in a single request, provided the total data volume is within the [documented limits](/pipelines/platform/limits). Sending data in a different format will result in an error. | ||
|
|
||
| For example, you can send data to your pipeline using a curl command like this: | ||
| ```sh | ||
| curl -X POST https://<PIPELINE-ID>.pipelines.cloudflare.com \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '[{"foo":"bar"}, {"foo":"bar"}, {"foo":"bar"}]' | ||
|
|
||
| {"success":true,"result":{"committed":3}} | ||
| ``` | ||
|
|
||
| ## Turning HTTP ingestion off | ||
| By default, ingestion via HTTP is turned on. You can turn it off by setting `--enable-http false` when creating or updating a pipeline. | ||
|
|
||
| ```sh | ||
| $ npx wrangler pipelines create [PIPELINE-NAME] --r2-bucket [R2-BUCKET-NAME] --enable-http false | ||
| ``` | ||
|
|
||
| Ingestion URLs are tied to your pipeline ID. Turning HTTP off, and then turning it back on, will not change the URL. | ||
|
|
||
| ## Authentication | ||
| You can secure your HTTP ingestion endpoint using Cloudflare API tokens. By default, authentication is turned off. To enable authentication, use `--require-http-auth true` while creating or updating a pipeline. | ||
|
|
||
| ```sh | ||
| $ npx wrangler pipelines create [PIPELINE-NAME] --r2-bucket [R2-BUCKET-NAME] --require-http-auth true | ||
| ``` | ||
|
|
||
| Once authentication is turned on, you will need to include a Cloudflare API token in your request headers. | ||
|
|
||
| ### Get API token | ||
| 1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account. | ||
| 2. Navigate to your [API Keys](https://dash.cloudflare.com/profile/api-tokens) | ||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 3. Select *Create Token* | ||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 4. Choose the template for Workers Pipelines. Click on *continue to summary*, and finally on *create token*. Make sure to copy the API token, and save it securely. | ||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Making authenticated requests | ||
| Include the API token you created in the previous step in the headers for your request: | ||
|
|
||
| ```sh | ||
| curl https://<PIPELINE-ID>.pipelines.cloudflare.com | ||
| -H "Content-Type: application/json" \ | ||
| -H "Authorization: Bearer ${API_TOKEN}" \ | ||
| -d '[{"foo":"bar"}, {"foo":"bar"}, {"foo":"bar"}]' | ||
| ``` | ||
|
|
||
| ## Specifying CORS Settings | ||
| If you want to use your pipeline to ingest client side data, such as website clicks, you'll need to configure your [Cross-Origin Resource Sharing (CORS) settings](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). | ||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Without setting your CORS settings, browsers will restrict requests made to your pipeline endpoint. For example, if your website domain is `https://my-website.com`, and you want to post client side data to your pipeline at `https://<PIPELINE-ID>.pipelines.cloudflare.com`, without CORS settings, the request will fail. | ||
|
|
||
| To fix this, you need to configure your pipeline to accept requests from `https://my-website.com`. You can do so while creating or updating a pipeline, using the flag `--cors-origins`. You can specify multiple domains separated by a space. | ||
|
|
||
| ```sh | ||
| $ npx wrangler pipelines update [PIPELINE-NAME] --cors-origins https://mydomain.com http://localhost:8787 | ||
| ``` | ||
|
|
||
| You can specify that all cross origin requests are accepted. We recommend only using this option in development, and not for production use cases. | ||
| ```sh | ||
| $ npx wrangler pipelines update [PIPELINE-NAME] --cors-origins "*" | ||
| ``` | ||
|
|
||
| After your the `--cors-origins` have been set on your pipeline, your pipeline will respond to preflight requests and POST requests with the appropriate `Access-Control-Allow-Origin` headers set. | ||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| title: Build with Pipelines | ||
| pcx_content_type: navigation | ||
| sidebar: | ||
| order: 3 | ||
| group: | ||
| hideIndex: true | ||
| --- |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||||||
| --- | ||||||||||
| title: Customize output settings | ||||||||||
| pcx_content_type: concept | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| sidebar: | ||||||||||
| order: 3 | ||||||||||
| head: | ||||||||||
| - tag: title | ||||||||||
| content: Customize output settings | ||||||||||
| --- | ||||||||||
|
|
||||||||||
| import { Render, PackageManagers } from "~/components"; | ||||||||||
|
|
||||||||||
| Pipelines convert a stream of records into output files, and deliver the files to an R2 bucket in your account. This guide details how you can change the output destination, and how to customize batch settings to generate query ready files. | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| ## Configure an R2 bucket as a destination | ||||||||||
| To create or update a pipeline using Wrangler, run the following command in a terminal: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| npx wrangler pipelines create [PIPELINE-NAME] --r2-bucket [R2-BUCKET-NAME] | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| After running this command, you'll be prompted to authorize Cloudflare Workers Pipelines to create an R2 API token on your behalf. Your pipeline uses the R2 API token to load data into your bucket. You can approve the request through the browser link which will open automatically. | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| If you prefer not to authenticate this way, you may pass your [R2 API Token](/r2/api/s3/tokens/) to Wrangler: | ||||||||||
| ```sh | ||||||||||
| npx wrangler pipelines create [PIPELINE-NAME] --r2 [R2-BUCKET-NAME] --r2-access-key-id [ACCESS-KEY-ID] --r2-secret-access-key [SECRET-ACCESS-KEY] | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## File format and compression | ||||||||||
| Output files are generated as Newline Delimited JSON files (`ndjson`). Each line in an output file maps to a single record. | ||||||||||
|
|
||||||||||
| By default, output files are compressed in the `gzip` format. Compression can be turned off using the `--compression` flag: | ||||||||||
| ```sh | ||||||||||
| npx wrangler pipelines update [PIPELINE-NAME] --compression none | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Output files are named using a [UILD](https://github.com/ulid/spec) slug, followed by an extension. | ||||||||||
|
|
||||||||||
| ## Customize batch behavior | ||||||||||
| When configuring your pipeline, you can define how records are batched before they are delivered to R2. Batches of records are written out to a single output file. | ||||||||||
|
|
||||||||||
| Batching can: | ||||||||||
| 1. Reduce the number of output files written to R2, and thus reduce the [cost of writing data to R2](/r2/pricing/#class-a-operations) | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| 2. Increase the size of output files, making them more efficient to query | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| There are three ways to define how ingested data is batched: | ||||||||||
|
|
||||||||||
| 1. `batch-max-mb`: The maximum amount of data that will be batched, in megabytes. Default is 10 MB, maximum is 100 MB. | ||||||||||
maheshwarip marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| 2. `batch-max-rows`: The maximum number of rows or events in a batch before data is written. Default, and maximum, is 10,000 rows. | ||||||||||
|
||||||||||
| 2. `batch-max-rows`: The maximum number of rows or events in a batch before data is written. Default, and maximum, is 10,000 rows. | |
| 2. `batch-max-rows`: The maximum number of rows or events in a batch before data is written. Default, and maximum, is `10,000` rows. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 3. `batch-max-seconds`: The maximum duration of a batch before data is written, in seconds. Default is 15 seconds, maximum is 300 seconds. | |
| 3. `batch-max-seconds`: The maximum duration of a batch before data is written in seconds. Default is `15 seconds`, maximum is `300 seconds`. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| All three batch definitions work together. Whichever limit is reached first triggers the delivery of a batch. | |
| All three batch definitions work together. Whichever limit is reached first triggers the delivery of a batch. |
| All three batch definitions work together. Whichever limit is reached first triggers the delivery of a batch. | |
| All three batch definitions work together and whichever limit is reached first triggers the delivery of a batch. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #### Batch size limits | |
| ### Batch size limits |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| After running the above command, the output files generated by your pipeline will be stored under the prefix "test". Files will remain partitioned. Your output will look like this: | |
| After running the above command, the output files generated by your pipeline will be stored under the prefix `test`. Files will remain partitioned. Your output will look like this: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| pcx_content_type: concept | ||
| title: Shards | ||
| sidebar: | ||
| order: 11 | ||
| --- | ||
|
|
||
| TODO |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| title: Workers API | ||
| pcx_content_type: concept | ||
| sidebar: | ||
| order: 2 | ||
| head: | ||
| - tag: title | ||
| content: Workers API | ||
|
|
||
| --- | ||
|
|
||
| This guide details the Pipelines API within Cloudflare Workers. | ||
|
|
||
| ## Send data to a Pipeline from a Worker | ||
| Pipelines exposes an API directly to your Workers scripts via the [bindings](/workers/runtime-apis/bindings/#what-is-a-binding) concept. Bindings allow you to securely send data to a Pipeline without having to manage API keys or clients. | ||
|
|
||
| You can bind to a Pipeline by defining a `[[pipelines]]` binding within your Wrangler configuration. For example: | ||
|
|
||
| import { WranglerConfig } from "~/components"; | ||
|
|
||
| <WranglerConfig> | ||
|
|
||
| ```toml title="wrangler.toml" | ||
| #:schema node_modules/wrangler/config-schema.json | ||
| name = "pipeline-starter" | ||
| main = "src/index.ts" | ||
| compatibility_date = "2025-04-01" | ||
|
|
||
| [[pipelines]] | ||
| pipeline = "<MY-PIPELINE-NAME>" # The name of your Pipeline | ||
| binding = "MY_PIPELINE" # The binding name, accessed using env.MY_PIPELINE | ||
| ``` | ||
|
|
||
| </WranglerConfig> | ||
|
|
||
|
|
||
| ## `Pipeline` | ||
| A binding which allows a Worker to send messages to a Pipeline. | ||
|
|
||
| ```ts | ||
| interface Pipeline<PipelineRecord> { | ||
| send(records: PipelineRecord[]): Promise<void>; | ||
| } | ||
| ``` | ||
|
|
||
| * `send(records)`: `Promise<void>` | ||
|
|
||
| * Sends a message to the Pipeline. The body must be an array of objects supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types). | ||
| * When the promise resolves, the message is confirmed to be stored by the Pipeline. | ||
|
|
||
| :::note | ||
| When running your Worker locally, Pipelines are partially simulated. Worker code which sends data to a Pipeline will execute successfully. However, the full Pipeline, including batching & writing to R2, will not be executed locally. | ||
| ::: |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||
| --- | ||||||
| pcx_content_type: concept | ||||||
| title: How Pipelines Work | ||||||
| sidebar: | ||||||
| order: 1 | ||||||
| --- | ||||||
|
|
||||||
| Cloudflare Pipelines let you ingest data from a source, and deliver to a sink. It's built for high volume, real time data streams. Each pipeline can ingest up to 100 MB/s of data, via HTTP or a Worker, and load the data as files in an R2 bucket. | ||||||
|
||||||
| Cloudflare Pipelines let you ingest data from a source, and deliver to a sink. It's built for high volume, real time data streams. Each pipeline can ingest up to 100 MB/s of data, via HTTP or a Worker, and load the data as files in an R2 bucket. | |
| Cloudflare Pipelines let you ingest data from a source and deliver to a sink. It is built for high volume, real time data streams. Each pipeline can ingest up to 100 MB/s of data, via HTTP or a Worker, and load the data as files in an R2 bucket. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this sentence because this repeats the title.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Pipelines supports delivering data into [R2 Object Storage](/r2/). Ingested data is delivered as newline delimited JSON files (`ndjson`), with optional compression. Multiple pipelines can be configured to deliver data to the same R2 bucket. | |
| Pipelines supports delivering data into [R2 Object Storage](/r2/). Ingested data is delivered as newline delimited JSON files (`ndjson`) with optional compression. Multiple pipelines can be configured to deliver data to the same R2 bucket. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If you send too much data, the pipeline will communicate backpressure by returning a 429 response to HTTP requests, or throwing an error if using the Workers API. Refer to the [limits](/pipelines/platform/limits) to learn how much volume a single pipeline can support. You might see 429 responses if you are sending too many requests, or sending too much data. | |
| If you send too much data, the pipeline will communicate backpressure by returning a 429 response to HTTP requests, or throwing an error if using the Workers API. Refer to the [limits](/pipelines/platform/limits) to learn how much volume a single pipeline can support. You might see 429 responses if you are sending too many requests or sending too much data. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Increase the [shard count](/pipelines/build-with-pipelines/shards), to increase the maxiumum throughput of your pipeline. | |
| * Increase the [shard count](/pipelines/build-with-pipelines/shards) to increase the maximum throughput of your pipeline. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Send data to a second pipeline if you receive an error. You can setup multiple pipelines to write to the same R2 bucket. | |
| * Send data to a second pipeline if you receive an error. You can set up multiple pipelines to write to the same R2 bucket. |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't used but I would expect a clearer guide on How Pipelines Works (w/ diagrams) - e.g. how it scales, how it batches, and how the system works. We need to explain our data systems.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for sure - will add that |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| title: Concepts | ||
| pcx_content_type: navigation | ||
| sidebar: | ||
| order: 3 | ||
| group: | ||
| hideIndex: true | ||
| --- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| title: Examples | ||
| pcx_content_type: navigation | ||
| sidebar: | ||
| order: 6 | ||
| group: | ||
| hideIndex: false | ||
| --- | ||
|
|
||
| import { DirectoryListing } from "~/components" | ||
|
|
||
| <DirectoryListing /> |
Uh oh!
There was an error while loading. Please reload this page.