11 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. |
|
101 |
|
|
|
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
influxCLI.The
influxCLI provides a simple way to interact with InfluxDB from a command line. For detailed installation and setup instructions, see Use the influx CLI. -
Create an All Access API token.
-
Go to {{% oss-only %}}localhost:8086{{% /oss-only %}} {{% cloud-only %}}cloud2.influxdata.com{{% /cloud-only %}} 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. {{% /note %}}
-
-
Configure authentication credentials.
As you go through this tutorial, interactions with InfluxDB {{< current-version >}} require your InfluxDB 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 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 provided 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: InfluxDB Cloud Serverless region URL.-o, --org: InfluxDB organization name.-t, --token: InfluxDB API token.
influx config create \
--config-name get-started \
--host-url https://cloud2.influxdata.com \
--org <YOUR_INFLUXDB_ORG_NAME> \
--token <YOUR_INFLUXDB_API_TOKEN>
For more information about CLI connection configurations, see
Install and use the influx CLI.
{{% /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: InfluxDB Cloud Serverless region URL.INFLUX_ORG: InfluxDB organization name.INFLUX_ORG_ID: InfluxDB organization ID.INFLUX_TOKEN: InfluxDB API token.
export INFLUX_HOST=https://cloud2.influxdata.com
export INFLUX_ORG=<YOUR_INFLUXDB_ORG_NAME>
export INFLUX_ORG_ID=<YOUR_INFLUXDB_ORG_ID>
export INFLUX_TOKEN=<YOUR_INFLUXDB_API_TOKEN>
{{% /expand %}}
{{% expand "Command flags" %}}
Use the following influx CLI flags to provide required credentials to commands:
--host: InfluxDB Cloud Serverless region URL.-o,--orgor--org-id: InfluxDB organization name or ID.-t,--token: InfluxDB API token.
{{% /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 %}}
When using the InfluxDB API, provide the required connection credentials in the following ways:
- InfluxDB host: InfluxDB Cloud Serverless region URL
- InfluxDB API Token: Include an
Authorizationheader that uses eitherBearerorTokenscheme and your InfluxDB API token. For example:
Authorization: Bearer 0xxx0o0XxXxx00Xxxx000xXXxoo0==. - InfluxDB organization name or ID: Depending on the API endpoint used, pass this as part of the URL path, query string, or in the request body.
All API examples in this tutorial use cURL from a command line. To provide all the necessary credentials to the example cURL commands, set the following environment variables in your command line session.
export INFLUX_HOST=https://cloud2.influxdata.com
export INFLUX_ORG=<YOUR_INFLUXDB_ORG_NAME>
export INFLUX_ORG_ID=<YOUR_INFLUXDB_ORG_ID>
export INFLUX_TOKEN=<YOUR_INFLUXDB_API_TOKEN>
{{% /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 {{% oss-only %}}localhost:8086{{% /oss-only %}} {{% cloud-only %}}cloud2.influxdata.com{{% /cloud-only %}} 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 InfluxDB Cloud Serverless 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 InfluxDB Cloud Serverless plan.- Connection and authentication credentials
influx bucket create \ --name get-started \ --retention 7d
{{% /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://cloud2.influxdata.com/api/v2/buckets" method="post" api-ref="/influxdb/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 InfluxDB Cloud Serverless plan.
- type:
export INFLUX_HOST=https://cloud2.influxdata.com
export INFLUX_ORG_ID=<YOUR_INFLUXDB_ORG_ID>
export INFLUX_TOKEN=<YOUR_INFLUXDB_API_TOKEN>
curl --request POST \
"$INFLUX_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
}
]
}'
{{% /tab-content %}} {{< /tabs-wrapper >}}
{{< page-nav prev="/influxdb/cloud-serverless/get-started/" next="/influxdb/cloud-serverless/get-started/write/" keepTab=true >}}