Skip to content

Commit 7674012

Browse files
committed
feat(influxdb3): Add missing precision CLI option, fix and enhance write documentation.\
- Verified precision behavior in source code. Added auto-detection note for all APIs: Added a note explaining that InfluxDB 3 uses timestamp magnitude to auto-detect precision by default, and users can specify precision to avoid ambiguity. - Fix allowed precision values\ - Add examples
1 parent 3ceabee commit 7674012

File tree

7 files changed

+77
-28
lines changed

7 files changed

+77
-28
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
analyze-api-source:
2+
<product_name> <endpoint_name> <parameter_name>
3+
4+
Analyze source code in the specified repo to determine:
5+
1. HTTP method and endpoint path
6+
2. Parameters for the given endpoint
7+
3. Whether the specified parameter is supported for the given API endpoint
8+
4. Parameter format, valid values, and default behavior
9+
5. Any limitations or quirks of the parameter
10+
11+
For product InfluxDB 3 Core and Enterprise,
12+
Search repo influxdata/influxdb
13+
Search through:
14+
- HTTP endpoint handlers in
15+
influxdb3_server/src/http/
16+
- Parameter structs and deserialization
17+
- Request routing and processing logic
18+
- Type definitions in influxdb3_types/src/
19+
20+
In the output, provide:
21+
- Comparison across v1, v2, and v3 API compatibility
22+
23+
In the output, provide:
24+
Concrete examples of endpoint and parameter usage
25+
Cite specific source code locations.

content/influxdb3/core/reference/cli/influxdb3/write.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ source: /shared/influxdb3-cli/write.md
1111
---
1212

1313
<!--
14-
The content of this file is at content/shared/influxdb3-cli/write.md
14+
//SOURCE - content/shared/influxdb3-cli/write.md
1515
-->

content/shared/influxdb3-cli/write.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ influxdb3 write [OPTIONS] --database <DATABASE_NAME> [LINE_PROTOCOL]...
3131
| | `--token` | _({{< req >}})_ Authentication token |
3232
| `-f` | `--file` | A file that contains line protocol to write |
3333
| | `--accept-partial` | Accept partial writes |
34+
| | `--precision` | Precision of data timestamps (`ns`, `us`, `ms`, or `s`) | |
3435
| | `--tls-ca` | Path to a custom TLS certificate authority (for testing or self-signed certificates) |
3536
| `-h` | `--help` | Print help information |
3637
| | `--help-all` | Print detailed help information |
@@ -144,4 +145,22 @@ cat ./data.lp | influxdb3 write \
144145
{{% /code-tab-content %}}
145146
{{< /code-tabs-wrapper >}}
146147

148+
## Write line protocol with specific timestamp precision
149+
150+
By default, in CLI and HTTP API write requests, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
151+
To avoid any ambiguity, specify the `--precision {ns|us|ms|s}` option:
152+
153+
<!--pytest.mark.skip-->
154+
155+
```bash
156+
influxdb3 write \
157+
--database DATABASE_NAME \
158+
--token AUTH_TOKEN \
159+
--precision s \
160+
'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
161+
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
162+
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
163+
home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
164+
'
165+
```
147166
{{% /code-placeholders %}}

content/shared/influxdb3-write-guides/best-practices/optimize-writes.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ if your data isn't collected in nanoseconds, there is no need to write at that p
8484
For better performance, use the coarsest timestamp precision you can for your
8585
use case.
8686

