From 15197e6dac74f8e6d091c57d2df86cacdfc8e016 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 26 Mar 2020 12:05:31 -0600 Subject: [PATCH] added information about writing csv, updated influx write doc, resolves #858 --- .../v2.0/reference/cli/influx/write/_index.md | 21 +++++--- .../v2.0/reference/cli/influx/write/dryrun.md | 38 ++++++++++++++ content/v2.0/write-data/_index.md | 51 ++++++++++++++----- layouts/partials/article/related.html | 2 +- 4 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 content/v2.0/reference/cli/influx/write/dryrun.md diff --git a/content/v2.0/reference/cli/influx/write/_index.md b/content/v2.0/reference/cli/influx/write/_index.md index 0f68c7399..f593b05fb 100644 --- a/content/v2.0/reference/cli/influx/write/_index.md +++ b/content/v2.0/reference/cli/influx/write/_index.md @@ -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` | diff --git a/content/v2.0/reference/cli/influx/write/dryrun.md b/content/v2.0/reference/cli/influx/write/dryrun.md new file mode 100644 index 000000000..728c4f89e --- /dev/null +++ b/content/v2.0/reference/cli/influx/write/dryrun.md @@ -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 %}} diff --git a/content/v2.0/write-data/_index.md b/content/v2.0/write-data/_index.md index 34ab545b4..55bf190c5 100644 --- a/content/v2.0/write-data/_index.md +++ b/content/v2.0/write-data/_index.md @@ -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 diff --git a/layouts/partials/article/related.html b/layouts/partials/article/related.html index 7817ad286..3dc5ff2ea 100644 --- a/layouts/partials/article/related.html +++ b/layouts/partials/article/related.html @@ -3,7 +3,7 @@