chore(v3): add Telegraf examples, configuration, dual-write (#4929)
- Add Telegraf examples to get-started/write-data (#4918) - Update instructions for saving the token, using secret store - Instructions for setting and using environment variables, add Windows examples - For Dedicated, make manual-config the config defaultpull/4973/head
parent
309b682060
commit
1b2dfe7e2f
|
|
@ -26,7 +26,8 @@ to perform administrative actions.
|
|||
#### Store secure tokens in a secret store
|
||||
|
||||
Token strings are returned _only_ on token creation.
|
||||
We recommend storing database tokens in a secure secret store.
|
||||
We recommend storing database tokens in a **secure secret store**.
|
||||
For example, see how to [authenticate Telegraf using tokens in your OS secret store](https://github.com/influxdata/telegraf/tree/master/plugins/secretstores/os).
|
||||
|
||||
#### Tokens cannot be updated
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ If a new token doesn't immediately work for querying or writing, wait a few seco
|
|||
#### Store secure tokens in a secret store
|
||||
|
||||
Token strings are returned _only_ on token creation.
|
||||
We recommend storing database tokens in a secure secret store.
|
||||
We recommend storing database tokens in a **secure secret store**.
|
||||
For example, see how to [authenticate Telegraf using tokens in your OS secret store](https://github.com/influxdata/telegraf/tree/master/plugins/secretstores/os).
|
||||
{{% /note %}}
|
||||
|
||||
#### Example token creation commands
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ be used to perform actions outlined in this tutorial.
|
|||
**InfluxDB Cloud Dedicated requires authentication** using
|
||||
[tokens](/influxdb/cloud-dedicated/security/tokens/).
|
||||
|
||||
There a two types of tokens:
|
||||
There are two types of tokens:
|
||||
|
||||
- **Database token**: A token that grants read and write access to InfluxDB
|
||||
databases.
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ menu:
|
|||
weight: 101
|
||||
metadata: [1 / 3]
|
||||
related:
|
||||
- /influxdb/cloud-dedicated/admin/buckets/
|
||||
- /influxdb/cloud-dedicated/reference/cli/influx/
|
||||
- /influxdb/cloud-dedicated/admin/databases/
|
||||
- /influxdb/cloud-dedicated/reference/cli/influxctl/
|
||||
- /influxdb/cloud-dedicated/reference/api/
|
||||
---
|
||||
|
||||
|
|
@ -25,96 +25,187 @@ you need is in place.
|
|||
- [Download, install, and configure the influxctl CLI](#download-install-and-configure-the-influxctl-cli)
|
||||
- [Create a database](#create-a-database)
|
||||
- [Create a database token](#create-a-database-token)
|
||||
- [Configure authentication credentials](#configure-authentication-credentials)
|
||||
|
||||
## Request an InfluxDB Cloud Dedicated cluster
|
||||
1. **Request an InfluxDB Cloud Dedicated cluster**.
|
||||
<span id="request-an-influxdb-cloud-dedicated-cluster"></span>
|
||||
|
||||
[Contact the InfluxData Sales team]({{< dedicated-link >}}) to request an
|
||||
InfluxDB Cloud Dedicated cluster.
|
||||
When your cluster is deployed, your InfluxData account representative provides
|
||||
the following:
|
||||
[Contact the InfluxData Sales team]({{< dedicated-link >}}) to request an
|
||||
InfluxDB Cloud Dedicated cluster.
|
||||
When your cluster is deployed, your InfluxData account representative provides
|
||||
the following:
|
||||
|
||||
- An **Auth0 login** to authenticate access to your cluster
|
||||
- Your InfluxDB Cloud Dedicated **account ID**
|
||||
- Your InfluxDB Cloud Dedicated **cluster ID**
|
||||
- Your InfluxDB Cloud Dedicated **cluster URL**
|
||||
|
||||
|
||||
2. **Download, install, and configure the influxctl CLI**.
|
||||
<span id="download-install-and-configure-the-influxctl-cli"></span>
|
||||
|
||||
- An **Auth0 login** to authenticate access to your cluster
|
||||
- Your InfluxDB Cloud Dedicated **account ID**
|
||||
- Your InfluxDB Cloud Dedicated **cluster ID**
|
||||
- Your InfluxDB Cloud Dedicated **cluster URL**
|
||||
|
||||
## Download, install, and configure the influxctl CLI
|
||||
|
||||
The [`influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/)
|
||||
provides a simple way to manage your InfluxDB Cloud Dedicated cluster from a
|
||||
command line. It lets you perform administrative tasks such as managing
|
||||
databases and tokens.
|
||||
The [`influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/)
|
||||
provides a simple way to manage your InfluxDB Cloud Dedicated cluster from a
|
||||
command line. It lets you perform administrative tasks such as managing
|
||||
databases and tokens.
|
||||
|
||||
1. **Download the `influxctl` CLI**.
|
||||
1. **Download the `influxctl` CLI**.
|
||||
|
||||
_[Contact InfluxData Support](https://support.influxdata.com) for
|
||||
information about downloading and installing the `influxctl` CLI._
|
||||
_[Contact InfluxData Support](https://support.influxdata.com) for
|
||||
information about downloading and installing the `influxctl` CLI._
|
||||
|
||||
2. **Create a connection profile and provide your InfluxDB Cloud Dedicated connection credentials**.
|
||||
The `influxctl` CLI uses [connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)
|
||||
to connect to and authenticate with your InfluxDB Cloud Dedicated cluster.
|
||||
2. **Create a connection profile and provide your InfluxDB Cloud Dedicated connection credentials**.
|
||||
|
||||
To create a connection profile, run `influxctl init` to start an interactive
|
||||
prompt that creates and stores a connection profile.
|
||||
The `influxctl` CLI uses [connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)
|
||||
to connect to and authenticate with your InfluxDB Cloud Dedicated cluster.
|
||||
|
||||
```sh
|
||||
influxctl init
|
||||
```
|
||||
To create a connection profile, run `influxctl init` to start an interactive
|
||||
prompt that creates and stores a connection profile.
|
||||
|
||||
Provide the following required credentials:
|
||||
```sh
|
||||
influxctl init
|
||||
```
|
||||
|
||||
- Account ID
|
||||
- Cluster ID
|
||||
Provide the following required credentials:
|
||||
|
||||
_For more information about `influxctl` profiles, see
|
||||
[Configure connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)_.
|
||||
- Account ID
|
||||
- Cluster ID
|
||||
|
||||
## Create a database
|
||||
_For more information about `influxctl` profiles, see
|
||||
[Configure connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)_.
|
||||
|
||||
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||
to create a database. You can use an existing database or create a new one
|
||||
specifically for this getting started tutorial.
|
||||
_Examples in this getting started tutorial assume a database named **"get-started"**._
|
||||
|
||||
{{% note %}}
|
||||
#### Authenticate with your cluster
|
||||
3. **Create a database**.
|
||||
<span id="create-a-database"></span>
|
||||
|
||||
|
||||
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||
to create a database. You can use an existing database or create a new one
|
||||
specifically for this getting started tutorial.
|
||||
_Examples in this getting started tutorial assume a database named **"get-started"**._
|
||||
|
||||
{{% note %}}
|
||||
#### Authenticate with your cluster
|
||||
|
||||
The first time you run an `influxctl` CLI command, you are directed
|
||||
to login to **Auth0**. Once logged in, Auth0 issues a short-lived (1 hour)
|
||||
management token for the `influxctl` CLI that grants administrative access
|
||||
to your InfluxDB Cloud Dedicated cluster.
|
||||
{{% /note %}}
|
||||
|
||||
Provide the following:
|
||||
|
||||
- Database name.
|
||||
- _Optional:_ Database [retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||
as a duration value. If no retention period is specified, the default is infinite.
|
||||
|
||||
The first time you run an `influxctl` CLI command, you are directed
|
||||
to login to **Auth0**. Once logged in, Auth0 issues a short-lived (1 hour)
|
||||
management token for the `influxctl` CLI that grants administrative access
|
||||
to your InfluxDB Cloud Dedicated cluster.
|
||||
{{% /note %}}
|
||||
|
||||
Provide the following:
|
||||
|
||||
- Database name.
|
||||
- _(Optional)_ Database [retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||
as a duration value.
|
||||
If no retention period is specified, the default is infinite.
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- Using tabs-wrapper to preserve indent and prevent code-placeholders and code-callout shortcodes from breaking indent and adding terminating lines -->
|
||||
|
||||
{{% code-placeholders "get-started|1y" %}}
|
||||
```sh
|
||||
influxctl database create \
|
||||
--retention-period 1y \
|
||||
get-started
|
||||
influxctl database create --retention-period 1y get-started
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
## Create a database token
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/)
|
||||
to create a database token with read and write permissions for your database.
|
||||
|
||||
Provide the following:
|
||||
4. **Create a database token**. <span id="create-a-database-token"></span>
|
||||
|
||||
- Permission grants
|
||||
- `--read-database`: Grants read access to a database
|
||||
- `--write-database` Grants write access to a database
|
||||
- Token description
|
||||
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/)
|
||||
to create a database token with read and write permissions for your database.
|
||||
|
||||
Provide the following:
|
||||
|
||||
- Permission grants
|
||||
- `--read-database`: Grants read access to a database
|
||||
- `--write-database` Grants write access to a database
|
||||
- Token description
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- Using tabs-wrapper to preserve indent and prevent code-placeholders and code-callout shortcodes from breaking indent and adding terminating lines -->
|
||||
|
||||
{{% code-placeholders "get-started" %}}
|
||||
```sh
|
||||
influxctl token create \
|
||||
--read-database get-started \
|
||||
--write-database get-started \
|
||||
"Read/write token for get-started database"
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
The command returns the token ID and the token string.
|
||||
Store the token string in a safe place.
|
||||
You'll need it later.
|
||||
**This is the only time the token string is available in plain text.**
|
||||
|
||||
{{% note %}}
|
||||
#### Store secure tokens in a secret store
|
||||
|
||||
Token strings are returned _only_ on token creation.
|
||||
We recommend storing database tokens in a **secure secret store**.
|
||||
For example, see how to [authenticate Telegraf using tokens in your OS secret store](https://github.com/influxdata/telegraf/tree/master/plugins/secretstores/os).
|
||||
{{% /note %}}
|
||||
|
||||
5. **Configure authentication credentials**.
|
||||
<span id="configure-authentication-credentials"></span>
|
||||
|
||||
Code samples in later sections assume you assigned the token string to an
|
||||
`INFLUX_TOKEN` environment variable--for example:
|
||||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[MacOS and Linux](#)
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /tabs %}}
|
||||
{{% tab-content %}}
|
||||
<!-- Using tabs-wrapper b/c code-tabs-wrapper breaks here. -->
|
||||
<!-- BEGIN MACOS/LINUX -->
|
||||
|
||||
{{% code-placeholders "DATABASE_TOKEN" %}}
|
||||
```sh
|
||||
export INFLUX_TOKEN=DATABASE_TOKEN
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!-- END MACOS/LINUX -->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!-- BEGIN POWERSHELL -->
|
||||
|
||||
{{% code-placeholders "DATABASE_TOKEN" %}}
|
||||
```powershell
|
||||
$env:INFLUX_TOKEN = "DATABASE_TOKEN"
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
|
||||
<!-- END POWERSHELL -->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!-- BEGIN CMD -->
|
||||
|
||||
{{% code-placeholders "DATABASE_TOKEN" %}}
|
||||
```sh
|
||||
set INFLUX_TOKEN=DATABASE_TOKEN
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!-- END CMD -->
|
||||
{{% /tab-content %}}
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
Replace `DATABASE_TOKEN` with your [database token](#create-a-database-token) string.
|
||||
|
||||
{{< page-nav prev="/influxdb/cloud-dedicated/get-started/" next="/influxdb/cloud-dedicated/get-started/write/" keepTab=true >}}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ title: Get started writing data
|
|||
seotitle: Write data | Get started with InfluxDB Cloud Dedicated
|
||||
list_title: Write data
|
||||
description: >
|
||||
Get started writing data to InfluxDB Cloud Dedicated by learning about line protocol
|
||||
and using tools like the InfluxDB API and Telegraf.
|
||||
Get started writing data to InfluxDB by learning about line protocol
|
||||
and using tools like Telegraf, client libraries, and the InfluxDB API.
|
||||
menu:
|
||||
influxdb_cloud_dedicated:
|
||||
name: Write data
|
||||
|
|
@ -19,17 +19,16 @@ related:
|
|||
- /{{< latest "telegraf" >}}/
|
||||
---
|
||||
|
||||
InfluxDB provides many different options for ingesting or writing data, including
|
||||
the following:
|
||||
This tutorial walks you through the fundamental of creating **line protocol** data and writing it to InfluxDB.
|
||||
|
||||
- [InfluxDB HTTP API (v1 and v2)](/influxdb/cloud-dedicated/primers/api/)
|
||||
- [`influx` CLI (v1 and v2)](/influxdb/cloud-dedicated/reference/cli/influx/)
|
||||
- [Telegraf](/{{< latest "telegraf" >}}/)
|
||||
- [InfluxDB client libraries](/influxdb/cloud-dedicated/reference/client-libraries/)
|
||||
- etc.
|
||||
InfluxDB provides many different options for ingesting or writing data, including the following:
|
||||
|
||||
This tutorial walks you through the fundamental of using **line protocol** to write
|
||||
data to InfluxDB. If using tools like Telegraf or InfluxDB client libraries, they can
|
||||
- InfluxDB HTTP API (v1 and v2)
|
||||
- `influx` CLI (v1 and v2)
|
||||
- Telegraf
|
||||
- InfluxDB client libraries
|
||||
|
||||
If using tools like Telegraf or InfluxDB client libraries, they can
|
||||
build the line protocol for you, but it's good to understand how line protocol works.
|
||||
|
||||
## Line protocol
|
||||
|
|
@ -45,7 +44,7 @@ Each line of line protocol contains the following elements:
|
|||
|
||||
{{< req type="key" >}}
|
||||
|
||||
- {{< req "\*" >}} **measurement**: String that identifies the [measurement]() to store the data in.
|
||||
- {{< req "\*" >}} **measurement**: String that identifies the [measurement](/influxdb/cloud-dedicated/reference/glossary/#measurement) to store the data in.
|
||||
- **tag set**: Comma-delimited list of key value pairs, each representing a tag.
|
||||
Tag keys and values are unquoted strings. _Spaces, commas, and equal characters must be escaped._
|
||||
- {{< req "\*" >}} **field set**: Comma-delimited list of key value pairs, each representing a field.
|
||||
|
|
@ -135,19 +134,106 @@ home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
|||
|
||||
## Write line protocol to InfluxDB
|
||||
|
||||
Use the **InfluxDB v2 HTTP API** or **InfluxDB client libraries** to write the
|
||||
line protocol above to InfluxDB.
|
||||
The following examples show how to use the **Python** and **Go** client libraries to write line protocol.
|
||||
The following examples show how to write the
|
||||
[sample data](#home-sensor-data-line-protocol), already in line protocol format,
|
||||
to an InfluxDB Cloud Dedicated database.
|
||||
|
||||
To learn more about available tools and options, see [Write data](influxdb/cloud-serverless/write-data/).
|
||||
|
||||
{{% note %}}
|
||||
All API, cURL, and client library examples in this getting started tutorial assume your InfluxDB
|
||||
**host**, **organization**, **url**, and **token** are provided by
|
||||
[environment variables](/influxdb/cloud-dedicated/get-started/setup/?t=InfluxDB+API#configure-authentication-credentials).
|
||||
{{% /note %}}
|
||||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[InfluxDB API](#)
|
||||
[Telegraf](#)
|
||||
[cURL](#)
|
||||
[Python](#)
|
||||
[Go](#)
|
||||
[Node.js](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN API CONTENT ----------------------------->
|
||||
<!------------------------------- BEGIN TELEGRAF CONTENT ------------------------------>
|
||||
Use [Telegraf](/{{< latest "telegraf" >}}/) to consume line protocol,
|
||||
and then write it to {{< cloud-name >}}.
|
||||
|
||||
1. If you haven't already, follow the instructions to [download and install Telegraf](/{{< latest "telegraf" >}}/install/).
|
||||
|
||||
2. Copy and save the [home sensor data sample](#home-sensor-data-line-protocol) to a file on your local system--for example, `home.lp`.
|
||||
|
||||
3. Run the following command to generate a Telegraf configuration file (`./telegraf.conf`) that enables the `inputs.file` and `outputs.influxdb_v2` plugins:
|
||||
|
||||
```sh
|
||||
telegraf --sample-config \
|
||||
--input-filter file \
|
||||
--output-filter influxdb_v2 \
|
||||
> telegraf.conf
|
||||
```
|
||||
|
||||
4. In your editor, open `./telegraf.conf` and configure the following:
|
||||
|
||||
- **`file` input plugin**: In the `[[inputs.file]].files` list, replace `"/tmp/metrics.out"` with your sample data filename.
|
||||
If Telegraf can't find a file when started, it stops processing and exits.
|
||||
|
||||
```toml
|
||||
[[inputs.file]]
|
||||
## Files to parse each interval. Accept standard unix glob matching rules,
|
||||
## as well as ** to match recursive files and directories.
|
||||
files = ["home.lp"]
|
||||
```
|
||||
|
||||
- **`output-influxdb_v2` output plugin**: In the `[[outputs.influxdb_v2]]` section, replace the default values with the following configuration for your InfluxDB Cloud Dedicated cluster:
|
||||
|
||||
```toml
|
||||
[[outputs.influxdb_v2]]
|
||||
# InfluxDB Cloud Dedicated cluster URL
|
||||
urls = ["${INFLUX_URL}"]
|
||||
|
||||
# INFLUX_TOKEN is an environment variable you assigned to your database token
|
||||
token = "${INFLUX_TOKEN}"
|
||||
|
||||
# An empty string (InfluxDB ignores this parameter)
|
||||
organization = ""
|
||||
|
||||
# Database name
|
||||
bucket = "get-started"
|
||||
```
|
||||
|
||||
The example configuration uses the following InfluxDB credentials:
|
||||
|
||||
- **`urls`**: an array containing your **`INFLUX_URL`** environment variable
|
||||
- **`token`**: your **`INFLUX_TOKEN`** environment variable
|
||||
- **`organization`**: an empty string (InfluxDB ignores this parameter)
|
||||
- **`bucket`**: the name of the database to write to
|
||||
|
||||
5. To write the data, start the `telegraf` daemon with the following options:
|
||||
|
||||
- `--config`: Specifies the filepath of the configuration file.
|
||||
- `--once`: Runs a single Telegraf collection cycle for the configured inputs and outputs, and then exits.
|
||||
|
||||
Enter the following command in your terminal:
|
||||
|
||||
```sh
|
||||
telegraf --once --config ./telegraf.conf
|
||||
```
|
||||
|
||||
If the write is successful, the output is similar to the following:
|
||||
|
||||
```plaintext
|
||||
2023-05-31T20:09:08Z D! [agent] Starting service inputs
|
||||
2023-05-31T20:09:19Z D! [outputs.influxdb_v2] Wrote batch of 52 metrics in 348.008167ms
|
||||
2023-05-31T20:09:19Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
|
||||
```
|
||||
|
||||
Telegraf and its plugins provide many options for reading and writing data.
|
||||
To learn more, see how to [use Telegraf to write data](/influxdb/cloud-dedicated/write-data/use-telegraf/).
|
||||
|
||||
<!------------------------------- END TELEGRAF CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN cURL CONTENT ----------------------------->
|
||||
|
||||
To write data to InfluxDB Cloud Dedicated using the InfluxDB v2 HTTP API, send a
|
||||
request to the InfluxDB API `/api/v2/write` endpoint using the `POST` request method.
|
||||
|
|
@ -170,17 +256,12 @@ With the InfluxDB Cloud Dedicated v2 API `/api/v2/write` endpoint, `Authorizatio
|
|||
{{% /note %}}
|
||||
|
||||
The following example uses cURL and the InfluxDB v2 API to write line protocol
|
||||
to InfluxDB Cloud dedicated:
|
||||
to InfluxDB:
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
```sh
|
||||
export INFLUX_HOST=https://cluster-id.influxdb.io
|
||||
export INFLUX_TOKEN=DATABASE_TOKEN
|
||||
|
||||
DATABASE_NAME=get-started
|
||||
|
||||
curl --request POST \
|
||||
"$INFLUX_HOST/api/v2/write?bucket=$DATABASE_NAME&precision=s" \
|
||||
"$INFLUX_HOST/api/v2/write?bucket=get-started&precision=s" \
|
||||
--header "Authorization: Bearer $INFLUX_TOKEN" \
|
||||
--header "Content-Type: text/plain; charset=utf-8" \
|
||||
--header "Accept: application/json" \
|
||||
|
|
@ -214,13 +295,15 @@ home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
|||
"
|
||||
```
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
<!------------------------------ END API CONTENT ------------------------------>
|
||||
<!------------------------------ END cURL CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!---------------------------- BEGIN PYTHON CONTENT --------------------------->
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
|
||||
To write data to InfluxDB Cloud Dedicated using Python, use the
|
||||
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||
[`influxdb_client_3` module](https://github.com/InfluxCommunity/influxdb3-python).
|
||||
The following steps include setting up a Python virtual environment to scope
|
||||
dependencies to your current project.
|
||||
|
||||
|
|
@ -241,75 +324,91 @@ dependencies to your current project.
|
|||
|
||||
- `pyarrow`
|
||||
- `flightsql-dbapi`
|
||||
- `pyinflux3`
|
||||
- `influxdb3-client`
|
||||
|
||||
```python
|
||||
pip install pyarrow flightsql-dbapi pyinflux3
|
||||
pip install pyarrow flightsql-dbapi influxdb3-client
|
||||
```
|
||||
|
||||
4. Build your python script to write the [sample line protocol](#home-sensor-data-line-protocol)
|
||||
to InfluxDB. _Save the script to a file and run `python SCRIPT_NAME` or run `python` to write and execute the script using the interactive shell._
|
||||
4. Create a file for your code--for example, `write.py`.
|
||||
|
||||
1. Import the `InfluxDBClient3` object from the `influxdb_client_3` module.
|
||||
2. Use the `InfluxDBClient3` constructor to instantiate an InfluxDB Client.
|
||||
The example below assigns it to the `client` variable.
|
||||
Provide the following credentials:
|
||||
```sh
|
||||
touch write.py
|
||||
```
|
||||
|
||||
- **host**: InfluxDB Cloud Dedicated cluster URL (without protocol or trailing slash)
|
||||
- **org**: _Leave as an empty string_ (InfluxDB Cloud Dedicated ignores `org`, but the client requires the parameter)
|
||||
- **token**: Database token with write access to the target database
|
||||
- **database**: Database name to write to
|
||||
5. Inside of `write.py`, enter the following sample code:
|
||||
|
||||
```py
|
||||
from influxdb_client_3 import InfluxDBClient3
|
||||
|
||||
# INFLUX_TOKEN is an environment variable you assigned to your
|
||||
# database token value.
|
||||
token = os.getenv('INFLUX_TOKEN')
|
||||
|
||||
# host is the URL without protocol or trailing slash
|
||||
client = InfluxDBClient3(
|
||||
host='cluster-id.influxdb.io',
|
||||
org='',
|
||||
token=token,
|
||||
database='get-started'
|
||||
)
|
||||
|
||||
lines = [
|
||||
"home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600",
|
||||
"home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600",
|
||||
"home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400",
|
||||
"home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000",
|
||||
"home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600",
|
||||
"home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800",
|
||||
"home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400",
|
||||
"home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400",
|
||||
"home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000",
|
||||
"home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000",
|
||||
"home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600",
|
||||
"home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200"
|
||||
]
|
||||
|
||||
client.write(lines,write_precision='s')
|
||||
```
|
||||
|
||||
The sample does the following:
|
||||
|
||||
1. Imports the `InfluxDBClient3` object from the `influxdb_client_3` module.
|
||||
2. Calls the `InfluxDBClient3()` constructor to instantiate an InfluxDB client
|
||||
configured with the following credentials:
|
||||
|
||||
- **host**: InfluxDB Cloud Dedicated cluster hostname (URL without protocol or trailing slash)
|
||||
- **org**: an empty or arbitrary string (InfluxDB ignores this parameter)
|
||||
- **token**: InfluxDB API token with write access to the target database
|
||||
- **database**: InfluxDB Cloud Dedicated database name
|
||||
|
||||
3. Use the `client.write` method to write the line protocol to the **get-started**
|
||||
database. Provide the following:
|
||||
|
||||
- **Line protocol** as an array of strings where each element is an individual
|
||||
line of line protocol.
|
||||
- **`write_precision` option** to specify the timestamp precision as
|
||||
seconds (`s`).
|
||||
3. Defines a list of line protocol strings where each string represents a data record.
|
||||
4. Calls the `client.write()` method with the line protocol record list and write options.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
**Because the timestamps in the sample line protocol are in second
|
||||
precision, the example passes the `write_precision='s'` option
|
||||
to set the timestamp precision to seconds.**
|
||||
|
||||
```py
|
||||
from influxdb_client_3 import InfluxDBClient3
|
||||
|
||||
client = InfluxDBClient3(
|
||||
host="cluster-id.influxdb.io",
|
||||
org="",
|
||||
token="DATABASE_TOKEN",
|
||||
database="get-started"
|
||||
)
|
||||
|
||||
client.write([
|
||||
"home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600",
|
||||
"home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600",
|
||||
"home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400",
|
||||
"home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000",
|
||||
"home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600",
|
||||
"home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800",
|
||||
"home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400",
|
||||
"home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400",
|
||||
"home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000",
|
||||
"home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000",
|
||||
"home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600",
|
||||
"home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200"],
|
||||
write_precision='s'
|
||||
)
|
||||
```
|
||||
6. To execute the module and write line protocol to your InfluxDB Cloud Dedicated
|
||||
database, enter the following command in your terminal:
|
||||
|
||||
```sh
|
||||
python write.py
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
|
|
@ -317,155 +416,298 @@ client.write([
|
|||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN GO CONTENT ------------------------------>
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
To write data to InfluxDB Cloud Dedicated using Go, use the
|
||||
[influxdb-client-go module](https://github.com/influxdata/influxdb-client-go).
|
||||
|
||||
1. Create a new go module in your project directory.
|
||||
|
||||
1. Create a new module directory and navigate into it.
|
||||
2. Initialize a new Go module in the current working directory.
|
||||
3. Create a `write.go` file.
|
||||
1. Inside of your project directory, create a new module directory and navigate into it.
|
||||
|
||||
```sh
|
||||
mkdir influxdb_go_client && cd $_
|
||||
```
|
||||
|
||||
2. Initialize a new Go module in the directory.
|
||||
|
||||
```sh
|
||||
go mod init influxdb_go_client
|
||||
```
|
||||
|
||||
3. Create a file for your code--for example, `write.go`.
|
||||
|
||||
```sh
|
||||
touch write.go
|
||||
```
|
||||
|
||||
2. Inside of `write.go` instantiate an InfluxDB write client to write the
|
||||
[line protocol above](#home-sensor-data-line-protocol) to InfluxDB.
|
||||
4. Inside of `write.go`, enter the following sample code:
|
||||
|
||||
1. Import the following packages
|
||||
```go
|
||||
package main
|
||||
|
||||
- `context`
|
||||
- `fmt`
|
||||
- `log`
|
||||
- `os`
|
||||
- `time`
|
||||
- `github.com/influxdata/influxdb-client-go/v2` aliased as `influxdb2`
|
||||
|
||||
2. Create a `dbWrite` function.
|
||||
3. In the `dbWrite` function, use `influxdb2.NewClientWithOptions` to
|
||||
create a `writeClient` that accepts write options.
|
||||
The write client requires the following credentials:
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
// Write line protocol data to InfluxDB
|
||||
func dbWrite(ctx context.Context) error {
|
||||
|
||||
// INFLUX_URL is an environment variable you assigned to your
|
||||
// cluster URL.
|
||||
url := os.Getenv("INFLUX_URL")
|
||||
|
||||
// INFLUX_TOKEN is an environment variable you assigned to your
|
||||
// database token value.
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
client := influxdb2.NewClientWithOptions(url,
|
||||
token,
|
||||
influxdb2.DefaultOptions().SetPrecision(time.Second))
|
||||
|
||||
// Define write API
|
||||
org := "ignored"
|
||||
bucket := "get-started"
|
||||
writeAPI := client.WriteAPIBlocking(org, bucket)
|
||||
|
||||
// Define line protocol records to write.
|
||||
// Use a raw string literal (denoted by backticks)
|
||||
// to preserve backslashes and prevent interpretation
|
||||
// of escape sequences--for example, escaped spaces in tag values.
|
||||
lines := [...]string{
|
||||
`home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600`,
|
||||
`home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600`,
|
||||
`home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400`,
|
||||
`home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800`,
|
||||
`home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400`,
|
||||
`home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000`,
|
||||
`home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000`,
|
||||
`home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600`,
|
||||
`home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200`,
|
||||
}
|
||||
|
||||
// Iterate over the lines array and write each line
|
||||
// separately to InfluxDB
|
||||
|
||||
for _, lp := range lines {
|
||||
err := writeAPI.WriteRecord(context.Background(), lp)
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing line protocol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Data has been written successfully.")
|
||||
client.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Module main function
|
||||
func main() {
|
||||
if err := dbWrite(context.Background()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The sample does the following:
|
||||
|
||||
1. Imports required packages.
|
||||
|
||||
2. Defines a `dbWrite()` function that does the following:
|
||||
|
||||
- **url**: InfluxDB Cloud Dedicated cluster URL
|
||||
- **token**: [Database token](/influxdb/cloud-dedicated/admin/tokens/)
|
||||
with write access to the **get-started** database.
|
||||
_For security reasons, we recommend setting this as an environment
|
||||
variable rather than including the raw token string._
|
||||
1. Calls the `influxdb2.NewClientWithOptions()` with InfluxDB URL,
|
||||
database token, and options to create client.
|
||||
|
||||
Because the timestamps in the line protocol are in second
|
||||
precision, **use `SetPrecision(time.Second)` to define the write precision option**.
|
||||
**Because the timestamps in the sample line protocol are in second
|
||||
precision, the example passes `DefaultOptions.SetPrecision(time.Second)`
|
||||
for the `precision` option in order to set the timestamp precision to
|
||||
seconds.**
|
||||
|
||||
2. Calls the `writeClient.WriteAPIBlocking()` method to
|
||||
create a `writeAPI` client configured to write to the database
|
||||
(the method requires an `org` argument, but InfluxDB ignores it).
|
||||
|
||||
4. Use `writeClient.WriteAPIBlocking` to define a `writeAPI`.
|
||||
The write API requires the following credentials:
|
||||
|
||||
- **bucket**: InfluxDB database name.
|
||||
3. Defines an array of line protocol strings where each string
|
||||
represents a data record.
|
||||
|
||||
5. Define an array of line protocol strings where each element is a single
|
||||
line of line protocol.
|
||||
4. Iterates through the array of line protocol and calls the
|
||||
write client's `WriteRecord()` method
|
||||
to write each line of line protocol separately to InfluxDB.
|
||||
|
||||
6. Iterate through the array of line protocol and use `writeAPI.WriteRecord`
|
||||
to write each line of line protocol to InfluxDB.
|
||||
|
||||
7. Define a `main` function that executes the `dbWrite` function.
|
||||
3. Defines a `main` function that executes the `dbWrite` function for the module.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
5. In your terminal, enter the following command to install the packages listed
|
||||
in `imports`:
|
||||
|
||||
```go
|
||||
package main
|
||||
```sh
|
||||
go get ./...
|
||||
```
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
func dbWrite(ctx context.Context) error {
|
||||
// Create write client
|
||||
url := "https://cluster-id.influxdb.io"
|
||||
// INFLUX_TOKEN is an environment variable you assigned to your database token value
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
writeClient := influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetPrecision(time.Second))
|
||||
|
||||
// Define write API
|
||||
org := "ignored"
|
||||
bucket := "get-started"
|
||||
writeAPI := writeClient.WriteAPIBlocking(org, bucket)
|
||||
|
||||
line := [...]string{
|
||||
`home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600`,
|
||||
`home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600`,
|
||||
`home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400`,
|
||||
`home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800`,
|
||||
`home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400`,
|
||||
`home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000`,
|
||||
`home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000`,
|
||||
`home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600`,
|
||||
`home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200`,
|
||||
}
|
||||
|
||||
for _, lp := range line {
|
||||
err := writeAPI.WriteRecord(context.Background(), lp)
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing line protocol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Data has been written successfully.")
|
||||
writeClient.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := dbWrite(context.Background()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run the following command to install the necessary packages:
|
||||
|
||||
```sh
|
||||
go get ./...
|
||||
```
|
||||
|
||||
Run `write.go` to write the line protocol to your InfluxDB Cloud Dedicated cluster:
|
||||
|
||||
```sh
|
||||
go run ./write.go
|
||||
```
|
||||
6. To execute the module and write the line protocol
|
||||
to your InfluxDB Cloud Dedicated database, enter the following command:
|
||||
|
||||
```sh
|
||||
go run ./write.go
|
||||
```
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
<!------------------------------- END GO CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!------------------------------- BEGIN NODE.JS CONTENT ----------------------->
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
To write data to InfluxDB Cloud Dedicated using Node.js, use the
|
||||
[influxdb-client-js package](https://github.com/influxdata/influxdb-client-js).
|
||||
|
||||
1. Inside of your project directory, create an NPM or Yarn package and install
|
||||
the `@influxdata/influxdb-client` InfluxDB v2 JavaScript client library.
|
||||
|
||||
```sh
|
||||
npm init -y && npm install --save @influxdata/influxdb-client
|
||||
```
|
||||
|
||||
2. Create a file for your code--for example: `write.js`.
|
||||
|
||||
```sh
|
||||
touch write.js
|
||||
```
|
||||
|
||||
3. Inside of `write.js`, enter the following sample code:
|
||||
|
||||
```js
|
||||
'use strict'
|
||||
/** @module write
|
||||
* Writes line protocol strings to InfluxDB using the Javascript client
|
||||
* library with Node.js.
|
||||
**/
|
||||
import {InfluxDB} from '@influxdata/influxdb-client';
|
||||
|
||||
/** Get credentials from environment variables. **/
|
||||
const url = process.env.INFLUX_URL;
|
||||
const token = process.env.INFLUX_TOKEN;
|
||||
const org = process.env.INFLUX_ORG;
|
||||
|
||||
/**
|
||||
* Instantiate the InfluxDB client with a configuration object.
|
||||
**/
|
||||
const influxDB = new InfluxDB({url, token});
|
||||
|
||||
/**
|
||||
* Define an array of line protocol strings to write.
|
||||
* Include an additional backslash to preserve backslashes
|
||||
* and prevent interpretation of escape sequences---for example,
|
||||
* escaped spaces in tag values.
|
||||
*/
|
||||
const lines = [
|
||||
'home,room=Living\\ Room temp=21.1,hum=35.9,co=0i 1641024000',
|
||||
'home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000',
|
||||
'home,room=Living\\ Room temp=21.4,hum=35.9,co=0i 1641027600',
|
||||
'home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600',
|
||||
'home,room=Living\\ Room temp=21.8,hum=36.0,co=0i 1641031200',
|
||||
'home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200',
|
||||
'home,room=Living\\ Room temp=22.2,hum=36.0,co=0i 1641034800',
|
||||
'home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800',
|
||||
'home,room=Living\\ Room temp=22.2,hum=35.9,co=0i 1641038400',
|
||||
'home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400',
|
||||
'home,room=Living\\ Room temp=22.4,hum=36.0,co=0i 1641042000',
|
||||
'home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000',
|
||||
'home,room=Living\\ Room temp=22.3,hum=36.1,co=0i 1641045600',
|
||||
'home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600',
|
||||
'home,room=Living\\ Room temp=22.3,hum=36.1,co=1i 1641049200',
|
||||
'home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200',
|
||||
'home,room=Living\\ Room temp=22.4,hum=36.0,co=4i 1641052800',
|
||||
'home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800',
|
||||
'home,room=Living\\ Room temp=22.6,hum=35.9,co=5i 1641056400',
|
||||
'home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400',
|
||||
'home,room=Living\\ Room temp=22.8,hum=36.2,co=9i 1641060000',
|
||||
'home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000',
|
||||
'home,room=Living\\ Room temp=22.5,hum=36.3,co=14i 1641063600',
|
||||
'home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600',
|
||||
'home,room=Living\\ Room temp=22.2,hum=36.4,co=17i 1641067200',
|
||||
'home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a write client from the getWriteApi method.
|
||||
* Provide your org and Database.
|
||||
**/
|
||||
const writeApi = influxDB.getWriteApi(org, 'get-started', 's');
|
||||
|
||||
/**
|
||||
* Write line protocol to the batch
|
||||
*/
|
||||
writeApi.writeRecords(lines);
|
||||
|
||||
/**
|
||||
* Flush pending writes from the buffer and close the write client.
|
||||
**/
|
||||
writeApi.close().then(
|
||||
() => {
|
||||
console.log('Data has been written successfully.');
|
||||
},
|
||||
(err) => {
|
||||
console.log('Error writing line protocol');
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
The sample does the following:
|
||||
|
||||
1. Calls the `new InfluxDB()` constructor to instantiate a client configured
|
||||
with the InfluxDB URL and database token.
|
||||
|
||||
2. Defines an array of line protocol strings where each string represents a data record.
|
||||
|
||||
3. Calls the client's `getWriteApi()` method to create a
|
||||
**write client** configured to write to the database
|
||||
(the method requires an `org` argument, but InfluxDB ignores it).
|
||||
|
||||
**Because the timestamps in the sample line protocol are in second
|
||||
precision, the example passes `'s'` for the `precision` option in order
|
||||
to set the timestamp precision to seconds**.
|
||||
|
||||
6. Calls the write client's `writeRecords()` method with the line protocol array
|
||||
to write the records in batches to InfluxDB.
|
||||
|
||||
7. Calls the write client's `close()` method with callback functions for success and error.
|
||||
The `close()` method sends any records remaining in the buffer,
|
||||
executes callbacks, and releases resources.
|
||||
|
||||
4. To execute the file and write the line protocol to your InfluxDB Cloud Dedicated database,
|
||||
enter the following command in your terminal:
|
||||
|
||||
```sh
|
||||
node write.js
|
||||
```
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
<!------------------------------- END NODE.JS CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
If successful, the output is the success message; otherwise, error details and the failure message.
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View the written data" %}}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ the token string.
|
|||
#### Store secure tokens in a secret store
|
||||
|
||||
Token strings are returned _only_ on token creation.
|
||||
We recommend storing database tokens in a secure secret store.
|
||||
We recommend storing database tokens in a **secure secret store**.
|
||||
{{% /note %}}
|
||||
|
||||
## Usage
|
||||
|
|
|
|||
|
|
@ -970,7 +970,7 @@ Related entries:
|
|||
A plugin-driven agent that collects, processes, aggregates, and writes metrics.
|
||||
|
||||
Related entries:
|
||||
[Telegraf plugins](/{{< latest "telegraf" >}}/plugins//),
|
||||
[Telegraf plugins](/{{< latest "telegraf" >}}/plugins/),
|
||||
[Use Telegraf to collect data](/influxdb/cloud-dedicated/write-data/telegraf/),
|
||||
|
||||
### time (data type)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Use Telegraf to write CSV data to InfluxDB Cloud Dedicated
|
||||
title: Use Telegraf to write CSV data to InfluxDB
|
||||
description: >
|
||||
Use the Telegraf `file` input plugin to read and parse CSV data into
|
||||
[line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/)
|
||||
|
|
@ -75,7 +75,7 @@ metrics from different sources and writes them to specified destinations.
|
|||
- **url**: a list (`[]`) containing your InfluxDB Cloud Dedicated cluster URL using the HTTPS
|
||||
protocol:
|
||||
|
||||
```
|
||||
```toml
|
||||
["https://cluster-id.influxdb.io"]
|
||||
```
|
||||
- **token**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with permission to write to the database.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
title: Use Telegraf to write data
|
||||
seotitle: Use the Telegraf agent to collect and write data
|
||||
weight: 101
|
||||
description: >
|
||||
Use Telegraf to collect and write data to InfluxDB.
|
||||
Create Telegraf configurations in the InfluxDB UI or manually configure Telegraf.
|
||||
aliases:
|
||||
- /influxdb/cloud-dedicated/collect-data/advanced-telegraf
|
||||
- /influxdb/cloud-dedicated/collect-data/use-telegraf
|
||||
- /influxdb/cloud-dedicated/write-data/no-code/use-telegraf/
|
||||
menu:
|
||||
influxdb_cloud_dedicated:
|
||||
name: Use Telegraf
|
||||
parent: Write data
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/
|
||||
---
|
||||
|
||||
[Telegraf](https://www.influxdata.com/time-series-platform/telegraf/) is a
|
||||
no-code data collection agent for collecting and reporting metrics.
|
||||
Its vast library of input plugins and "plug-and-play" architecture lets you quickly
|
||||
and easily collect metrics from many different sources.
|
||||
|
||||
For a list of available plugins, see [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/).
|
||||
|
||||
#### Requirements
|
||||
|
||||
- **Telegraf 1.9.2 or greater**.
|
||||
_For information about installing Telegraf, see the
|
||||
[Telegraf Installation instructions](/{{< latest "telegraf" >}}/install/)._
|
||||
|
||||
## Basic Telegraf usage
|
||||
|
||||
Telegraf is a plugin-based agent with plugins that are enabled and configured in
|
||||
your Telegraf configuration file (`telegraf.conf`).
|
||||
Each Telegraf configuration must **have at least one input plugin and one output plugin**.
|
||||
|
||||
Telegraf input plugins retrieve metrics from different sources.
|
||||
Telegraf output plugins write those metrics to a destination.
|
||||
|
||||
Use the [`outputs.influxdb_v2`](/{{< latest "telegraf" >}}/plugins/#output-influxdb_v2) plugin to write metrics collected by Telegraf to {{< cloud-name >}}.
|
||||
|
||||
```toml
|
||||
# ...
|
||||
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["https://cluster-id.influxdb.io"]
|
||||
token = "${INFLUX_TOKEN}"
|
||||
organization = ""
|
||||
bucket = "DATABASE_NAME"
|
||||
|
||||
# ...
|
||||
```
|
||||
|
||||
_See how to [Configure Telegraf](/influxdb/cloud-dedicated/write-data/use-telegraf/configure/)._
|
||||
|
||||
## Use Telegraf with InfluxDB
|
||||
|
||||
{{< children >}}
|
||||
|
||||
{{< influxdbu "telegraf-102" >}}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
---
|
||||
title: Configure Telegraf for InfluxDB
|
||||
seotitle: Configure Telegraf to write to InfluxDB
|
||||
description: >
|
||||
Telegraf is a plugin-based agent with plugins that are enabled and configured in
|
||||
your Telegraf configuration file (`telegraf.conf`).
|
||||
Update existing or create new Telegraf configurations to use the `influxdb_v2`
|
||||
output plugin to write to InfluxDB.
|
||||
Start Telegraf using the custom configuration.
|
||||
menu:
|
||||
influxdb_cloud_dedicated:
|
||||
name: Configure Telegraf
|
||||
parent: Use Telegraf
|
||||
weight: 101
|
||||
influxdb/cloud-dedicated/tags: [telegraf]
|
||||
related:
|
||||
- /{{< latest "telegraf" >}}/plugins/
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/manual-config/
|
||||
aliases:
|
||||
- /influxdb/cloud-dedicated/write-data/use-telegraf/manual-config/
|
||||
---
|
||||
|
||||
Use the Telegraf `influxdb_v2` output plugin to collect and write metrics to
|
||||
{{< cloud-name >}}.
|
||||
Learn how to enable the `influxdb_v2` output plugin in new and
|
||||
existing Telegraf configurations,
|
||||
and then start Telegraf using the custom configuration file.
|
||||
|
||||
{{% note %}}
|
||||
_View the [requirements](/influxdb/cloud-dedicated/write-data/use-telegraf#requirements)
|
||||
for using Telegraf with {{< cloud-name >}}._
|
||||
{{% /note %}}
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
- [Configure Telegraf input and output plugins](#configure-telegraf-input-and-output-plugins)
|
||||
- [Add Telegraf plugins](#add-telegraf-plugins)
|
||||
- [Enable and configure the InfluxDB v2 output plugin](#enable-and-configure-the-influxdb-v2-output-plugin)
|
||||
- [urls](#urls)
|
||||
- [token](#token)
|
||||
- [organization](#organization)
|
||||
- [bucket](#bucket)
|
||||
- [Write to InfluxDB v1.x and {{< cloud-name >}}](#write-to-influxdb-v1x-and--cloud-name-)
|
||||
- [Start Telegraf](#start-telegraf)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## Configure Telegraf input and output plugins
|
||||
|
||||
Configure Telegraf input and output plugins in the Telegraf configuration file (typically named `telegraf.conf`).
|
||||
Input plugins collect metrics.
|
||||
Output plugins define destinations where metrics are sent.
|
||||
|
||||
This guide assumes you followed [Setup instructions](/influxdb/cloud-dedicated/get-started/setup/) in the Get Started tutorial
|
||||
to set up InfluxDB and [configure authentication credentials](/influxdb/cloud-dedicated/get-started/setup/?t=Telegraf).
|
||||
|
||||
### Add Telegraf plugins
|
||||
|
||||
To add any of the available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/), follow the steps below.
|
||||
|
||||
1. Find the plugin you want to enable from the complete list of available
|
||||
[Telegraf plugins](/{{< latest "telegraf" >}}/plugins/).
|
||||
2. Click **View** to the right of the plugin name to open the plugin page on GitHub.
|
||||
For example, view the [MQTT plugin GitHub page](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/mqtt_consumer/README.md).
|
||||
3. Copy and paste the example configuration into your Telegraf configuration file
|
||||
(typically named `telegraf.conf`).
|
||||
|
||||
### Enable and configure the InfluxDB v2 output plugin
|
||||
|
||||
To send data to {{< cloud-name >}}, enable the
|
||||
[`influxdb_v2` output plugin](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md)
|
||||
in the `telegraf.conf`.
|
||||
|
||||
```toml
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["https://cluster-id.influxdb.io"]
|
||||
token = "${INFLUX_TOKEN}"
|
||||
organization = ""
|
||||
bucket = "get-started"
|
||||
```
|
||||
|
||||
The InfluxDB output plugin configuration contains the following options:
|
||||
|
||||
##### urls
|
||||
|
||||
An array of URL strings.
|
||||
To write to InfluxDB Cloud Dedicated, include your InfluxDB Cloud Dedicated cluster URL using the HTTPS protocol:
|
||||
|
||||
```toml
|
||||
["https://cluster-id.influxdb.io"]
|
||||
```
|
||||
|
||||
##### token
|
||||
|
||||
Your InfluxDB Cloud Dedicated [database token](/influxdb/cloud-dedicated/admin/tokens/) with _write_ permission to the database.
|
||||
|
||||
In the examples, **`INFLUX_TOKEN`** is an environment variable assigned to a [database token](/influxdb/cloud-dedicated/admin/tokens/) that has _write_ permission to the database.
|
||||
|
||||
##### organization
|
||||
|
||||
For {{% cloud-name %}}, set this to an empty string (`""`).
|
||||
|
||||
##### bucket
|
||||
|
||||
The name of the InfluxDB Cloud Dedicated database to write data to.
|
||||
|
||||
In the example, **`INFLUX_DATABASE`** is an environment variable assigned to the [database](/influxdb/cloud-dedicated/admin/databases/) name.
|
||||
|
||||
{{% note %}}
|
||||
##### Write to InfluxDB v1.x and {{< cloud-name >}}
|
||||
|
||||
If a Telegraf agent is already writing to an InfluxDB v1.x database,
|
||||
enabling the InfluxDB v2 output plugin will write data to both v1.x and your {{< cloud-name >}} cluster.
|
||||
{{% /note %}}
|
||||
|
||||
## Start Telegraf
|
||||
|
||||
Start the Telegraf service using the `--config` flag to specify the location of your `telegraf.conf`.
|
||||
|
||||
```sh
|
||||
telegraf --config /path/to/custom/telegraf.conf
|
||||
```
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
title: Dual write to InfluxDB OSS and InfluxDB Cloud
|
||||
description: >
|
||||
Configure Telegraf to write data to both InfluxDB OSS and InfluxDB Cloud Dedicated simultaneously.
|
||||
menu:
|
||||
influxdb_cloud_dedicated:
|
||||
name: Dual write to OSS & Cloud
|
||||
parent: Use Telegraf
|
||||
weight: 203
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/dual-write/
|
||||
---
|
||||
|
||||
If you want to back up your data in two places, or if you're migrating from InfluxDB OSS to {{< cloud-name >}},
|
||||
you may want to set up Telegraf to dual write.
|
||||
|
||||
Use Telegraf to write to both InfluxDB OSS and {{< cloud-name >}} simultaneously.
|
||||
|
||||
The sample configuration below uses:
|
||||
- The [InfluxDB v2 output plugin](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/influxdb_v2) twice: first pointing to the OSS instance and then to the {{< cloud-name >}} cluster.
|
||||
- Two different tokens, one for OSS and one for Cloud Dedicated. You'll need to configure both tokens as environment variables (see how to [Configure authentication credentials as environment variables](/influxdb/cloud-dedicated/get-started/setup/#configure-authentication-credentials)).
|
||||
|
||||
Use the configuration below to write your data to both OSS and Cloud Dedicated instances simultaneously.
|
||||
|
||||
## Sample configuration
|
||||
|
||||
```toml
|
||||
# Include any other input, processor, or aggregator plugins that you want to include in your configuration.
|
||||
|
||||
# Send data to InfluxDB OSS v2
|
||||
[[outputs.influxdb_v2]]
|
||||
## The URLs of the InfluxDB instance.
|
||||
##
|
||||
## Multiple URLs can be specified for a single cluster, only ONE of the
|
||||
## urls will be written to each interval.
|
||||
## urls exp: http://127.0.0.1:9999
|
||||
urls = ["http://localhost:8086"]
|
||||
|
||||
## OSS token for authentication.
|
||||
token = "${INFLUX_TOKEN_OSS}"
|
||||
|
||||
## Organization is the name of the organization you want to write to. It must already exist.
|
||||
organization = "ORG_NAME_OSS"
|
||||
|
||||
## Destination bucket to write to.
|
||||
bucket = "BUCKET_NAME_OSS"
|
||||
|
||||
# Send data to InfluxDB Dedicated instance
|
||||
[[outputs.influxdb_v2]]
|
||||
## The URLs of the InfluxDB Cloud instance.
|
||||
|
||||
urls = ["https://cluster-id.influxdb.io"]
|
||||
|
||||
## Cloud token for authentication.
|
||||
token = "${INFLUX_TOKEN}"
|
||||
|
||||
## For InfluxDB Cloud Dedicated, set organization to an empty string.
|
||||
organization = ""
|
||||
|
||||
## Destination bucket to write into.
|
||||
bucket = "DATABASE_NAME"
|
||||
```
|
||||
|
|
@ -3,7 +3,8 @@ title: Set up InfluxDB
|
|||
seotitle: Set up InfluxDB | Get started with InfluxDB
|
||||
list_title: Set up InfluxDB
|
||||
description: >
|
||||
Learn how to set up InfluxDB for the "Get started with InfluxDB" tutorial.
|
||||
Learn how to set up InfluxDB for the "Get started with InfluxDB" tutorial
|
||||
and for general use.
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Set up InfluxDB
|
||||
|
|
@ -27,13 +28,19 @@ aliases:
|
|||
As you get started with this tutorial, do the following to make sure everything
|
||||
you need is in place.
|
||||
|
||||
1. {{< req text="(Optional)" color="magenta" >}} **Download, install, and configure the `influx` CLI**.
|
||||
|
||||
- [_Optional:_ Download, install, and configure the influx CLI](#download-install-and-configure-the-influx-cli)
|
||||
- [Create an All Access API token](#create-an-all-access-api-token)
|
||||
- [Configure authentication credentials](#configure-authentication-credentials)
|
||||
- [_Optional:_ Create a bucket](#create-a-bucket)
|
||||
|
||||
1. {{< req text="Optional:" color="magenta" >}} **Download, install, and configure the `influx` CLI**.
|
||||
<span id="download-install-and-configure-the-influx-cli"></span>
|
||||
|
||||
The `influx` CLI provides a simple way to interact with InfluxDB from a
|
||||
command line. For detailed installation and setup instructions,
|
||||
see [Use the influx CLI](/influxdb/cloud-serverless/tools/influx-cli/).
|
||||
|
||||
2. **Create an All Access API token.**
|
||||
2. **Create an All Access API token**.
|
||||
<span id="create-an-all-access-api-token"></span>
|
||||
|
||||
1. Go to
|
||||
|
|
@ -55,10 +62,11 @@ We recommend using a password manager or a secret store to securely store
|
|||
sensitive tokens.
|
||||
{{% /note %}}
|
||||
|
||||
3. **Configure authentication credentials**. <span id="configure-authentication-credentials"></span>
|
||||
3. **Configure authentication credentials**.
|
||||
<span id="configure-authentication-credentials"></span>
|
||||
|
||||
As you go through this tutorial, interactions with InfluxDB {{< current-version >}}
|
||||
require your InfluxDB **host**, **organization name or ID**, and your **API token**.
|
||||
require your InfluxDB **URL** or **host**, **organization name or ID**, and your **API token**.
|
||||
There are different methods for providing these credentials depending on
|
||||
which client you use to interact with InfluxDB.
|
||||
|
||||
|
|
@ -71,6 +79,7 @@ use that token to interact with InfluxDB. Otherwise, use your operator token.
|
|||
{{% tabs %}}
|
||||
[InfluxDB UI](#)
|
||||
[influx CLI](#)
|
||||
[Telegraf](#)
|
||||
[InfluxDB API](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
|
|
@ -86,7 +95,7 @@ associated with the user you log in with.
|
|||
{{% tab-content %}}
|
||||
<!---------------------------- BEGIN CLI CONTENT ----------------------------->
|
||||
|
||||
There are three ways to provided authentication credentials to the `influx` CLI:
|
||||
There are three ways to provide authentication credentials to the `influx` CLI:
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "CLI connection configurations <em>(<span class=\"req\">Recommended</span>)</em>" %}}
|
||||
|
|
@ -101,13 +110,15 @@ to create a new CLI connection configuration. Include the following flags:
|
|||
- `-o, --org`: InfluxDB organization name.
|
||||
- `-t, --token`: InfluxDB API token.
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com|get-started" %}}
|
||||
```sh
|
||||
influx config create \
|
||||
--config-name get-started \
|
||||
--host-url https://cloud2.influxdata.com \
|
||||
--org <ORG_NAME> \
|
||||
--token <API_TOKEN>
|
||||
--org ORG_NAME \
|
||||
--token API_TOKEN
|
||||
```
|
||||
{{% /code-placeholders%}}
|
||||
|
||||
_For more information about CLI connection configurations, see
|
||||
[Install and use the `influx` CLI](/influxdb/cloud-serverless/tools/influx-cli/#set-up-the-influx-cli)._
|
||||
|
|
@ -121,16 +132,53 @@ uses those environment variables to populate authentication credentials.
|
|||
Set the following environment variables in your command line session:
|
||||
|
||||
- `INFLUX_HOST`: [InfluxDB Cloud Serverless region URL](/influxdb/cloud-serverless/reference/regions/).
|
||||
- `INFLUX_ORG`: InfluxDB organization name.
|
||||
- `INFLUX_ORG_ID`: InfluxDB [organization ID](/influxdb/cloud-serverless/organizations/view-orgs/#view-your-organization-id).
|
||||
- `INFLUX_ORG`: InfluxDB organization name or [ID](/influxdb/cloud-serverless/organizations/view-orgs/#view-your-organization-id).
|
||||
- `INFLUX_TOKEN`: InfluxDB API token.
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[MacOS and Linux](#)
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /code-tabs %}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN MACOS/LINUX -->
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```sh
|
||||
export INFLUX_HOST=https://cloud2.influxdata.com
|
||||
export INFLUX_ORG=<ORG_NAME>
|
||||
export INFLUX_ORG_ID=<ORG_ID>
|
||||
export INFLUX_TOKEN=<API_TOKEN>
|
||||
export INFLUX_ORG=ORG_NAME
|
||||
export INFLUX_TOKEN=API_TOKEN
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END MACOS/LINUX -->
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN POWERSHELL -->
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```sh
|
||||
$env:INFLUX_HOST = "https://cloud2.influxdata.com"
|
||||
$env:INFLUX_TOKEN = "API_TOKEN"
|
||||
$env:INFLUX_ORG = "ORG_NAME"
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END POWERSHELL -->
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN CMD -->
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```sh
|
||||
set INFLUX_HOST=https://cloud2.influxdata.com
|
||||
set INFLUX_ORG=ORG_NAME
|
||||
set INFLUX_TOKEN=API_TOKEN
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END CMD -->
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
<!-- END WINDOWS -->
|
||||
|
||||
{{% /expand %}}
|
||||
|
||||
|
|
@ -139,7 +187,7 @@ export INFLUX_TOKEN=<API_TOKEN>
|
|||
Use the following `influx` CLI flags to provide required credentials to commands:
|
||||
|
||||
- `--host`: [InfluxDB Cloud Serverless region URL](/influxdb/cloud-serverless/reference/regions/).
|
||||
- `-o`, `--org` or `--org-id`: InfluxDB organization name or
|
||||
- `-o`, `--org`: InfluxDB organization name or
|
||||
[ID](/influxdb/cloud-serverless/organizations/view-orgs/#view-your-organization-id).
|
||||
- `-t`, `--token`: InfluxDB API token.
|
||||
|
||||
|
|
@ -156,37 +204,127 @@ or by environment variables.
|
|||
<!------------------------------ END CLI CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN TELEGRAF CONTENT ------------------------->
|
||||
|
||||
Telegraf examples in this getting started tutorial assumes you assigned an
|
||||
`INFLUX_TOKEN` environment variable to your InfluxDB **token**.
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[MacOS and Linux](#)
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /code-tabs %}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN MACOS/LINUX -->
|
||||
{{% code-placeholders "API_TOKEN" %}}
|
||||
```sh
|
||||
export INFLUX_TOKEN=API_TOKEN
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END MACOS/LINUX -->
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN POWERSHELL -->
|
||||
{{% code-placeholders "API_TOKEN" %}}
|
||||
```sh
|
||||
$env:INFLUX_TOKEN = "API_TOKEN"
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END POWERSHELL -->
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN CMD -->
|
||||
{{% code-placeholders "API_TOKEN" %}}
|
||||
```sh
|
||||
set INFLUX_TOKEN=API_TOKEN
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
<!-- END CMD -->
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
<!-- END WINDOWS -->
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`API_TOKEN`**: your InfluxDB API token with sufficient permissions to your bucket
|
||||
|
||||
<!----------------------------- END TELEGRAF CONTENT ------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN API CONTENT ----------------------------->
|
||||
|
||||
cURL and client library examples in this getting started tutorial assume you have
|
||||
API (cURL and client library) examples in this getting started tutorial assume you have
|
||||
environment variables assigned to your InfluxDB credentials.
|
||||
|
||||
To assign environment variables to your credentials, enter the
|
||||
following commands into your profile settings or terminal:
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[MacOS and Linux](#)
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /code-tabs %}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN MACOS/LINUX -->
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```sh
|
||||
export INFLUX_URL=https://cloud2.influxdata.com
|
||||
export INFLUX_HOST=cloud2.influxdata.com
|
||||
export INFLUX_HOST=https://cloud2.influxdata.com
|
||||
export INFLUX_ORG=ORG_NAME
|
||||
export INFLUX_ORG_ID=ORG_ID
|
||||
export INFLUX_TOKEN=API_TOKEN
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!-- END MACOS/LINUX -->
|
||||
{{% /code-tab-content %}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN POWERSHELL -->
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```powershell
|
||||
$env:INFLUX_HOST = "https://cloud2.influxdata.com"
|
||||
$env:INFLUX_ORG = "ORG_NAME"
|
||||
$env:INFLUX_TOKEN = "API_TOKEN"
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!-- END POWERSHELL -->
|
||||
{{% /code-tab-content %}}
|
||||
{{% code-tab-content %}}
|
||||
<!-- BEGIN CMD -->
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG_NAME|https://cloud2.influxdata.com" %}}
|
||||
```sh
|
||||
set INFLUX_HOST=https://cloud2.influxdata.com
|
||||
set INFLUX_ORG=ORG_NAME
|
||||
set INFLUX_TOKEN=API_TOKEN
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!-- END CMD -->
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
<!-- END WINDOWS -->
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`ORG_NAME`**: your InfluxDB organization name
|
||||
- **`ORG_ID`**: your InfluxDB organization ID
|
||||
- **`API_TOKEN`**: your InfluxDB API token with sufficient permissions to write or query
|
||||
data in your bucket
|
||||
- **`API_TOKEN`**: your InfluxDB API token with sufficient permissions to your bucket
|
||||
|
||||
Keep the following in mind when using API clients and client libraries:
|
||||
|
||||
- InfluxDB ignores `org` and `org_id` parameters in API write and query requests,
|
||||
but some clients still require them.
|
||||
- In code samples, **host** usually refers to your
|
||||
but some clients still require the parameters.
|
||||
- Some clients use `host` to refer to your _hostname_, your
|
||||
[InfluxDB Cloud Serverless region URL](/influxdb/cloud-serverless/reference/regions/)
|
||||
(without `https://`).
|
||||
.
|
||||
without `https://`.
|
||||
|
||||
{{% note %}}
|
||||
All API, cURL, and client library examples in this getting started tutorial assume your InfluxDB
|
||||
|
|
@ -196,7 +334,7 @@ All API, cURL, and client library examples in this getting started tutorial assu
|
|||
{{% /tab-content %}}
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
6. {{< req text="(Optional)" color="magenta" >}} **Create a bucket**.
|
||||
4. {{< req text="Optional:" color="magenta" >}} **Create a bucket**.
|
||||
|
||||
You can use an existing bucket or create a new one specifically for this
|
||||
getting started tutorial. All examples in this tutorial assume a bucket named
|
||||
|
|
@ -247,11 +385,13 @@ All API, cURL, and client library examples in this getting started tutorial assu
|
|||
Supported retention periods depend on your InfluxDB Cloud Serverless plan.
|
||||
- [Connection and authentication credentials](#configure-authentication-credentials)
|
||||
|
||||
```sh
|
||||
influx bucket create \
|
||||
--name get-started \
|
||||
--retention 7d
|
||||
```
|
||||
{{% code-placeholders "get-started|7d" %}}
|
||||
```sh
|
||||
influx bucket create \
|
||||
--name get-started \
|
||||
--retention 7d
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!------------------------------ END CLI CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
|
|
@ -277,9 +417,10 @@ Include the following with your request:
|
|||
- **everySeconds**: Retention period duration in seconds.
|
||||
Supported retention periods depend on your InfluxDB Cloud Serverless plan.
|
||||
|
||||
{{% code-placeholders "\$INFLUX_TOKEN|\$INFLUX_ORG_ID|https://cloud2.influxdata.com|get-started"%}}
|
||||
```sh
|
||||
curl --request POST \
|
||||
"$INFLUX_URL/api/v2/buckets" \
|
||||
"https://cloud2.influxdata.com/api/v2/buckets" \
|
||||
--header "Authorization: Token $INFLUX_TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{
|
||||
|
|
@ -293,6 +434,8 @@ curl --request POST \
|
|||
]
|
||||
}'
|
||||
```
|
||||
{{% /code-placeholders %}}
|
||||
|
||||
<!------------------------------ END API CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{< /tabs-wrapper >}}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: Get started writing data
|
||||
seotitle: Write data | Get started with InfluxDB
|
||||
seotitle: Write data | Get started with InfluxDB Cloud Serverless
|
||||
list_title: Write data
|
||||
description: >
|
||||
Get started writing data to InfluxDB by learning about line protocol and using
|
||||
tools like the InfluxDB UI, `influx` CLI, and InfluxDB API.
|
||||
tools like the InfluxDB UI, `influx` CLI, Telegraf, client libraries, and the InfluxDB API.
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Write data
|
||||
|
|
@ -45,7 +45,7 @@ Each line of line protocol contains the following elements:
|
|||
|
||||
{{< req type="key" >}}
|
||||
|
||||
- {{< req "\*" >}} **measurement**: String that identifies the [measurement]() to store the data in.
|
||||
- {{< req "\*" >}} **measurement**: String that identifies the [measurement](/influxdb/cloud-serverless/reference/glossary/#measurement) to store the data in.
|
||||
- **tag set**: Comma-delimited list of key value pairs, each representing a tag.
|
||||
Tag keys and values are unquoted strings. _Spaces, commas, and equal characters must be escaped._
|
||||
- {{< req "\*" >}} **field set**: Comma-delimited list of key value pairs, each representing a field.
|
||||
|
|
@ -139,24 +139,24 @@ The following examples show how to write the
|
|||
[sample data](#home-sensor-data-line-protocol), already in line protocol format,
|
||||
to an InfluxDB Cloud Serverless bucket.
|
||||
|
||||
To learn more about available tools and options, see [Write data](influxdb/cloud-serverless/write-data/).
|
||||
|
||||
{{% note %}}
|
||||
All API, cURL, and client library examples in this getting started tutorial assume your InfluxDB
|
||||
**host**, **organization**, **url**, and **token** are provided by
|
||||
[environment variables](/influxdb/cloud-serverless/get-started/setup/?t=InfluxDB+API#configure-authentication-credentials).
|
||||
{{% /note %}}
|
||||
|
||||
<!-- To learn more about available tools and write options, see [Write data](influxdb/cloud-serverless/write-data/).-->
|
||||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[InfluxDB UI](#)
|
||||
[influx CLI](#)
|
||||
[Telegraf](#)
|
||||
[cURL](#)
|
||||
[Python](#)
|
||||
[Go](#)
|
||||
[Node.js](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
<!------------------------------ BEGIN UI CONTENT ----------------------------->
|
||||
|
||||
|
|
@ -236,6 +236,84 @@ home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
|||
<!------------------------------ END CLI CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!------------------------------- BEGIN TELEGRAF CONTENT ------------------------------>
|
||||
Use [Telegraf](/{{< latest "telegraf" >}}/) to consume line protocol,
|
||||
and then write it to {{< cloud-name >}}.
|
||||
|
||||
1. If you haven't already, follow the instructions to [download and install Telegraf](/{{< latest "telegraf" >}}/install/).
|
||||
|
||||
2. Copy and save the [home sensor data sample](#home-sensor-data-line-protocol) to a file on your local system--for example, `home.lp`.
|
||||
|
||||
3. Run the following command to generate a Telegraf configuration file (`./telegraf.conf`) that enables the `inputs.file` and `outputs.influxdb_v2` plugins:
|
||||
|
||||
```sh
|
||||
telegraf --sample-config \
|
||||
--input-filter file \
|
||||
--output-filter influxdb_v2 \
|
||||
> telegraf.conf
|
||||
```
|
||||
|
||||
4. In your editor, open `./telegraf.conf` and configure the following:
|
||||
|
||||
- **`file` input plugin**: In the `[[inputs.file]].files` list, replace `"/tmp/metrics.out"` with your sample data filename.
|
||||
If Telegraf can't find a file when started, it stops processing and exits.
|
||||
|
||||
```toml
|
||||
[[inputs.file]]
|
||||
## Files to parse each interval. Accept standard unix glob matching rules,
|
||||
## as well as ** to match recursive files and directories.
|
||||
files = ["home.lp"]
|
||||
```
|
||||
|
||||
- **`output-influxdb_v2` output plugin**: In the `[[outputs.influxdb_v2]]` section, replace the default values with the following configuration for your InfluxDB Cloud Dedicated cluster:
|
||||
|
||||
```toml
|
||||
[[outputs.influxdb_v2]]
|
||||
# InfluxDB Cloud Serverless region URL
|
||||
urls = ["${INFLUX_URL}"]
|
||||
|
||||
# INFLUX_TOKEN is an environment variable you assigned to your API token
|
||||
token = "${INFLUX_TOKEN}"
|
||||
|
||||
# An empty string (InfluxDB ignores this parameter)
|
||||
organization = ""
|
||||
|
||||
# Bucket name
|
||||
bucket = "get-started"
|
||||
```
|
||||
|
||||
The example configuration uses the following InfluxDB credentials:
|
||||
|
||||
- **`urls`**: an array containing your **`INFLUX_URL`** environment variable
|
||||
- **`token`**: your **`INFLUX_TOKEN`** environment variable
|
||||
- **`organization`**: an empty string (InfluxDB ignores this parameter)
|
||||
- **`bucket`**: the name of the bucket to write to
|
||||
|
||||
5. To write the data, start the `telegraf` daemon with the following options:
|
||||
|
||||
- `--config`: Specifies the filepath of the configuration file.
|
||||
- `--once`: Runs a single Telegraf collection cycle for the configured inputs and outputs, and then exits.
|
||||
|
||||
Enter the following command in your terminal:
|
||||
|
||||
```sh
|
||||
telegraf --once --config ./telegraf.conf
|
||||
```
|
||||
|
||||
If the write is successful, the output is similar to the following:
|
||||
|
||||
```plaintext
|
||||
2023-05-31T20:09:08Z D! [agent] Starting service inputs
|
||||
2023-05-31T20:09:19Z D! [outputs.influxdb_v2] Wrote batch of 52 metrics in 348.008167ms
|
||||
2023-05-31T20:09:19Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
|
||||
```
|
||||
|
||||
Telegraf and its plugins provide many options for reading and writing data.
|
||||
To learn more, see how to [use Telegraf to write data](/influxdb/cloud-serverless/write-data/use-telegraf/).
|
||||
|
||||
<!------------------------------- END TELEGRAF CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN cURL CONTENT ----------------------------->
|
||||
|
||||
To write data to InfluxDB using the InfluxDB HTTP API, send a request to
|
||||
|
|
@ -250,12 +328,11 @@ Include the following with your request:
|
|||
- **Content-Type**: text/plain; charset=utf-8
|
||||
- **Accept**: application/json
|
||||
- **Query parameters**:
|
||||
- **org**: InfluxDB organization name
|
||||
- **bucket**: InfluxDB bucket name
|
||||
- **precision**: timestamp precision (default is `ns`)
|
||||
- **Request body**: Line protocol as plain text
|
||||
|
||||
The following example uses cURL and the InfluxDB API to write line protocol
|
||||
The following example uses cURL and the InfluxDB v2 API to write line protocol
|
||||
to InfluxDB:
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
|
@ -302,7 +379,7 @@ home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
|||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
To write data to InfluxDB Cloud Serverless using Python, use the
|
||||
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||
[`influxdb_client_3` module](https://github.com/InfluxCommunity/influxdb3-python).
|
||||
The following steps include setting up a Python virtual environment to scope
|
||||
dependencies to your current project.
|
||||
|
||||
|
|
@ -323,10 +400,10 @@ dependencies to your current project.
|
|||
|
||||
- `pyarrow`
|
||||
- `flightsql-dbapi`
|
||||
- `pyinflux3`
|
||||
- `influxdb3-client`
|
||||
|
||||
```python
|
||||
pip install pyarrow flightsql-dbapi pyinflux3
|
||||
pip install pyarrow flightsql-dbapi influxdb3-client
|
||||
```
|
||||
|
||||
4. Create a file for your code--for example, `write.py`.
|
||||
|
|
@ -392,7 +469,7 @@ dependencies to your current project.
|
|||
|
||||
- **host**: InfluxDB Cloud Serverless region hostname (URL without protocol or trailing slash)
|
||||
- **org**: an empty or arbitrary string (InfluxDB ignores this parameter)
|
||||
- **token**: InfluxDB API token with write access to the target database
|
||||
- **token**: InfluxDB API token with write access to the target bucket
|
||||
- **database**: InfluxDB Cloud Serverless bucket name
|
||||
|
||||
3. Defines a list of line protocol strings where each string represents a data record.
|
||||
|
|
@ -576,7 +653,7 @@ To write data to InfluxDB Cloud Serverless using Go, use the
|
|||
<!------------------------------- BEGIN NODE.JS CONTENT ----------------------->
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
To write data to InfluxDB Cloud Serverless using Node.JS, use the
|
||||
To write data to InfluxDB Cloud Serverless using Node.js, use the
|
||||
[influxdb-client-js package](https://github.com/influxdata/influxdb-client-js).
|
||||
|
||||
1. Inside of your project directory, create an NPM or Yarn package and install
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ menu:
|
|||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/
|
||||
---
|
||||
|
||||
[Telegraf](https://www.influxdata.com/time-series-platform/telegraf/) is InfluxData's
|
||||
data collection agent for collecting and reporting metrics.
|
||||
[Telegraf](https://www.influxdata.com/time-series-platform/telegraf/) is a
|
||||
no-code data collection agent for collecting and reporting metrics.
|
||||
Its vast library of input plugins and "plug-and-play" architecture lets you quickly
|
||||
and easily collect metrics from many different sources.
|
||||
|
||||
|
|
@ -28,39 +28,30 @@ For a list of available plugins, see [Telegraf plugins](/{{< latest "telegraf" >
|
|||
|
||||
- **Telegraf 1.9.2 or greater**.
|
||||
_For information about installing Telegraf, see the
|
||||
[Telegraf Installation instructions](/{{< latest "telegraf" >}}//install/)._
|
||||
[Telegraf Installation instructions](/{{< latest "telegraf" >}}/install/)._
|
||||
|
||||
## Basic Telegraf usage
|
||||
|
||||
Telegraf is a plugin-based agent with plugins are that enabled and configured in
|
||||
Telegraf is a plugin-based agent with plugins that are enabled and configured in
|
||||
your Telegraf configuration file (`telegraf.conf`).
|
||||
Each Telegraf configuration must **have at least one input plugin and one output plugin**.
|
||||
|
||||
Telegraf input plugins retrieve metrics from different sources.
|
||||
Telegraf output plugins write those metrics to a destination.
|
||||
|
||||
Use the [`outputs.influxdb_v2`](/{{< latest "telegraf" >}}/plugins/#output-influxdb_v2) to write metrics collected by Telegraf to InfluxDB.
|
||||
Use the [`outputs.influxdb_v2`](/{{< latest "telegraf" >}}/plugins/#output-influxdb_v2) plugin to write metrics collected by Telegraf to {{< cloud-name >}}.
|
||||
|
||||
```toml
|
||||
# ...
|
||||
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["http://localhost:8086"]
|
||||
urls = ["https://cloud2.influxdata.com"]
|
||||
token = "${INFLUX_TOKEN}"
|
||||
organization = "ORG_ID"
|
||||
bucket = "BUCKET_NAME"
|
||||
|
||||
organization = ""
|
||||
bucket = "get-started"
|
||||
# ...
|
||||
```
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`ORG_ID`**: your InfluxDB Serverless [organization](/influxdb/cloud-serverless/admin/organizations/) ID.
|
||||
- **`BUCKET_NAME`**: the name of the [bucket](/influxdb/cloud-serverless/admin/buckets/) to write to.
|
||||
|
||||
In the example, **`INFLUX_TOKEN`** is an environment variable assigned to an InfluxDB API token with _write_ permission to the bucket.
|
||||
|
||||
_For more information, see [Manually configure Telegraf](/influxdb/cloud-serverless/write-data/use-telegraf/configure/manual-config/#enable-and-configure-the-influxdb-v2-output-plugin)._
|
||||
_See how to [Configure Telegraf](/influxdb/serverless/write-data/use-telegraf/configure/)._
|
||||
|
||||
## Use Telegraf with InfluxDB
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,122 @@
|
|||
---
|
||||
title: Configure Telegraf for InfluxDB
|
||||
seotitle: Configure Telegraf to write to InfluxDB
|
||||
description: >
|
||||
Telegraf is a plugin-based agent with plugins are that enabled and configured in
|
||||
Telegraf is a plugin-based agent with plugins that are enabled and configured in
|
||||
your Telegraf configuration file (`telegraf.conf`).
|
||||
Learn how to create Telegraf configuration files that work with InfluxDB.
|
||||
Update existing or create new Telegraf configurations to use the `influxdb_v2`
|
||||
output plugin to write to InfluxDB.
|
||||
Start Telegraf using the custom configuration.
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Configure Telegraf
|
||||
parent: Use Telegraf
|
||||
weight: 101
|
||||
influxdb/cloud-serverless/tags: [telegraf]
|
||||
related:
|
||||
- /{{< latest "telegraf" >}}/plugins/
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/manual-config/
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/write-data/use-telegraf/manual-config/
|
||||
---
|
||||
|
||||
Telegraf is a plugin-based agent with plugins are that enabled and configured in
|
||||
your Telegraf configuration file (`telegraf.conf`).
|
||||
Use the Telegraf `influxdb_v2` output plugin to collect and write metrics to
|
||||
{{< cloud-name >}}.
|
||||
Learn how to enable the `influxdb_v2` output plugin in new and
|
||||
existing Telegraf configurations,
|
||||
and then start Telegraf using the custom configuration file.
|
||||
|
||||
The following are options you have for creating Telegraf configuration files
|
||||
that work with InfluxDB {{< current-version >}}.
|
||||
{{% note %}}
|
||||
_View the [requirements](/influxdb/cloud-serverless/write-data/use-telegraf#requirements)
|
||||
for using Telegraf with {{< cloud-name >}}._
|
||||
{{% /note %}}
|
||||
|
||||
{{< children >}}
|
||||
<!-- TOC -->
|
||||
|
||||
- [Configure Telegraf input and output plugins](#configure-telegraf-input-and-output-plugins)
|
||||
- [Add Telegraf plugins](#add-telegraf-plugins)
|
||||
- [Enable and configure the InfluxDB v2 output plugin](#enable-and-configure-the-influxdb-v2-output-plugin)
|
||||
- [urls](#urls)
|
||||
- [token](#token)
|
||||
- [organization](#organization)
|
||||
- [bucket](#bucket)
|
||||
- [Write to InfluxDB v1.x and {{< cloud-name >}}](#write-to-influxdb-v1x-and--cloud-name-)
|
||||
- [Start Telegraf](#start-telegraf)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## Configure Telegraf input and output plugins
|
||||
|
||||
Configure Telegraf input and output plugins in the Telegraf configuration file (typically named `telegraf.conf`).
|
||||
Input plugins collect metrics.
|
||||
Output plugins define destinations where metrics are sent.
|
||||
|
||||
This guide assumes you followed [Setup instructions](/influxdb/cloud-serverless/get-started/setup/) in the Get Started guide
|
||||
to set up InfluxDB and [configure authentication credentials](/influxdb/cloud-serverless/get-started/setup/?t=Telegraf).
|
||||
|
||||
### Add Telegraf plugins
|
||||
|
||||
To add any of the available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/), follow the steps below.
|
||||
|
||||
1. Find the plugin you want to enable from the complete list of available
|
||||
[Telegraf plugins](/{{< latest "telegraf" >}}/plugins/).
|
||||
2. Click **View** to the right of the plugin name to open the plugin page on GitHub.
|
||||
For example, view the [MQTT plugin GitHub page](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/mqtt_consumer/README.md).
|
||||
3. Copy and paste the example configuration into your Telegraf configuration file
|
||||
(typically named `telegraf.conf`).
|
||||
|
||||
### Enable and configure the InfluxDB v2 output plugin
|
||||
|
||||
To send data to {{< cloud-name >}}, enable the
|
||||
[`influxdb_v2` output plugin](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md)
|
||||
in the `telegraf.conf`.
|
||||
|
||||
```toml
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["https://cloud2.influxdata.com"]
|
||||
token = "${INFLUX_TOKEN}"
|
||||
organization = ""
|
||||
bucket = "get-started"
|
||||
```
|
||||
|
||||
The InfluxDB output plugin configuration contains the following options:
|
||||
|
||||
##### urls
|
||||
|
||||
An array of URL strings.
|
||||
To write to InfluxDB Cloud Serverless, include your InfluxDB Cloud Serverless region URL using the HTTPS protocol:
|
||||
|
||||
```toml
|
||||
["https://cloud2.influxdata.com"]
|
||||
```
|
||||
|
||||
##### token
|
||||
|
||||
Your InfluxDB Cloud Serverless [API token](/influxdb/cloud-serverless/admin/tokens/) with _write_ permission to the database.
|
||||
|
||||
In the examples, `INFLUX_TOKEN` is an environment variable assigned to a [API token](/influxdb/cloud-serverless/admin/tokens/) that has _write_ permission to the database.
|
||||
|
||||
##### organization
|
||||
|
||||
For {{% cloud-name %}}, set this to an empty string (`""`).
|
||||
|
||||
##### bucket
|
||||
|
||||
The name of the InfluxDB Cloud Serverless bucket to write data to.
|
||||
|
||||
In the example, **`INFLUX_DATABASE`** is an environment variable assigned to the [database](/influxdb/cloud-serverless/admin/databases/) name.
|
||||
|
||||
{{% note %}}
|
||||
##### Write to InfluxDB v1.x and {{< cloud-name >}}
|
||||
|
||||
If a Telegraf agent is already writing to an InfluxDB v1.x database,
|
||||
enabling the InfluxDB v2 output plugin will write data to both v1.x and your {{< cloud-name >}} cluster.
|
||||
{{% /note %}}
|
||||
|
||||
## Start Telegraf
|
||||
|
||||
Start the Telegraf service using the `--config` flag to specify the location of your `telegraf.conf`.
|
||||
|
||||
```sh
|
||||
telegraf --config /path/to/custom/telegraf.conf
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
---
|
||||
title: Automatically configure Telegraf
|
||||
seotitle: Automatically configure Telegraf for InfluxDB
|
||||
description: >
|
||||
Use the InfluxDB UI to automatically generate a Telegraf configuration,
|
||||
then start Telegraf using the generated configuration file.
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/collect-data/use-telegraf/auto-config
|
||||
- /influxdb/cloud-serverless/write-data/use-telegraf/auto-config
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
parent: Configure Telegraf
|
||||
name: Automatically
|
||||
weight: 201
|
||||
related:
|
||||
- /influxdb/cloud-serverless/use-telegraf/telegraf-configs/create/
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/auto-config/
|
||||
---
|
||||
|
||||
The InfluxDB user interface (UI) can automatically create Telegraf configuration files based on user-selected Telegraf plugins.
|
||||
This article describes how to create a Telegraf configuration in the InfluxDB UI and
|
||||
start Telegraf using the generated configuration file.
|
||||
|
||||
{{< youtube M8KP7FAb2L0 >}}
|
||||
|
||||
{{% note %}}
|
||||
_View the [requirements](/influxdb/cloud-serverless/write-data/no-code/use-telegraf#requirements)
|
||||
for using Telegraf with InfluxDB {{< current-version >}}._
|
||||
{{% /note %}}
|
||||
|
||||
## Create a Telegraf configuration
|
||||
|
||||
1. Open the InfluxDB UI _(default: [localhost:8086](http://localhost:8086))_.
|
||||
2. In the navigation menu on the left, select **Data** (**Load Data**) > **Telegraf**.
|
||||
|
||||
{{< nav-icon "load data" >}}
|
||||
|
||||
4. Click **{{< icon "plus" >}} Create Configuration**.
|
||||
5. In the **Bucket** dropdown, select the bucket where Telegraf will store collected data.
|
||||
6. Select one or more of the available plugin groups and click **Continue**.
|
||||
7. Review the list of **Plugins to Configure** for configuration requirements.
|
||||
Plugins listed with a <span style="color:#32B08C">{{< icon "check" >}}</span>
|
||||
require no additional configuration.
|
||||
To configure a plugin or access plugin documentation, click the plugin name.
|
||||
5. Provide a **Telegraf Configuration Name** and an optional **Telegraf Configuration Description**.
|
||||
6. Adjust configuration settings as needed. To find configuration settings for a specific plugin, see [Telegraf plugins](/telegraf/latest/plugins/).
|
||||
7. Click **Save and Test**.
|
||||
8. The **Test Your Configuration** page provides instructions for how to start Telegraf using the generated configuration.
|
||||
_See [Start Telegraf](#start-telegraf) below for detailed information about what each step does._
|
||||
9. Once Telegraf is running, click **Listen for Data** to confirm Telegraf is successfully sending data to InfluxDB.
|
||||
Once confirmed, a **Connection Found!** message appears.
|
||||
10. Click **Finish**. Your Telegraf configuration name and the associated bucket name appears in the list of Telegraf configurations.
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
If you plan to monitor a Windows host using the System plugin, you must complete the following steps.
|
||||
|
||||
1. In the list of Telegraf configurations, double-click your
|
||||
Telegraf configuration, and then click **Download Config**.
|
||||
2. Open the downloaded Telegraf configuration file and replace the `[[inputs.processes]]` plugin with one of the following Windows plugins, depending on your Windows configuration:
|
||||
|
||||
- [`[[inputs.win_perf_counters]]`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_perf_counters)
|
||||
- [`[[inputs.win_services]]`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_services)
|
||||
|
||||
3. Save the file and place it in a directory that **telegraf.exe** can access.
|
||||
|
||||
|
||||
## Start Telegraf
|
||||
|
||||
Requests to the [InfluxDB v2 API](/influxdb/cloud/reference/api/) must include an API token.
|
||||
A token identifies specific permissions to the InfluxDB instance.
|
||||
|
||||
### Configure your token as an environment variable
|
||||
|
||||
1. Find your API token. _For information about viewing tokens, see [View tokens](/influxdb/cloud-serverless/security/tokens/view-tokens/)._
|
||||
|
||||
2. To configure your API token as the `INFLUX_TOKEN` environment variable, run the command appropriate for your operating system and command-line tool:
|
||||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[macOS or Linux](#)
|
||||
[Windows](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
```sh
|
||||
export INFLUX_TOKEN=YourAuthenticationToken
|
||||
```
|
||||
{{% /tab-content %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```sh
|
||||
$env:INFLUX_TOKEN = "YourAuthenticationToken"
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```sh
|
||||
set INFLUX_TOKEN=YourAuthenticationToken
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
{{% /tab-content %}}
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
### Start the Telegraf service
|
||||
|
||||
Start the Telegraf service using the `-config` flag to specify the location of the generated Telegraf configuration file.
|
||||
|
||||
- For Windows, the location is always a local file path.
|
||||
- For Linux and macOS, the location can be a local file path or URL.
|
||||
|
||||
Telegraf starts using the Telegraf configuration pulled from InfluxDB API.
|
||||
|
||||
{{% note %}}
|
||||
InfluxDB host URLs and ports differ between InfluxDB OSS and InfluxDB Cloud Serverless.
|
||||
For the exact command, see the Telegraf configuration **Setup Instructions** in the InfluxDB UI.
|
||||
{{% /note %}}
|
||||
|
||||
```sh
|
||||
telegraf -config http://localhost:8086/api/v2/telegrafs/0xoX00oOx0xoX00o
|
||||
```
|
||||
|
||||
## Manage Telegraf configurations
|
||||
|
||||
For more information about managing Telegraf configurations in InfluxDB, see
|
||||
[Telegraf configurations](/influxdb/cloud-serverless/write-data/use-telegraf/telegraf-configs/).
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
---
|
||||
title: Manually configure Telegraf
|
||||
seotitle: Manually configure Telegraf for InfluxDB
|
||||
description: >
|
||||
Update existing or create new Telegraf configurations to use the `influxdb_v2`
|
||||
output plugin to write to InfluxDB.
|
||||
Start Telegraf using the custom configuration.
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Manually
|
||||
parent: Configure Telegraf
|
||||
weight: 202
|
||||
influxdb/cloud-serverless/tags: [telegraf]
|
||||
related:
|
||||
- /{{< latest "telegraf" >}}/plugins//
|
||||
- /influxdb/cloud-serverless/use-telegraf/telegraf-configs/create/
|
||||
- /influxdb/cloud-serverless/use-telegraf/telegraf-configs/update/
|
||||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/manual-config/
|
||||
---
|
||||
|
||||
Use the Telegraf `influxdb_v2` output plugin to collect and write metrics into
|
||||
an InfluxDB {{< current-version >}} bucket.
|
||||
This article describes how to enable the `influxdb_v2` output plugin in new and
|
||||
existing Telegraf configurations,
|
||||
then start Telegraf using the custom configuration file.
|
||||
|
||||
{{< youtube qFS2zANwIrc >}}
|
||||
|
||||
{{% note %}}
|
||||
_View the [requirements](/influxdb/cloud-serverless/write-data/use-telegraf#requirements)
|
||||
for using Telegraf with InfluxDB {{< current-version >}}._
|
||||
{{% /note %}}
|
||||
|
||||
## Configure Telegraf input and output plugins
|
||||
|
||||
Configure Telegraf input and output plugins in the Telegraf configuration file (typically named `telegraf.conf`).
|
||||
Input plugins collect metrics.
|
||||
Output plugins define destinations where metrics are sent.
|
||||
|
||||
_See [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/) for a complete list of available plugins._
|
||||
|
||||
### Manually add Telegraf plugins
|
||||
|
||||
To manually add any of the available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins//), follow the steps below.
|
||||
|
||||
1. Find the plugin you want to enable from the complete list of available
|
||||
[Telegraf plugins](/{{< latest "telegraf" >}}/plugins/).
|
||||
2. Click **View** to the right of the plugin name to open the plugin page on GitHub.
|
||||
For example, view the [MQTT plugin GitHub page](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/mqtt_consumer/README.md).
|
||||
3. Copy and paste the example configuration into your Telegraf configuration file
|
||||
(typically named `telegraf.conf`).
|
||||
|
||||
### Enable and configure the InfluxDB v2 output plugin
|
||||
|
||||
To send data to an InfluxDB {{< current-version >}} instance, enable in the
|
||||
[`influxdb_v2` output plugin](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md)
|
||||
in the `telegraf.conf`.
|
||||
|
||||
To find an example InfluxDB v2 output plugin configuration in the UI:
|
||||
|
||||
1. In the navigation menu on the left, select **Load Data** > **Telegraf**.
|
||||
|
||||
{{< nav-icon "load data" >}}
|
||||
|
||||
2. Click **InfluxDB Output Plugin**.
|
||||
3. Click **Copy to Clipboard** to copy the example configuration or **Download Config** to save a copy.
|
||||
4. Paste the example configuration into your `telegraf.conf` and specify the options below.
|
||||
|
||||
The InfluxDB output plugin configuration contains the following options:
|
||||
|
||||
##### urls
|
||||
|
||||
An array of URLs for your InfluxDB {{< current-version >}} instances.
|
||||
See [InfluxDB Cloud Serverless regions](/influxdb/cloud-serverless/reference/regions/) for
|
||||
information about which URLs to use.
|
||||
**{{< cloud-name "short">}} requires HTTPS**.
|
||||
|
||||
##### token
|
||||
|
||||
Your InfluxDB {{< current-version >}} authorization token.
|
||||
For information about viewing tokens, see [View tokens](/influxdb/cloud-serverless/security/tokens/view-tokens/).
|
||||
|
||||
{{% note %}}
|
||||
###### Avoid storing tokens in `telegraf.conf`
|
||||
|
||||
We recommend storing your tokens by setting the `INFLUX_TOKEN` environment
|
||||
variable and including the environment variable in your configuration file.
|
||||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[macOS or Linux](#)
|
||||
[Windows](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
```sh
|
||||
export INFLUX_TOKEN=YourAuthenticationToken
|
||||
```
|
||||
{{% /tab-content %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[PowerShell](#)
|
||||
[CMD](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```sh
|
||||
$env:INFLUX_TOKEN = "YourAuthenticationToken"
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```sh
|
||||
set INFLUX_TOKEN=YourAuthenticationToken
|
||||
# Make sure to include a space character at the end of this command.
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
{{% /tab-content %}}
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
_See the [example `telegraf.conf` below](#example-influxdb_v2-configuration)._
|
||||
{{% /note %}}
|
||||
|
||||
##### organization
|
||||
|
||||
The name of the organization that owns the target bucket.
|
||||
|
||||
##### bucket
|
||||
|
||||
The name of the bucket to write data to.
|
||||
|
||||
#### Example influxdb_v2 configuration
|
||||
|
||||
The example below illustrates an `influxdb_v2` configuration.
|
||||
|
||||
```toml
|
||||
# ...
|
||||
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["http://localhost:8086"]
|
||||
token = "{$INFLUX_TOKEN}"
|
||||
organization = "example-org"
|
||||
bucket = "example-bucket"
|
||||
|
||||
# ...
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
##### Write to InfluxDB v1.x and v2.6
|
||||
|
||||
If a Telegraf agent is already writing to an InfluxDB v1.x database,
|
||||
enabling the InfluxDB v2 output plugin will write data to both v1.x and v2.6 instances.
|
||||
{{% /note %}}
|
||||
|
||||
## Add a custom Telegraf configuration to InfluxDB
|
||||
|
||||
To add a custom or manually configured Telegraf configuration to your collection
|
||||
of Telegraf configurations in InfluxDB, use the [`influx telegrafs create`](/influxdb/cloud-serverless/reference/cli/influx/telegrafs/create/)
|
||||
or [`influx telegrafs update`](/influxdb/cloud-serverless/reference/cli/influx/telegrafs/update/) commands.
|
||||
For more information, see:
|
||||
|
||||
- [Create a Telegraf configuration](/influxdb/cloud-serverless/telegraf-configs/create/#use-the-influx-cli)
|
||||
- [Update a Telegraf configuration](/influxdb/cloud-serverless/telegraf-configs/update/#use-the-influx-cli)
|
||||
|
||||
## Start Telegraf
|
||||
|
||||
Start the Telegraf service using the `--config` flag to specify the location of your `telegraf.conf`.
|
||||
|
||||
```sh
|
||||
telegraf --config /path/to/custom/telegraf.conf
|
||||
```
|
||||
|
|
@ -10,23 +10,21 @@ weight: 203
|
|||
alt_engine: /influxdb/cloud/write-data/no-code/use-telegraf/dual-write/
|
||||
---
|
||||
|
||||
If you want to back up your data in two places, or if you're migrating from OSS to Cloud, you may want to set up dual write.
|
||||
If you want to back up your data in two places, or if you're migrating from InfluxDB OSS to {{< cloud-name >}},
|
||||
you may want to set up Telegraf to dual write.
|
||||
|
||||
Use Telegraf to write to both InfluxDB OSS and InfluxDB Cloud Serverless simultaneously.
|
||||
Use Telegraf to write to both InfluxDB OSS and {{< cloud-name >}} simultaneously.
|
||||
|
||||
The sample configuration below uses:
|
||||
- The [InfluxDB v2 output plugin](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/influxdb_v2) twice: first pointing to the OSS instance and then to the cloud instance.
|
||||
- Two different tokens, one for OSS and one for Cloud. You'll need to configure both tokens as environment variables (see [Configure your token as an environment variable](/influxdb/v2.6/write-data/no-code/use-telegraf/auto-config/#configure-your-token-as-an-environment-variable).
|
||||
- The [InfluxDB v2 output plugin](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/influxdb_v2) twice: first pointing to the OSS instance and then to the {{< cloud-name >}} instance.
|
||||
- Two different tokens, one for OSS and one for Cloud Dedicated. You'll need to configure both tokens as environment variables (see how to [Configure authentication credentials as environment variables](/influxdb/cloud-serverless/get-started/setup/?t=Telegraf)).
|
||||
|
||||
Use the configuration below to write your data to both OSS and Cloud instances simultaneously.
|
||||
Use the configuration below to write your data to both OSS and Cloud Serverless instances simultaneously.
|
||||
|
||||
## Sample configuration
|
||||
|
||||
```toml
|
||||
[[inputs.cpu]]
|
||||
[[inputs.mem]]
|
||||
|
||||
## Any other inputs, processors, aggregators that you want to include in your configuration.
|
||||
# Include any other input, processor, or aggregator plugins that you want to include in your configuration.
|
||||
|
||||
# Send data to InfluxDB OSS v2
|
||||
[[outputs.influxdb_v2]]
|
||||
|
|
@ -41,23 +39,23 @@ Use the configuration below to write your data to both OSS and Cloud instances s
|
|||
token = "${INFLUX_TOKEN_OSS}"
|
||||
|
||||
## Organization is the name of the organization you want to write to. It must already exist.
|
||||
organization = "influxdata"
|
||||
organization = "ORG_NAME_OSS"
|
||||
|
||||
## Destination bucket to write to.
|
||||
bucket = "telegraf"
|
||||
bucket = "BUCKET_NAME_OSS"
|
||||
|
||||
# Send data to InfluxDB Cloud - AWS West cloud instance
|
||||
# Send data to InfluxDB Cloud Serverless instance
|
||||
[[outputs.influxdb_v2]]
|
||||
## The URLs of the InfluxDB Cloud instance.
|
||||
|
||||
urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
|
||||
urls = ["https://cloud2.influxdata.com"]
|
||||
|
||||
## Cloud token for authentication.
|
||||
token = "${INFLUX_TOKEN_CLOUD}"
|
||||
token = "${INFLUX_TOKEN}"
|
||||
|
||||
## Organization is the name of the organization you want to write to. It must already exist.
|
||||
organization = "example@domain.com"
|
||||
## For InfluxDB Cloud Serverless, set organization to an empty string.
|
||||
organization = ""
|
||||
|
||||
## Destination bucket to write into.
|
||||
bucket = "telegraf"
|
||||
bucket = "BUCKET_NAME"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
---
|
||||
title: Manage Telegraf configurations
|
||||
description: >
|
||||
InfluxDB Cloud Serverless lets you automatically generate Telegraf configurations
|
||||
or upload customized Telegraf configurations that collect metrics and write
|
||||
them to InfluxDB Cloud Serverless.
|
||||
weight: 102
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Manage Telegraf configs
|
||||
parent: Use Telegraf
|
||||
influxdb/cloud-serverless/tags: [telegraf]
|
||||
related:
|
||||
- /influxdb/cloud-serverless/write-data/use-telegraf/manual-config/
|
||||
- /influxdb/cloud-serverless/write-data/use-telegraf/auto-config/
|
||||
alt_engine: /influxdb/cloud/telegraf-configs/
|
||||
---
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/" >}}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
---
|
||||
title: Create a Telegraf configuration
|
||||
description: >
|
||||
Use the InfluxDB UI or the [`influx` CLI](/influxdb/cloud/reference/cli/influx/)
|
||||
to create an Telegraf configuration.
|
||||
weight: 101
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Create a config
|
||||
parent: Manage Telegraf configs
|
||||
related:
|
||||
- /influxdb/cloud-serverless/write-data/no-code/use-telegraf/configure/manual-config/
|
||||
- /influxdb/cloud-serverless/write-data/no-code/use-telegraf/configure/auto-config/
|
||||
- /influxdb/cloud-serverless/write-data/use-telegraf/telegraf-configs/update/
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/telegraf-configs/create/
|
||||
- /influxdb/cloud-serverless/telegraf-configs/clone/
|
||||
alt_engine: /influxdb/cloud/telegraf-configs/create/
|
||||
---
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/create" >}}
|
||||
|
||||
## Clone an existing Telegraf configuration
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/clone" >}}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: Remove a Telegraf configuration
|
||||
description: >
|
||||
Use the InfluxDB UI or the [`influx` CLI](/influxdb/cloud/reference/cli/influx/)
|
||||
to remove Telegraf configurations from InfluxDB.
|
||||
weight: 104
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Remove a config
|
||||
parent: Manage Telegraf configs
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/telegraf-configs/remove/
|
||||
alt_engine: /influxdb/cloud/telegraf-configs/remove/
|
||||
---
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/remove" >}}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: Update a Telegraf configuration
|
||||
description: >
|
||||
Use the InfluxDB user interface (UI) or the [`influx` CLI](/influxdb/cloud/reference/cli/influx/)
|
||||
to update InfluxDB Telegraf configurations.
|
||||
weight: 103
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Update a config
|
||||
parent: Manage Telegraf configs
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/telegraf-configs/update/
|
||||
alt_engine: /influxdb/cloud/telegraf-configs/update/
|
||||
---
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/update" >}}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: View Telegraf configurations
|
||||
description: >
|
||||
Use the InfluxDB user interface (UI) or the [`influx` CLI](/influxdb/cloud/reference/cli/influx/)
|
||||
to view and download InfluxDB Telegraf configurations.
|
||||
weight: 102
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: View configs
|
||||
parent: Manage Telegraf configs
|
||||
aliases:
|
||||
- /influxdb/cloud-serverless/telegraf-configs/view/
|
||||
alt_engine: /influxdb/cloud/telegraf-configs/view/
|
||||
---
|
||||
|
||||
{{< duplicate-oss "/telegraf-configs/view" >}}
|
||||
|
|
@ -14,7 +14,7 @@ menu:
|
|||
weight: 202
|
||||
influxdb/cloud/tags: [manually, plugin, mqtt]
|
||||
related:
|
||||
- /{{< latest "telegraf" >}}/plugins//
|
||||
- /{{< latest "telegraf" >}}/plugins/
|
||||
- /influxdb/cloud/telegraf-configs/create/
|
||||
- /influxdb/cloud/telegraf-configs/update/
|
||||
alt_engine: /influxdb/cloud-serverless/write-data/use-telegraf/configure/manual-config/
|
||||
|
|
@ -36,13 +36,13 @@ Configure Telegraf input and output plugins in the Telegraf configuration file (
|
|||
Input plugins collect metrics.
|
||||
Output plugins define destinations where metrics are sent.
|
||||
|
||||
_See [Telegraf plugins](/{{< latest "telegraf" >}}/plugins//) for a complete list of available plugins._
|
||||
_See [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/) for a complete list of available plugins._
|
||||
|
||||
### Manually add Telegraf plugins
|
||||
|
||||
To manually add any of the available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins//), follow the steps below.
|
||||
To manually add any of the available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/), follow the steps below.
|
||||
|
||||
1. Find the plugin you want to enable from the complete list of available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins//).
|
||||
1. Find the plugin you want to enable from the complete list of available [Telegraf plugins](/{{< latest "telegraf" >}}/plugins/).
|
||||
2. Click **View** to the right of the plugin name to open the plugin page on GitHub. For example, view the MQTT plugin GitHub page [here](https://github.com/influxdata/telegraf/blob/release-1.14/plugins/inputs/mqtt_consumer/README.md).
|
||||
3. Copy and paste the example configuration into your Telegraf configuration file (typically named `telegraf.conf`).
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue