Skip to content

Commit ce87791

Browse files
committed
fix(core): write apis and add examples
1 parent 088735b commit ce87791

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

content/shared/v3-core-get-started/_index.md

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,22 +228,21 @@ Subsequent requests can add new fields on-the-fly, but can't add new tags.
228228
229229
InfluxDB 3 Core is optimized for recent data only--it accepts writes for data with timestamps from the last 72 hours. It persists that data in Parquet files for access by third-party systems for longer term historical analysis and queries. If you require longer historical queries with a compactor that optimizes data organization, consider using [InfluxDB 3 Enterprise](/influxdb3/enterprise/get-started/).
230230
231-
**Note**: write requests to the database _don't_ return until a WAL file has been flushed to the configured object store, which by default happens once per second.
232-
This means that individual write requests may not complete quickly, but you can make many concurrent requests to get higher total throughput. In the future, we will add an API parameter to make requests that do not wait for the WAL flush to return.
233231
234232
The database has three write API endpoints that respond to HTTP `POST` requests:
235233
236-
* `/write_lp?db=mydb,precision=ns`
237-
* `/api/v2/write_lp?db=mydb,precision=ns`
238-
* `/api/v3/write_lp?db=mydb,precision=ns`
234+
* `/write?db=mydb&precision=ns`
235+
* `/api/v2/write?bucket=mydb&precision=ns`
236+
* `/api/v3/write_lp?db=mydb&precision=ns&accept_partial=true`
239237
240-
{{% product-name %}} provides the `/write_lp` and `/api/v2` endpoints for backward compatibility with clients that can write data to previous versions of InfluxDB.
238+
{{% product-name %}} provides the `/write` and `/api/v2/write` endpoints for backward compatibility with clients that can write data to previous versions of InfluxDB.
241239
However, these APIs differ from the APIs in the previous versions in the following ways:
242240
243241
- Tags in a table (measurement) are _immutable_
244242
- A tag and a field can't have the same name within a table.
245243
246-
The `/api/v3/write_lp` endpoint accepts the same line protocol syntax as previous versions, and brings new functionality that lets you accept or reject partial writes using the `accept_partial` parameter (`true` is default).
244+
{{% product-name %}} adds the `/api/v3/write_lp` endpoint, which accepts the same line protocol syntax as previous versions, and supports an `?accept_partial=<BOOLEAN>` parameter, which
245+
lets you accept or reject partial writes (default is `true`).
247246
248247
The following code block is an example of [line protocol](/influxdb3/core/reference/syntax/line-protocol/), which shows the table name followed by tags, which are an ordered, comma-separated list of key/value pairs where the values are strings, followed by a comma-separated list of key/value pairs that are the fields, and ending with an optional timestamp. The timestamp by default is a nanosecond epoch, but you can specify a different precision through the `precision` query parameter.
249248
@@ -262,8 +261,52 @@ If you save the preceding line protocol to a file (for example, `server_data`),
262261
influxdb3 write --database=mydb --file=server_data
263262
```
264263
265-
The written data goes into WAL files, created once per second, and into an in-memory queryable buffer. Later, InfluxDB snapshots the WAL and persists the data into object storage as Parquet files.
266-
We'll cover the [diskless architecture](#diskless-architecture) later in this document.
264+
The following examples show how to write data using `curl` and the `/api/3/write_lp` HTTP endpoint.
265+
To show the difference between accepting and rejecting partial writes, `line 2` in the example contains a `string` value for a `float` field (`temp=hi`).
266+
267+
##### Partial write of line protocol occurred
268+
269+
With `accept_partial=true`:
270+
271+
```
272+
* upload completely sent off: 59 bytes
273+
< HTTP/1.1 400 Bad Request
274+
< transfer-encoding: chunked
275+
< date: Wed, 15 Jan 2025 19:35:36 GMT
276+
<
277+
* Connection #0 to host localhost left intact
278+
{"error":"partial write of line protocol occurred","data":[{"original_line":"dquote> home,room=Sunroom temp=hi","line_number":2,"error_message":"No fields were provided"}]}%
279+
```
280+
281+
The response is an HTTP error (`400`) status, and the response body contains `partial write of line protocol occurred` and details about the problem line.
282+
283+
##### Parsing failed for write_lp endpoint
284+
285+
With `accept_partial=false`:
286+
287+
> curl -v -XPOST "localhost:8181/api/v3/write_lp?db=sensors&precision=auto&accept_partial=false" \
288+
--data-raw "home,room=Sunroom temp=96
289+
dquote> home,room=Sunroom temp=hi"
290+
< HTTP/1.1 400 Bad Request
291+
< transfer-encoding: chunked
292+
< date: Wed, 15 Jan 2025 19:28:27 GMT
293+
<
294+
* Connection #0 to host localhost left intact
295+
{"error":"parsing failed for write_lp endpoint","data":{"original_line":"dquote> home,room=Sunroom temp=hi","line_number":2,"error_message":"No fields were provided"}}%
296+
```
297+
298+
The response is an HTTP error (`400`) status, and the response body contains `parsing failed for write_lp endpoint` and details about the problem line.
299+
300+
##### Data durability
301+
302+
Written data goes into WAL files, created once per second, and into an in-memory queryable buffer. Later, InfluxDB snapshots the WAL and persists the data into object storage as Parquet files.
303+
We cover the [diskless architecture](#diskless-architecture) later in this guide.
304+
305+
> [!Note]
306+
> ##### Write requests return after WAL flush
307+
> Write requests to the database _don't_ return until a WAL file has been flushed to the configured object store, which by default happens once per second.
308+
> Individual write requests might not complete quickly, but you can make many concurrent requests to get higher total throughput.
309+
> In the future, we will add an API parameter that lets requests return without waiting for the WAL flush.
267310
268311
#### Create a Database or Table
269312

0 commit comments

Comments
 (0)