docs-v2/content/influxdb3/cloud-serverless/get-started/setup.md

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.
influxdb3_cloud_serverless
name parent identifier
Set up InfluxDB Get started get-started-set-up
101
1 / 3
/influxdb3/cloud-serverless/security/tokens/
/influxdb3/cloud-serverless/security/tokens/create-token/
/influxdb3/cloud-serverless/security/tokens/view-tokens/
/influxdb3/cloud-serverless/admin/buckets/
/influxdb3/cloud-serverless/reference/cli/influx/
/influxdb3/cloud-serverless/reference/api/
/influxdb3/cloud-serverless/security/tokens/
/influxdb3/cloud-serverless/security/tokens/create-token/
/influxdb3/cloud-serverless/security/tokens/view-tokens/

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.

    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.

  2. Create an All Access API token.

    1. Go to cloud2.influxdata.com in a browser to log in and access the InfluxDB UI.

    2. Navigate to Load Data > API Tokens using the left navigation bar.

      {{< nav-icon "load data" >}}

    3. Click + {{% caps %}}Generate API token{{% /caps %}} and select All Access API Token.

    4. Enter a description for the API token and click {{< icon "check" >}} {{% caps %}}Save{{% /caps %}}.

    5. 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. {{% /note %}}

  3. 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. {{% /note %}}

    {{< 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:

{{% 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:

{{< 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:

{{% /expand %}} {{< /expand-wrapper >}}

{{% note %}} All influx CLI examples in this getting started tutorial assume your InfluxDB host, organization, and token are provided by either the active influx CLI configuration or by environment variables. {{% /note %}}

{{% /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 name
  • ORG_ID: your InfluxDB organization ID
  • API_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 org and org_id parameters in API write and query requests, but some clients still require the parameters.
  • Some clients use host to refer to your hostname, your {{% product-name %}} region URL without https://.

{{% 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. {{% /note %}}

{{% /tab-content %}} {{< /tabs-wrapper >}}

  1. {{< 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 %}}

  1. Go to cloud2.influxdata.com in a browser to log in and access the InfluxDB UI.

  2. Navigate to Load Data > Buckets using the left navigation bar.

{{< nav-icon "load data" >}}

  1. Click + {{< caps >}}Create bucket{{< /caps >}}.

  2. Provide a bucket name (get-started) and select a retention period. Supported retention periods depend on your {{% product-name %}} plan.

  3. Click {{< caps >}}Create{{< /caps >}}.

{{% /tab-content %}} {{% tab-content %}}

  1. If you haven't already, download, install, and configure the influx CLI.

  2. 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.
    • 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
  • 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.

{{% 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 >}}