content/influxdb3/cloud-serverless/get-started/setup.md
As you get started with this tutorial, do the following to make sure everything you need is in place.
{{< 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 the influx CLI reference.
Create an All Access API token. <span id="create-an-all-access-api-token"></span>
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. <span id="configure-authentication-credentials"></span>
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 %}}
<!------------------------------ BEGIN UI 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.
<!------------------------------- END UI CONTENT ------------------------------>{{% /tab-content %}} {{% tab-content %}}
<!---------------------------- BEGIN CLI CONTENT ----------------------------->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>" %}}
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 uses get-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 %}}
<!-- BEGIN MACOS/LINUX -->{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
export INFLUX_HOST=https://{{< influxdb/host >}}
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" %}}
$env:INFLUX_HOST = "https://{{< influxdb/host >}}"
$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" %}}
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 %}}
<!-- END CMD -->{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
<!-- END WINDOWS -->{{% /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 >}}
<!------------------------------ END CLI CONTENT ------------------------------>[!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 %}}
<!----------------------------- 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" %}}
export INFLUX_TOKEN=API_TOKEN
{{% /code-placeholders %}}
<!-- END MACOS/LINUX -->{{% /code-tab-content %}}
{{% code-tab-content %}}
<!-- BEGIN POWERSHELL -->{{% code-placeholders "API_TOKEN" %}}
$env:INFLUX_TOKEN = "API_TOKEN"
{{% /code-placeholders %}}
<!-- END POWERSHELL -->{{% /code-tab-content %}}
{{% code-tab-content %}}
<!-- BEGIN CMD -->{{% code-placeholders "API_TOKEN" %}}
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: an InfluxDB API token with sufficient permissions to your bucket{{% /tab-content %}} {{% tab-content %}}
<!----------------------------- BEGIN API 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 %}}
<!-- BEGIN MACOS/LINUX -->{{% code-placeholders "API_TOKEN|ORG_NAME" %}}
export INFLUX_HOST=https://{{< influxdb/host >}}
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" %}}
$env:INFLUX_HOST = "https://{{< influxdb/host >}}"
$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" %}}
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 %}}
<!-- END CMD -->{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
<!-- END WINDOWS -->Replace the following:
ORG_NAME: your InfluxDB organization nameORG_ID: your InfluxDB organization IDAPI_TOKEN: an InfluxDB API token with sufficient permissions to your bucketKeep the following in mind when using API clients and client libraries:
org and org_id parameters in API write and query requests,
but some clients still require the parameters.host to refer to your hostname, your
{{% product-name %}} region URL
without https://.<!------------------------------ END API CONTENT ------------------------------>[!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, influx CLI, or InfluxDB API to create a
bucket.
{{< tabs-wrapper >}} {{% tabs %}} InfluxDB UI influx CLI InfluxDB API {{% /tabs %}}
{{% tab-content %}}
<!------------------------------ BEGIN UI 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 %}}
<!----------------------------- BEGIN CLI CONTENT ----------------------------->If you haven't already, download, install, and configure the influx CLI.
Use the influx bucket create command
to create a new bucket.
Provide the following:
-n, --name flag with the bucket name.-r, --retention flag with the bucket's retention period duration.
Supported retention periods depend on your {{% product-name %}} plan.{{% code-placeholders "get-started|7d" %}}
influx bucket create \
--name get-started \
--retention 7d
{{% /code-placeholders %}}
<!------------------------------ END CLI CONTENT ------------------------------>{{% /tab-content %}} {{% tab-content %}}
<!----------------------------- BEGIN API 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:
INFLUX_TOKENapplication/json"expire"{{% 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 %}}
<!------------------------------ END API CONTENT ------------------------------>{{% /tab-content %}} {{< /tabs-wrapper >}}
{{< page-nav prev="/influxdb3/cloud-serverless/get-started/" next="/influxdb3/cloud-serverless/get-started/write/" keepTab=true >}}