15 KiB
| title | seotitle | list_title | description | menu | weight | metadata | related | aliases | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Set up InfluxDB | Set up InfluxDB | Get started with InfluxDB | Set up InfluxDB | Learn how to set up InfluxDB for the "Get started with InfluxDB" tutorial and for general use. |
|
101 |
|
|
|
As you get started with this tutorial, do the following to make sure everything you need is in place.
- Optional: Download, install, and configure the influx CLI
- Create an All Access API token
- Configure authentication credentials
- Optional: Create a bucket
-
{{< req text="Optional:" color="magenta" >}} Download, install, and configure the
influxCLI.The
influxCLI provides a simple way to interact with InfluxDB from a command line. For detailed installation and setup instructions, see theinfluxCLI reference. -
Create an All Access API token.
-
Go to cloud2.influxdata.com in a browser to log in and access the InfluxDB UI.
-
Navigate to Load Data > API Tokens using the left navigation bar.
{{< nav-icon "load data" >}}
-
Click + {{% caps %}}Generate API token{{% /caps %}} and select All Access API Token.
-
Enter a description for the API token and click {{< icon "check" >}} {{% caps %}}Save{{% /caps %}}.
-
Copy the generated token and store it for safe keeping.
[!Note] We recommend using a password manager or a secret store to securely store sensitive tokens.
-
-
Configure authentication credentials.
As you go through this tutorial, interactions with InfluxDB {{< current-version >}} 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.
[!Note] When configuring your token, if you created an all access token, use that token to interact with InfluxDB. Otherwise, use your operator token.
{{< tabs-wrapper >}} {{% tabs %}} InfluxDB UI influx CLI Telegraf InfluxDB API {{% /tabs %}}
{{% tab-content %}}
When managing InfluxDB {{< current-version >}} through the InfluxDB UI, authentication credentials are provided automatically using credentials associated with the user you log in with.
{{% /tab-content %}} {{% tab-content %}}
There are three ways to provide authentication credentials to the influx CLI:
{{< expand-wrapper >}} {{% expand "CLI connection configurations (<span class="req">Recommended)" %}}
The influx CLI lets you specify connection configuration presets that let
you store and quickly switch between multiple sets of InfluxDB connection
credentials. Use the influx config create command
to create a new CLI connection configuration. Include the following flags:
-n, --config-name: Connection configuration name. This examples usesget-started.-u, --host-url: {{% product-name %}} region URL.-o, --org: InfluxDB organization name.-t, --token: your API token.
{{% code-placeholders "API_TOKEN|ORG_NAME|https://{{< influxdb/host >}}|get-started" %}}
influx config create \
--config-name get-started \
--host-url https://{{< influxdb/host >}} \
--org ORG_NAME \
--token API_TOKEN
{{% /code-placeholders%}}
For more information about CLI connection configurations, see the
influx config command.
{{% /expand %}}
{{% expand "Environment variables" %}}
The influx CLI checks for specific environment variables and, if present,
uses those environment variables to populate authentication credentials.
Set the following environment variables in your command line session:
INFLUX_HOST: {{% product-name %}} region URL.INFLUX_ORG: InfluxDB organization name or ID.INFLUX_TOKEN: your API token.
{{< code-tabs-wrapper >}} {{% code-tabs %}} MacOS and Linux PowerShell CMD {{% /code-tabs %}} {{% code-tab-content %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
export INFLUX_HOST=https://{{< influxdb/host >}}
export INFLUX_ORG=ORG_NAME
export INFLUX_TOKEN=API_TOKEN
{{% /code-placeholders %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
$env:INFLUX_HOST = "https://{{< influxdb/host >}}"
$env:INFLUX_TOKEN = "API_TOKEN"
$env:INFLUX_ORG = "ORG_NAME"
{{% /code-placeholders %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
set INFLUX_HOST=https://{{< influxdb/host >}}
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 %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /expand %}}
{{% expand "Command flags" %}}
Use the following influx CLI flags to provide required credentials to commands:
--host: {{% product-name %}} region URL.-o,--org: InfluxDB organization name or ID.-t,--token: your API token.
{{% /expand %}} {{< /expand-wrapper >}}
[!Note] All
influxCLI examples in this getting started tutorial assume your InfluxDB host, organization, and token are provided by either the activeinfluxCLI configuration or by environment variables.
{{% /tab-content %}} {{% tab-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 %}}
{{% code-placeholders "API_TOKEN" %}}
export INFLUX_TOKEN=API_TOKEN
{{% /code-placeholders %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% code-placeholders "API_TOKEN" %}}
$env:INFLUX_TOKEN = "API_TOKEN"
{{% /code-placeholders %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% code-placeholders "API_TOKEN" %}}
set INFLUX_TOKEN=API_TOKEN
# Make sure to include a space character at the end of this command.
{{% /code-placeholders %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
Replace the following:
API_TOKEN: an InfluxDB API token with sufficient permissions to your bucket
{{% /tab-content %}} {{% tab-content %}}
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 %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
export INFLUX_HOST=https://{{< influxdb/host >}}
export INFLUX_ORG=ORG_NAME
export INFLUX_TOKEN=API_TOKEN
{{% /code-placeholders %}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
$env:INFLUX_HOST = "https://{{< influxdb/host >}}"
$env:INFLUX_ORG = "ORG_NAME"
$env:INFLUX_TOKEN = "API_TOKEN"
{{% /code-placeholders %}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
set INFLUX_HOST=https://{{< influxdb/host >}}
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 %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
Replace the following:
ORG_NAME: your InfluxDB organization nameORG_ID: your InfluxDB organization IDAPI_TOKEN: an InfluxDB API token with sufficient permissions to your bucket
Keep the following in mind when using API clients and client libraries:
- InfluxDB ignores
organdorg_idparameters in API write and query requests, but some clients still require the parameters. - Some clients use
hostto refer to your hostname, your {{% product-name %}} region URL withouthttps://.
[!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.
{{% /tab-content %}} {{< /tabs-wrapper >}}
-
{{< 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 "get-started".
Use the InfluxDB UI,
influxCLI, or InfluxDB API to create a bucket.{{< tabs-wrapper >}} {{% tabs %}} InfluxDB UI influx CLI InfluxDB API {{% /tabs %}}
{{% tab-content %}}
-
Go to cloud2.influxdata.com in a browser to log in and access the InfluxDB UI.
-
Navigate to Load Data > Buckets using the left navigation bar.
{{< nav-icon "load data" >}}
-
Click + {{< caps >}}Create bucket{{< /caps >}}.
-
Provide a bucket name (get-started) and select a retention period. Supported retention periods depend on your {{% product-name %}} plan.
-
Click {{< caps >}}Create{{< /caps >}}.
{{% /tab-content %}} {{% tab-content %}}
-
If you haven't already, download, install, and configure the
influxCLI. -
Use the
influx bucket createcommand to create a new bucket.Provide the following:
-n, --nameflag with the bucket name.-r, --retentionflag with the bucket's retention period duration. Supported retention periods depend on your {{% product-name %}} plan.- Connection and authentication credentials
{{% code-placeholders "get-started|7d" %}}
influx bucket create \
--name get-started \
--retention 7d
{{% /code-placeholders %}}
{{% /tab-content %}} {{% tab-content %}}
To create a bucket using the InfluxDB HTTP API, send a request to
the InfluxDB API /api/v2/buckets endpoint using the POST request method.
{{< api-endpoint endpoint="https://{{< influxdb/host >}}/api/v2/buckets" method="post" api-ref="/influxdb3/cloud-serverless/api/#operation/PostBuckets" >}}
Include the following with your request:
- Headers:
- Authorization: Token
INFLUX_TOKEN - Content-Type:
application/json
- Authorization: Token
- Request body: JSON object with the following properties:
- org: InfluxDB organization name
- name: Bucket name
- retentionRules: List of retention rule objects that define the bucket's retention period.
Each retention rule object has the following properties:
- type:
"expire" - everySeconds: Retention period duration in seconds. Supported retention periods depend on your {{% product-name %}} plan.
- type:
{{% code-placeholders "$INFLUX_TOKEN|$INFLUX_ORG_ID|get-started"%}}
curl --request POST \
"https://{{< influxdb/host >}}/api/v2/buckets" \
--header "Authorization: Token $INFLUX_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"orgID": "'"$INFLUX_ORG_ID"'",
"name": "get-started",
"retentionRules": [
{
"type": "expire",
"everySeconds": 604800
}
]
}'
{{% /code-placeholders %}}
{{% /tab-content %}} {{< /tabs-wrapper >}}
{{< page-nav prev="/influxdb3/cloud-serverless/get-started/" next="/influxdb3/cloud-serverless/get-started/write/" keepTab=true >}}