added information about writing csv, updated influx write doc, resolves #858
parent
63b610b309
commit
15197e6dac
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: influx write
|
||||
description: >
|
||||
The 'influx write' command writes line protocol to InfluxDB either via a single
|
||||
line of line protocol, or a via a file containing line protocol.
|
||||
The `influx write` command writes data to InfluxDB via stdin or from a specified file.
|
||||
Write data using line protocol or annotated CSV.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: influx write
|
||||
|
@ -11,20 +11,29 @@ weight: 101
|
|||
v2.0/tags: [write]
|
||||
---
|
||||
|
||||
The `influx write` writes a single line of line protocol to InfluxDB,
|
||||
or adds an entire file specified with an `@` prefix.
|
||||
The `influx write` command writes data to InfluxDB via stdin or from a specified file.
|
||||
Write data using [line protocol](/v2.0/reference/syntax/line-protocol) or
|
||||
[annotated CSV](/v2.0/reference/syntax/annotated-csv).
|
||||
|
||||
## Usage
|
||||
```
|
||||
influx write [line protocol or @/path/to/points.txt] [flags]
|
||||
influx write [flags]
|
||||
influx write [command]
|
||||
```
|
||||
|
||||
## Subcommands
|
||||
| Subcommand | Description |
|
||||
|:---------- |:----------- |
|
||||
| [dryrun](/v2.0/reference/cli/influx/write/dryrun) | Write to stdout instead of InfluxDB |
|
||||
|
||||
## Flags
|
||||
| Flag | Description | Input type | {{< cli/mapped >}} |
|
||||
|:---- |:----------- |:----------:|:------------------ |
|
||||
| `-b`, `--bucket` | Bucket name | string | `INFLUX_BUCKET_NAME` |
|
||||
| `--bucket-id` | Bucket ID | string | `INFLUX_BUCKET_ID` |
|
||||
| `-h`, `--help` | Help for the `write` command | | |
|
||||
| `-f`, `--file` | File to import | string | |
|
||||
| `--format` | Input format (`lp` or `csv`, default `lp`) | string | |
|
||||
| `-h`, `--help` | Help for the `dryrun` command | | |
|
||||
| `-o`, `--org` | Organization name | string | `INFLUX_ORG` |
|
||||
| `--org-id` | Organization ID | string | `INFLUX_ORG_ID` |
|
||||
| `-p`, `--precision` | Precision of the timestamps (default `ns`) | string | `INFLUX_PRECISION` |
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: influx write dryrun
|
||||
description: >
|
||||
The 'influx write dryrun' command prints write output to stdout instead of writing
|
||||
to InfluxDB. Use this command to test writing data.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: influx write dryrun
|
||||
parent: influx write
|
||||
weight: 101
|
||||
v2.0/tags: [write]
|
||||
---
|
||||
|
||||
The `influx write dryrun` command prints write output to stdout instead of writing
|
||||
to InfluxDB. Use this command to test writing data.
|
||||
|
||||
Supports [line protocol](/v2.0/reference/syntax/line-protocol) and
|
||||
[annotated CSV](/v2.0/reference/syntax/annotated-csv).
|
||||
Output is always **line protocol**.
|
||||
|
||||
## Usage
|
||||
```
|
||||
influx write dryrun [flags]
|
||||
```
|
||||
|
||||
## Flags
|
||||
| Flag | Description | Input type | {{< cli/mapped >}} |
|
||||
|:---- |:----------- |:----------:|:------------------ |
|
||||
| `-b`, `--bucket` | Bucket name | string | `INFLUX_BUCKET_NAME` |
|
||||
| `--bucket-id` | Bucket ID | string | `INFLUX_BUCKET_ID` |
|
||||
| `-f`, `--file` | File to import | string | |
|
||||
| `--format` | Input format (`lp` or `csv`, defaults `lp`) | string | |
|
||||
| `-h`, `--help` | Help for the `dryrun` command | | |
|
||||
| `-o`, `--org` | Organization name | string | `INFLUX_ORG` |
|
||||
| `--org-id` | Organization ID | string | `INFLUX_ORG_ID` |
|
||||
| `-p`, `--precision` | Precision of the timestamps (default `ns`) | string | `INFLUX_PRECISION` |
|
||||
|
||||
{{% cli/influx-global-flags %}}
|
|
@ -9,6 +9,12 @@ menu:
|
|||
v2_0:
|
||||
name: Write data
|
||||
v2.0/tags: [write, line protocol]
|
||||
related:
|
||||
- /v2.0/write-data/use-telegraf/
|
||||
- /v2.0/api/#tag/Write, InfluxDB API /write endpoint
|
||||
- /v2.0/reference/syntax/line-protocol
|
||||
- /v2.0/reference/syntax/annotated-csv
|
||||
- /v2.0/reference/cli/influx/write
|
||||
---
|
||||
|
||||
Collect and write time series data to InfluxDB using [line protocol](/v2.0/reference/syntax/line-protocol),
|
||||
|
@ -133,26 +139,45 @@ To scrape metrics, see [Create a scraper](/v2.0/write-data/scrape-data/manage-sc
|
|||
From the command line, use the [`influx write` command](/v2.0/reference/cli/influx/write/) to write data to InfluxDB.
|
||||
Include the following in your command:
|
||||
|
||||
| Requirement | Include by |
|
||||
|:----------- |:---------- |
|
||||
| Organization | Use the `-o`,`--org`, or `--org-id` flags. |
|
||||
| Bucket | Use the `-b`, `--bucket`, or `--bucket-id` flags. |
|
||||
| Precision | Use the `-p`, `--precision` flag. |
|
||||
| Authentication token | Set the `INFLUX_TOKEN` environment variable or use the `t`, `--token` flag. |
|
||||
| Line protocol | Write a single line as a string or pass a file path prefixed with `@`. |
|
||||
| Requirement | Include by |
|
||||
|:----------- |:---------- |
|
||||
| Organization | Use the `-o`,`--org`, or `--org-id` flags. |
|
||||
| Bucket | Use the `-b`, `--bucket`, or `--bucket-id` flags. |
|
||||
| Precision | Use the `-p`, `--precision` flag. |
|
||||
| Authentication token | Set the `INFLUX_TOKEN` environment variable or use the `t`, `--token` flag. |
|
||||
| Data | Write data using **line protocol** or **annotated CSV**. Pass a file with the `-f`, `--file` flag. |
|
||||
|
||||
##### Example influx write commands
|
||||
_See [Line protocol](/v2.0/reference/syntax/line-protocol/) and [Annotated CSV](/v2.0/reference/syntax/annotated-csv)_
|
||||
|
||||
To write a single data point, for example, run
|
||||
#### Example influx write commands
|
||||
|
||||
##### Write a single line of line protocol
|
||||
```sh
|
||||
influx write -b bucketName -o orgName -p s 'myMeasurement,host=myHost testField="testData" 1556896326'
|
||||
influx write \
|
||||
-b bucketName \
|
||||
-o orgName \
|
||||
-p s \
|
||||
'myMeasurement,host=myHost testField="testData" 1556896326'
|
||||
```
|
||||
|
||||
To write data in line protocol from a file, try
|
||||
|
||||
##### Write line protocol from a file
|
||||
```sh
|
||||
influx write \
|
||||
-b bucketName \
|
||||
-o orgName \
|
||||
-p s \
|
||||
--format=lp
|
||||
-f /path/to/line-protocol.txt
|
||||
```
|
||||
influx write -b bucketName -o orgName -p s @/path/to/line-protocol.txt
|
||||
|
||||
##### Write annotated CSV from a file
|
||||
```sh
|
||||
influx write \
|
||||
-b bucketName \
|
||||
-o orgName \
|
||||
-p s \
|
||||
--format=csv
|
||||
-f /path/to/data.csv
|
||||
```
|
||||
|
||||
### InfluxDB API
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<h4 id="related-articles">Related articles</h4>
|
||||
<ul>
|
||||
{{ range .Params.related }}
|
||||
{{ if in . "http" }}
|
||||
{{ if or (in . "http") (in . "/v2.0/api") }}
|
||||
{{ $link := replaceRE `\,\s(.*)$` "" . }}
|
||||
{{ $title := replaceRE `^(\S*\,\s)` "" . }}
|
||||
<li><a href="{{ $link }}" target="_blank">{{ $title }}</a></li>
|
||||
|
|
Loading…
Reference in New Issue