### Run the browser example application Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/client-libraries/v2/javascript/browser/index.md Start the example application which will be accessible at http://localhost:3001/examples/index.html. Ensure you have updated the environment configuration file `./env_browser.js`. ```shell npm run browser ``` -------------------------------- ### Run the example browser application Source: https://docs.influxdata.com/influxdb3/clustered/reference/client-libraries/v2/javascript/browser/index.md Start the example browser application using npm. This command makes the application accessible at http://localhost:3001/examples/index.html. ```sh npm run browser ``` -------------------------------- ### Run InfluxQL Query Example Source: https://docs.influxdata.com/influxdb3/cloud-serverless/query-data/execute-queries/client-libraries/go/index.md Provides instructions on how to set up and run the Go client example. This includes creating a main.go file, installing dependencies, building, and executing the program to see query results. ```go package main func main() { Query() } ``` ```sh go build && go run main.go ``` -------------------------------- ### Install InfluxDB 3 Go Client Library Source: https://docs.influxdata.com/influxdb3/core/write-data/client-libraries/index.md Initialize your Go module and then use `go get` to install the Go client library. ```bash go mod init path/to/project/dir && cd $_ go get github.com/InfluxCommunity/influxdb3-go/v2/influxdb3 ``` -------------------------------- ### Start Another Query Node Source: https://docs.influxdata.com/influxdb3/enterprise/get-started/multi-server This example demonstrates starting a second query node to enhance read capacity and availability. It uses a different node ID while maintaining the same cluster and storage settings. ```bash influxdb3 serve \ --node-id host05 \ --cluster-id cluster01 \ --mode query \ --object-store s3 \ --bucket influxdb-3-enterprise-storage \ --aws-access-key-id \ --aws-secret-access-key ``` -------------------------------- ### Line Protocol Comment Example Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/syntax/line-protocol/index.md Example of a comment in Line Protocol. Lines starting with '#' are ignored. ```shell # This is a comment myTable fieldKey="string value" 1556813561098000000 ``` -------------------------------- ### Run Go Client Example Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/query-data/execute-queries/client-libraries/go This snippet shows how to set up a main function to execute the query logic and then build and run the Go program from the terminal. Ensure you have the necessary packages installed. ```go package main func main() { Query() } ``` ```bash go build && go run influxdb_go_client ``` -------------------------------- ### Install multiple Python packages Source: https://docs.influxdata.com/influxdb3/core/reference/cli/influxdb3/install/package/index.md Install several Python packages simultaneously by listing them space-separated after the command. This example installs `pint`, `pandas`, and `requests`. ```bash influxdb3 install package pint pandas requests ``` -------------------------------- ### Start InfluxDB 3 Service (systemctl) Source: https://docs.influxdata.com/influxdb3/enterprise/admin/upgrade/index.md Starts the InfluxDB 3 service using systemctl after a new version has been installed. ```bash sudo systemctl start influxdb3 ``` -------------------------------- ### Example: Basic Write Monitoring Setup and Query Source: https://docs.influxdata.com/influxdb3/core/plugins/library/examples/wal-plugin/index.md Sets up basic write monitoring and demonstrates writing test data, then querying the generated write reports. ```bash # Create the monitoring trigger influxdb3 create trigger \ --database testdb \ --plugin-filename examples/wal_plugin/wal_plugin.py \ --trigger-spec "all_tables" \ write_monitor # Write test data to various tables influxdb3 write \ --database testdb \ "temperature,location=office value=22.5" influxdb3 write \ --database testdb \ "humidity,location=office value=45.2" influxdb3 write \ --database testdb \ "pressure,location=office value=1013.25" # The plugin automatically generates write reports in the `write_reports` measurement. # Query the write reports influxdb3 query \ --database testdb \ "SELECT * FROM write_reports ORDER BY time DESC" ``` -------------------------------- ### View Resource Details Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/cli/influxctl/management/list To get detailed information about a specific resource, use the `get` command followed by the resource type and its ID. For example, to get details of a specific bucket: ```bash influxctl management get bucket ``` -------------------------------- ### Navigate to examples directory Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/client-libraries/v2/javascript/browser/index.md Change the current directory to the examples folder within the cloned repository. ```shell cd examples ``` -------------------------------- ### Install packages using a specific package manager Source: https://docs.influxdata.com/influxdb3/core/reference/cli/influxdb3/install/package/index.md Force the use of a particular package manager, such as `uv`, for installing Python packages. This example installs `prophet` and `adtk` using `uv`. ```bash influxdb3 install package \ --package-manager uv \ prophet adtk ``` -------------------------------- ### EXPLAIN ANALYZE Statement Example Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/influxql/index.md An example of using the EXPLAIN ANALYZE statement to get runtime performance and storage data for a query. ```sql explain analyze select mean(usage_steal) from cpu where time >= '2018-02-22T00:00:00Z' and time < '2018-02-22T12:00:00Z' ``` -------------------------------- ### Go Project Setup and Dependencies Source: https://docs.influxdata.com/influxdb3/cloud-serverless/get-started/write?t=Nodejs This command installs Go dependencies and runs the main application. Ensure your Go modules are initialized (`go mod init`). ```bash go mod tidy && go run main.go ``` -------------------------------- ### Create a table with custom partitioning Source: https://docs.influxdata.com/influxdb3/clustered/reference/cli/influxctl/table/create/index.md This example demonstrates creating a table with a custom partition template. It partitions by two tags (`room` and `sensor-type`), buckets `customerID` tag values into 1000 groups, and partitions by day using the time format '%Y-%m-%d'. Replace `DATABASE_NAME` and `TABLE_NAME` with your actual database and table names. ```bash influxctl table create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,1000 \ --template-timeformat '%Y-%m-%d' \ DATABASE_NAME \ TABLE_NAME ``` -------------------------------- ### Create a table with a specific partition key Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/cli/influxctl/table/create This example shows how to create a table and define a partition key. Partitioning helps optimize query performance by distributing data. ```bash influxctl table create --database "my-db" --name "my-table" --partition-key "host" ``` -------------------------------- ### Example: Start InfluxDB with Offline Admin Token Source: https://docs.influxdata.com/influxdb3/core/reference/config-options/index.md Shows how to start the InfluxDB server using a pre-generated offline admin token file. ```bash # Generate an admin token offline influxdb3 create token \ --admin \ --name "example-admin-token" \ --expiry 1d \ --offline \ --output-file ./path/to/admin-token.json # Start InfluxDB 3 Core using the generated token influxdb3 serve --admin-token-file ./path/to/admin-token.json ``` -------------------------------- ### Create a table with multiple options Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/cli/influxctl/table/create This comprehensive example shows how to create a table specifying the database, name, retention period, schema, partition key, and cluster key all in one command. ```bash influxctl table create --database "my-db" --name "my-table" --retention-period 720h --schema "time:ts,sensor_id:str,temperature:float,humidity:float" --partition-key "sensor_id" --cluster-key "time" ``` -------------------------------- ### Example AppInstance Resource with Admin Section Source: https://docs.influxdata.com/influxdb3/clustered/reference/release-notes/clustered An example of an AppInstance resource that previously required an admin section for identity provider setup. This section is now optional. ```yaml apiVersion: kubecfg.dev/v1alpha1 kind: AppInstance metadata: name: influxdb namespace: influxdb spec: package: image: apiVersion: influxdata.com/v1alpha1 spec: # ... other spec fields elided ... admin: users: # - ... user entries elided ... dsn: valueFrom: # ... dsn source elided ... identityProvider: jwksEndpoint: ``` -------------------------------- ### Create an organization with a description Source: https://docs.influxdata.com/influxdb3/cloud-serverless/reference/cli/influx/org/create/index.md This example demonstrates creating an organization and providing a descriptive text for it. Authentication credentials should be pre-configured. ```sh influx org create \ --name example-org \ --description "Example organization description" ``` -------------------------------- ### Install Packages and Serve with Disabled Package Manager Source: https://docs.influxdata.com/influxdb3/core/plugins/index.md First, install required Python packages, then start the InfluxDB 3 server with the package manager disabled. This is useful for environments where runtime package installation is not permitted. ```bash # Install packages first influxdb3 install package pandas requests numpy # Then start with disabled package manager influxdb3 serve \ --plugin-dir ~/.plugins \ --package-manager disabled ``` -------------------------------- ### Create a Bucket Schema with a Description Source: https://docs.influxdata.com/influxdb3/cloud-serverless/reference/cli/influx/bucket-schema/create This example shows how to create a bucket schema and provide a description for it. ```bash influx bucket schema create --bucket my-bucket --type "measurement" --schema "{\"measurement\": \"cpu\", \"fields\": {\"usage_user\": \"float\"}}" --description "CPU usage data" ``` -------------------------------- ### Create a bucket with a description Source: https://docs.influxdata.com/influxdb3/cloud-serverless/reference/cli/influx/bucket/create/index.md Creates a bucket named 'example-bucket' and assigns it a descriptive string. Authentication credentials are required. ```sh influx bucket create \ --name example-bucket \ --description "Example bucket description" ``` -------------------------------- ### Install Go Client Library Source: https://docs.influxdata.com/influxdb3/core/reference/client-libraries/flight/go-flight Install the InfluxDB Go client library using go get. This is the first step to interacting with InfluxDB from your Go applications. ```go go get -u github.com/influxdata/influxdb-client-go/v2 ``` -------------------------------- ### Example of using the NOW() function Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/sql/functions Demonstrates how to get the current timestamp using the NOW() function. ```sql SELECT NOW() ``` -------------------------------- ### Go Project Setup Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/write-data/line-protocol/client-libraries Steps to set up a Go project for writing data to InfluxDB 3 using the influxdb3-go client library. ```bash mkdir iot-starter-go && cd $_ go mod init iot-starter go get github.com/InfluxCommunity/influxdb3-go/v2 ``` -------------------------------- ### Invalid Table Names Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/naming-restrictions/index.md An example of an invalid table name that starts with an underscore. ```text _internal # Starts with underscore (not recommended) ``` -------------------------------- ### Initialize Go Module and Create File Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/get-started/write?t=Go These commands set up a new Go project directory and create the main Go file for writing data. ```shell mkdir -p influxdb_go_client && cd influxdb_go_client go mod init influxdb_go_client touch write.go ``` -------------------------------- ### Initialize Go Project Directory Source: https://docs.influxdata.com/influxdb3/core/write-data/client-libraries/index.md Create a directory for your Go module and initialize it. ```sh mkdir iot-starter-go && cd $_ go mod init iot-starter ``` -------------------------------- ### Install Python Packages using HTTP API Source: https://docs.influxdata.com/influxdb3/enterprise/plugins/index.md Use the HTTP API to programmatically install Python packages into the Processing Engine's environment. This example installs 'pandas', 'requests', and 'numpy'. Replace AUTH_TOKEN with your admin token. ```bash # Use the HTTP API to install Python packages curl -X POST "localhost:8181/api/v3/configure/plugin_environment/install_packages" \ --header "Authorization: Bearer AUTH_TOKEN" \ --header "Content-Type: application/json" \ --data '{ \ "packages": ["pandas", "requests", "numpy"] \ }' ``` -------------------------------- ### Serve with Disabled Package Manager Source: https://docs.influxdata.com/influxdb3/core/plugins/index.md Start the InfluxDB 3 server with package installation disabled for secure or air-gapped environments. This maintains Processing Engine functionality while blocking package installations. ```bash influxdb3 serve \ --node-id node0 \ --object-store file \ --data-dir ~/.influxdb3 \ --plugin-dir ~/.plugins \ --package-manager disabled ``` -------------------------------- ### Create a database with a custom partition template using influxctl CLI Source: https://docs.influxdata.com/influxdb3/clustered/admin/custom-partitions/define-custom-partitions This example demonstrates how to create a new database named 'example-db' and apply a custom partition template using the `influxctl` command-line interface. The template partitions data by the 'room' and 'sensor-type' tags, buckets 'customerID' tag values into 500 groups, and partitions by day. ```APIDOC ## Create a database with a custom partition template using influxctl CLI ### Description Creates a new database with a custom partition template using the `influxctl` CLI. The partition template includes partitioning by specific tags, bucketing tag values, and time-based partitioning. ### Command ```bash influxctl database create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,500 \ --template-timeformat '%Y-%m-%d' \ example-db ``` ### Parameters - `--template-timeformat` (string): Specifies the time part in the partition template. Accepted values are `%Y-%m-%d` (daily), `%Y-%m` (monthly), or `%Y` (annually). - `--template-tag` (string): An InfluxDB tag to use in the partition template. - `--template-tag-bucket` (string): An InfluxDB tag and the number of buckets to group tag values into. Format: `tagKey,N`. - `example-db` (string): The name of the database to create. ``` -------------------------------- ### Generate Admin Token and Start InfluxDB Source: https://docs.influxdata.com/influxdb3/enterprise/reference/config-options Generates an admin token offline and then starts the InfluxDB server using the generated token. This is useful for initial setup and secure token management. ```bash # Generate an admin token offline influxdb3 create token \ --name "example-token" \ --permission "db:db1,db2:read,write" \ --permission "db:db3:read" \ --expiry 1d \ --offline \ --create-databases db1,db2 \ --output-file ./path/to/tokens.json # Start InfluxDB 3 Enterprise using the generated token influxdb3 serve --permission-tokens-file ./path/to/tokens.json ``` -------------------------------- ### Copy Example Configuration File Source: https://docs.influxdata.com/influxdb3/clustered/install/set-up-cluster/configure-cluster/directly/index.md Use this command to copy the example customer YAML file to create your own cluster configuration file. ```bash cp example-customer.yml myinfluxdb.yml ``` -------------------------------- ### Example of using the PI() function Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/reference/sql/functions Demonstrates how to get the value of PI using the PI() function. ```sql SELECT PI() ``` -------------------------------- ### Example: Monitoring with Special Table Handling Setup and Query Source: https://docs.influxdata.com/influxdb3/core/plugins/library/examples/wal-plugin/index.md Sets up write monitoring with doubled counting for a specific table and demonstrates writing data and querying reports. ```bash # Create trigger with special handling influxdb3 create trigger \ --database testdb \ --plugin-filename examples/wal_plugin/wal_plugin.py \ --trigger-spec "all_tables" \ --trigger-arguments 'double_count_table=temperature' \ write_monitor_special # Write test data influxdb3 write \ --database testdb \ "temperature,location=office value=22.5" influxdb3 write \ --database testdb \ "humidity,location=office value=45.2" # Query the write reports influxdb3 query \ --database testdb \ "SELECT * FROM write_reports ORDER BY time DESC" ``` -------------------------------- ### Install Go Packages and Run Program Source: https://docs.influxdata.com/influxdb3/cloud-dedicated/get-started/query Command to install Go dependencies, build the module, and run the program. ```bash go mod tidy && go run influxdb_go_client ```