87-
By default, {{< product-name >}} attempts to auto-detect the precision of
88-
timestamps in line protocol by identifying what precision would be relatively
89-
close to "now." You can also specify your timestamp precision in your write
90-
request. {{< product-name >}} supports the following timestamp precisions:
91-
92-
- `ns` (nanoseconds)
93-
- `us` (microseconds)
94-
- `ms` (milliseconds)
95-
- `s` (seconds)
87+
> [!Tip]
88+
> By default, in CLI and HTTP API write requests, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
89+
90+
To specify the precision of timestamps in your write
91+
request, pass the `precision` option.
92+
93+
For more information, see the following:
94+
95+
- [`/api/v3/write_lp` endpoint parameters](/influxdb3/version/write-data/http-api/v3-write-lp/)
96+
- [`/api/v2/write` v2 API endpoint parameters](/influxdb3/version/write-data/http-api/compatibility-apis/#v2-api-write-parameters)
97+
- [`/write` v1 API endpoint parameters](/influxdb3/version/write-data/http-api/compatibility-apis/#v1-api-write-parameters)
9698

9799
## Use gzip compression
98100

content/shared/influxdb3-write-guides/http-api/compatibility-apis.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ Parameter | Allowed in | Ignored | Value
7575

7676
#### Timestamp precision {#timestamp-precision-v2}
7777

78+
> [!Note]
79+
> By default, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
80+
> To avoid any ambiguity, you can specify the precision of timestamps in your data.
81+
7882
Use one of the following `precision` values in v2 API `/api/v2/write` requests:
7983

8084
- `ns`: nanoseconds
@@ -224,6 +228,10 @@ Parameter | Allowed in | Ignored | Value
224228

225229
#### Timestamp precision {#timestamp-precision-v1}
226230

231+
> [!Note]
232+
> By default, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
233+
> To avoid any ambiguity, you can specify the precision of timestamps in your data.
234+
227235
Use one of the following `precision` values in v1 API `/write` requests:
228236

229237
- `ns`: nanoseconds

content/shared/influxdb3-write-guides/http-api/v3-write-lp.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ syntax as previous versions of InfluxDB, and supports the following:
77

88
- `?accept_partial=<BOOLEAN>`: Accept or reject partial writes (default is `true`).
99
- `?no_sync=<BOOLEAN>`: Control when writes are acknowledged:
10-
- `no_sync=true`: Acknowledge writes before WAL persistence completes.
10+
- `no_sync=true`: Acknowledges writes before WAL persistence completes.
1111
- `no_sync=false`: Acknowledges writes after WAL persistence completes (default).
1212
- `?precision=<PRECISION>`: Specify the precision of the timestamp.
13-
The default is `ns` (nanosecond) precision.
14-
You can also use `auto` to let InfluxDB automatically determine the timestamp
15-
precision by identifying which precisions resolves most closely to _now_.
13+
By default, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
14+
To avoid any ambiguity, you can specify the precision of timestamps in your data.
15+
16+
The {{< product-name >}} `/api/v3/write_lp` API endpoint supports the following timestamp precisions:
17+
18+
- `ns` (nanoseconds)
19+
- `us` (microseconds)
20+
- `ms` (milliseconds)
21+
- `s` (seconds)
1622

1723
##### Request body
1824

@@ -25,7 +31,7 @@ the {{< influxdb3/home-sample-link >}}, but you can use any HTTP client._
2531

2632
{{% influxdb/custom-timestamps %}}
2733
```bash
28-
curl -v "http://{{< influxdb/host >}}/api/v3/write_lp?db=sensors&precision=auto" \
34+
curl -v "http://{{< influxdb/host >}}/api/v3/write_lp?db=sensors&precision=s" \
2935
--data-raw "home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1735545600
3036
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1735545600
3137
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1735549200

content/shared/influxdb3-write-guides/influxdb3-cli.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,8 @@ Provide the following:
7373
- from stdin
7474

7575
> [!Note]
76-
> {{< product-name >}} auto-detects the timestamp precision by identifying which
77-
> precision results in timestamps relatively close to "now."
78-
79-
<!--
80-
ADD THIS BACK WHEN THE precision FLAG IS ADDED
81-
82-
- The timestamp precision as seconds (`s`) using the `--precision` option
83-
84-
> [!Note]
85-
> If no precision is provided, {{< product-name >}} attempts to auto-detect
86-
> the timestamp precision by identifying which precision results in timestamps
87-
> relatively close to "now."
88-
-->
76+
> By default, {{% product-name %}} uses the timestamp magnitude to auto-detect the precision.
77+
> To specify the precision of timestamps in your data, use the [`--precision {ns|us|ms|s}` option](/influxdb3/version/reference/cli/influxdb3/write/#options).
8978
9079
{{< tabs-wrapper >}}
9180
{{% tabs %}}

0 commit comments

Comments
 (0)