Merge branch 'master' into master

pull/5529/head
Jason Stirnaman 2024-07-25 16:23:56 -05:00 committed by GitHub
commit bb03cfa5ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 390 additions and 107 deletions

View File

@ -11,6 +11,17 @@ menu:
weight: 202
---
## v2.9.4 {date="2024-07-25"}
### Bug Fixes
- Resolve crash when parsing error message and authentication was null.
### Dependency Updates
- Update `golang.org/x/mod` from 0.18.0 to 0.19.0
- Update `google.golang.org/grpc` from 1.64.0 to 1.65.0
## v2.9.3 {date="2024-06-26"}
### Bug Fixes

View File

@ -3,7 +3,6 @@ title: Java client library for InfluxDB v3
list_title: Java
description: >
The InfluxDB v3 `influxdb3-java` Java client library integrates with application code to write and query data stored in an InfluxDB Cloud Serverless bucket.
external_url: https://github.com/InfluxCommunity/influxdb3-java
menu:
influxdb_cloud_serverless:
name: Java
@ -15,69 +14,66 @@ aliases:
- /cloud-serverless/query-data/sql/execute-queries/java/
---
The InfluxDB v3 [`influxdb3-java` Java client library](https://github.com/InfluxCommunity/influxdb3-java) integrates with Java application code
to write and query data stored in an {{% product-name %}} bucket.
The InfluxDB v3 [`influxdb3-java` Java client library](https://github.com/InfluxCommunity/influxdb3-java) integrates
with Java application code to write and query data stored in an {{% product-name %}}
bucket.
The documentation for this client library is available on GitHub.
InfluxDB client libraries provide configurable batch writing of data to {{% product-name %}}.
Client libraries can be used to construct line protocol data, transform data from other formats
to line protocol, and batch write line protocol data to InfluxDB HTTP APIs.
<a href="https://github.com/InfluxCommunity/influxdb3-java" target="_blank" class="btn github">InfluxDB v3 Java client library</a>
InfluxDB v3 client libraries can query {{% product-name %}} using SQL or InfluxQL.
The `influxdb3-java` Java client library wraps the Apache Arrow `org.apache.arrow.flight.FlightClient`
in a convenient InfluxDB v3 interface for executing SQL and InfluxQL queries, requesting
server metadata, and retrieving data from {{% product-name %}} using the Flight protocol with gRPC.
## Setup & Installation
Create a command line java application using Maven or Gradle.
### Maven
To use Maven to install the client library in your project, add the following to your `pom.xml`:
- [Installation](#installation)
- [Using Maven](#using-maven)
- [Using Gradle](#using-gradle)
- [Importing the client](#importing-the-client)
- [API reference](#api-reference)
- [Classes](#classes)
- [InfluxDBClient interface](#influxdbclient-interface)
- [Initialize with credential parameters](#initialize-with-credential-parameters)
- [InfluxDBClient instance methods](#influxdbclient-instance-methods)
- [InfluxDBClient.writePoint](#influxdbclientwritepoint)
- [InfluxDBClient.query](#influxdbclientquery)
```xml
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb3-java</artifactId>
<version>RELEASE</version>
</dependency>
```
#### Example: write and query data
### Gradle
To use Gradle to install the client library in your project, add the following to your `build.gradle` dependencies:
```groovy
implementation group: 'com.influxdb', name: 'influxdb3-java', version: 'latest.release'
```
## Example: write and query data
The following example, also available on [GitHub](https://github.com/suyashcjoshi/SimpleJavaInfluxDB/tree/main) shows how to use `influxdb3-java` to write and query data stored in {{% product-name %}}:
### Initialize the application
Create a `HelloInfluxDB.java` class with the following information:
The following example shows how to use `influxdb3-java` to write and query data stored in {{% product-name %}}.
```java
package com.influxdata.demo;
import com.influxdb.v3.client.InfluxDBClient;
import com.influxdb.v3.client.Point;
import com.influxdb.v3.client.query.QueryOptions;
import com.influxdb.v3.client.query.QueryType;
import java.time.Instant;
import java.util.stream.Stream;
public class HelloInfluxDB {
private static final String HOST_URL = "https://{{< influxdb/host >}}";
private static final String DATABASE = "java"; // your bucket in InfluxDB Cloud Serverless
private static final char[] API_TOKEN = System.getenv("API_TOKEN"); // your API Token found in InfluxDB Cloud Serverless stored locally
// Create a client instance, and then write and query data in InfluxDB Cloud Serverless.
private static final String HOST_URL = "https://{{< influxdb/host >}}"; // your Cloud Serverless region URL
private static final String DATABASE = "java"; // your Cloud Serverless bucket
private static final char[] API_TOKEN = System.getenv("API_TOKEN"); // your local environment variable that stores your API Token
// Create a client instance that writes and queries data in your bucket.
public static void main(String[] args) {
// Instantiate the client with your InfluxDB credentials
try (InfluxDBClient client = InfluxDBClient.getInstance(HOST_URL, API_TOKEN, DATABASE)) {
writeData(client);
queryData(client);
}
catch (Exception e) {
System.err.println("An error occurred while connecting with the serverless InfluxDB!");
System.err.println("An error occurred while connecting to InfluxDB Cloud Serverless!");
e.printStackTrace();
}
}
```
### Write the data
```java
// Use the Point class to construct time series data.
// Call client.writePoint to write the point as line protocol to your bucket.
private static void writeData(InfluxDBClient client) {
Point point = Point.measurement("temperature")
.setTag("location", "London")
@ -85,19 +81,15 @@ public class HelloInfluxDB {
.setTimestamp(Instant.now().minusSeconds(10));
try {
client.writePoint(point);
System.out.println("Data written to the bucket.");
System.out.println("Data is written to the bucket.");
}
catch (Exception e) {
System.err.println("Failed to write data to the bucket.");
e.printStackTrace();
}
}
```
### Query the data
```java
// Query the latest 10 measurements using SQL
// Use SQL to query the most recent 10 measurements
private static void queryData(InfluxDBClient client) {
System.out.printf("--------------------------------------------------------%n");
System.out.printf("| %-8s | %-8s | %-30s |%n", "location", "value", "time");
@ -115,10 +107,213 @@ public class HelloInfluxDB {
}
```
## Run the program to write and query data
{{% cite %}}Source: [suyashcjoshi/SimpleJavaInfluxDB](https://github.com/suyashcjoshi/SimpleJavaInfluxDB/) on GitHub{{% /cite %}}
Build the project and then run the executable .jar file with this [JVM Flag](https://arrow.apache.org/docs/java/install.html).
```sh
java --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED -jar target/PROJECT_NAME.jar
Replace the following:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: your {{% product-name %}} [bucket](/influxdb/cloud-serverless/admin/buckets/)
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}}: a local environment variable that stores your [token](/influxdb/cloud-serverless/admin/tokens/)--the token must have read and write permission to the specified bucket.
### Run the example to write and query data
1. Build an executable JAR for the project--for example, using Maven:
<!--pytest.mark.skip-->
```bash
mvn package
```
2. In your terminal, run the `java` command to write and query data in your bucket:
<!--pytest.mark.skip-->
```bash
java \
--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED \
-jar target/PROJECT_NAME.jar
```
Include the following in your command:
- [`--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED`](https://arrow.apache.org/docs/java/install.html#id3): with Java version 9 or later and Apache Arrow version 16 or later, exposes JDK internals for Arrow.
For more options, see the [Apache Arrow Java install documentation](https://arrow.apache.org/docs/java/install.html).
- `-jar target/PROJECT_NAME.jar`: your `.jar` file to run.
The output is the newly written data from your {{< product-name >}} bucket.
## Installation
Include `com.influxdb.influxdb3-java` in your project dependencies.
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[Maven pom.xml](#)
[Gradle dependency script](#)
{{% /code-tabs %}}
{{% code-tab-content %}}
```xml
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb3-java</artifactId>
<version>RELEASE</version>
</dependency>
```
You should be able to also confirm the newly written data in your InfluxDB Cloud Serverless.
{{% /code-tab-content %}}
{{% code-tab-content %}}
<!--pytest.mark.skip-->
```groovy
dependencies {
implementation group: 'com.influxdb', name: 'influxdb3-java', version: 'latest.release'
}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
## Importing the client
The `influxdb3-java` client library package provides
`com.influxdb.v3.client` classes for constructing, writing, and querying data
stored in {{< product-name >}}.
## API reference
- [Interface InfluxDBClient](#interface-influxdbclient)
- [Initialize with credential parameters](#initialize-with-credential-parameters)
- [InfluxDBClient instance methods](#influxdbclient-instance-methods)
- [InfluxDBClient.writePoint](#influxdbclientwritepoint)
- [InfluxDBClient.query](#influxdbclientquery)
## InfluxDBClient interface
`InfluxDBClient` provides an interface for interacting with InfluxDB APIs for writing and querying data.
The `InfluxDBClient.getInstance` constructor initializes and returns a client instance with the following:
- A _write client_ configured for writing to the database.
- An Arrow _Flight client_ configured for querying the database.
To initialize a client, call `getInstance` and pass your credentials as one of
the following types:
- [parameters](#initialize-with-credential-parameters)
- a [`ClientConfig`](https://github.com/InfluxCommunity/influxdb3-java/blob/main/src/main/java/com/influxdb/v3/client/config/ClientConfig.java)
- a database connection string--for example:
```java
"https://{{< influxdb/host >}}"
+ "?token=API_TOKEN&amp;database=DATABASE_NAME"
```
### Initialize with credential parameters
```java
static InfluxDBClient getInstance(@Nonnull final String host,
@Nullable final char[] token,
@Nullable final String database)
```
- **`host`** (string): The host URL of the InfluxDB instance.
- **`database`** (string): The bucket to use for writing and querying.
- **`token`** (string): An API token with read/write permissions.
#### Example: initialize with credential parameters
```java
package com.influxdata.demo;
import com.influxdb.v3.client.InfluxDBClient;
import com.influxdb.v3.client.Point;
import com.influxdb.v3.client.query.QueryOptions;
import com.influxdb.v3.client.query.QueryType;
import java.time.Instant;
import java.util.stream.Stream;
public class HelloInfluxDB {
private static final String HOST_URL = "https://{{< influxdb/host >}}";
private static final String DATABASE = "DATABASE_NAME"; // your Cloud Serverless bucket
private static final char[] API_TOKEN = System.getenv("API_TOKEN"); // an environment variable for your Cloud Serverless API Token
// Create a client instance, and then write and query data in InfluxDB Cloud Serverless.
public static void main(String[] args) {
try (InfluxDBClient client = InfluxDBClient.getInstance(HOST_URL, API_TOKEN, DATABASE)) {
writeData(client);
queryData(client);
}
catch (Exception e) {
System.err.println("An error occurred while connecting with the serverless InfluxDB!");
e.printStackTrace();
}
}
}
```
#### Default tags
- _Optional_: To include default
[tags](/influxdb/cloud-serverless/reference/glossary/#tag) in all written data,
pass a `Map` of tag keys and values.
```java
InfluxDBClient getInstance(@Nonnull final String host,
@Nullable final char[] token,
@Nullable final String database,
@Nullable Map<String, String> defaultTags)
```
### InfluxDBClient instance methods
#### InfluxDBClient.writePoint
1. Use the `com.influxdb.v3.client.Point` class to create time series data.
2. Call the `client.writePoint()` method to write points as line protocol in your
bucket.
```java
// Use the Point class to construct time series data.
// Call client.writePoint to write the point in your bucket.
private static void writeData(InfluxDBClient client) {
Point point = Point.measurement("temperature")
.setTag("location", "London")
.setField("value", 30.01)
.setTimestamp(Instant.now().minusSeconds(10));
try {
client.writePoint(point);
System.out.println("Data written to the bucket.");
}
catch (Exception e) {
System.err.println("Failed to write data to the bucket.");
e.printStackTrace();
}
}
```
#### InfluxDBClient.query
To query data and process the results:
1. Call `client.query()` and provide your SQL query as a string.
2. Use the result stream's built-in iterator to process row data.
```java
// Query the latest 10 measurements using SQL
private static void queryData(InfluxDBClient client) {
System.out.printf("--------------------------------------------------------%n");
System.out.printf("| %-8s | %-8s | %-30s |%n", "location", "value", "time");
System.out.printf("--------------------------------------------------------%n");
String sql = "select time,location,value from temperature order by time desc limit 10";
try (Stream<Object[]> stream = client.query(sql)) {
stream.forEach(row -> System.out.printf("| %-8s | %-8s | %-30s |%n", row[1], row[2], row[0]));
}
catch (Exception e) {
System.err.println("Failed to query data from the bucket.");
e.printStackTrace();
}
}
```
<a class="btn" href="https://github.com/InfluxCommunity/influxdb3-java/" target="\_blank">View the InfluxDB v3 Java client library</a>

View File

@ -15,45 +15,9 @@ aliases:
- /influxdb/cloud-serverless/reference/client-libraries/v3/pyinflux3/
related:
- /influxdb/cloud-serverless/query-data/execute-queries/troubleshoot/
list_code_example: >
<!-- Import for tests and hide from users.
```python
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
from influxdb_client_3 import(InfluxDBClient3,
WriteOptions,
write_client_options)
# Instantiate batch writing options for the client
write_options = WriteOptions()
wco = write_client_options(write_options=write_options)
# Instantiate an InfluxDB v3 client
with InfluxDBClient3(host=f"{{< influxdb/host >}}",
database=f"BUCKET_NAME",
token=f"API_TOKEN",
write_client_options=wco) as client:
# Write data in batches
client.write_file(file='./data/home-sensor-data.csv', timestamp_column='time',
tag_columns=["room"])
# Execute a query and retrieve data formatted as a PyArrow Table
table = client.query(
'''SELECT *
FROM home
WHERE time >= now() - INTERVAL '90 days'
ORDER BY time''')
```
---
The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python)
The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python/)
integrates {{% product-name %}} write and query operations with Python scripts and applications.
InfluxDB client libraries provide configurable batch writing of data to {{% product-name %}}.
@ -85,8 +49,8 @@ Code samples in this page use the [Get started home sensor sample data](/influxd
- [Class WriteOptions](#class-writeoptions)
- [Parameters](#parameters-4)
- [Functions](#functions)
- [Function write_client_options(\*\*kwargs)](#function-write_client_optionskwargs)
- [Function flight_client_options(\*\*kwargs)](#function-flight_client_optionskwargs)
- [Function write_client_options(**kwargs)](#function-write_client_optionskwargs)
- [Function flight_client_options(**kwargs)](#function-flight_client_optionskwargs)
- [Constants](#constants)
- [Exceptions](#exceptions)
@ -143,6 +107,11 @@ The `influxdb_client_3` module includes the following classes and functions.
- [Class Point](#class-point)
- [Class WriteOptions](#class-writeoptions)
- [Parameters](#parameters-4)
- [Functions](#functions)
- [Function write_client_options(**kwargs)](#function-write_client_optionskwargs)
- [Function flight_client_options(**kwargs)](#function-flight_client_optionskwargs)
- [Constants](#constants)
- [Exceptions](#exceptions)
## Class InfluxDBClient3
@ -186,10 +155,10 @@ Given that `write_client_options` isn't specified, the client uses the default [
```python
import os
```
<!--pytest-codeblocks:cont-->
-->
<!--pytest-codeblocks:cont-->
```python
from influxdb_client_3 import InfluxDBClient3
@ -216,6 +185,7 @@ To explicitly specify synchronous mode, create a client with `write_options=SYNC
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -270,6 +240,7 @@ specify callback functions for the response status (success, error, or retryable
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -348,6 +319,7 @@ Writes a record or a list of records to InfluxDB.
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -401,6 +373,7 @@ data to InfluxDB.
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -534,6 +507,7 @@ and how to write data from CSV and JSON files to InfluxDB:
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -636,6 +610,7 @@ Returns all data in the query result as an Arrow table ([`pyarrow.Table`](https:
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -672,6 +647,7 @@ In the examples, replace the following:
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -698,6 +674,7 @@ print(table.select(['room', 'temp']))
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -723,6 +700,7 @@ print(pd.to_markdown())
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -750,6 +728,7 @@ print(table.schema)
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -776,6 +755,7 @@ Pass `timeout=<number of seconds>` for [`FlightCallOptions`](https://arrow.apach
import os
```
-->
<!--pytest-codeblocks:cont-->
```python
@ -980,3 +960,5 @@ Replace the following:
## Exceptions
- `influxdb_client_3.InfluxDBError`: Exception class raised for InfluxDB-related errors
<a class="btn" href="https://github.com/InfluxCommunity/influxdb3-python/" target="\_blank">View the InfluxDB v3 Python client library</a>

View File

@ -58,6 +58,8 @@ install your license.
3. Use `kubectl` to apply and create the `License` resource in your InfluxDB
namespace:
<!--pytest.mark.skip-->
```sh
kubectl apply --filename license.yml --namespace influxdb
```
@ -85,21 +87,22 @@ per hour) while running.
## Recover from a license misconfiguration
If you deploy a licensed release of InfluxDB Clustered without an invalid or
If you deploy a licensed release of InfluxDB Clustered with an invalid or
expired license, many of the pods in your cluster will crash on startup and will
likely enter a `CrashLoopBackoff` state without ever running or becoming healthy.
Because the license is stored in a volume-mounted Kubernetes secret, invalid
licenses affect both old and new pods.
Because InfluxDB stores the license in a volume-mounted Kubernetes secret, invalid
licenses affect old and new pods.
Once a valid `License` resource is applied, new pods will begin to start up normally.
Licenses are validated when the `License` resource is applied. If the license
is invalid when you attempt to apply it, the InfluxDB clustered license
controller will not add or update the required secret.
After you apply a valid `License` resource, new pods will begin to start up normally.
InfluxDB validates a license when you apply it.
If the license is invalid when you try to apply it, the `license controller`
won't add or update the required secret.
## Renew your license
In advance of your license expiration, your InfluxData sales representative will
contact you regarding license renewal.
Before your license expires, your InfluxData sales representative will
contact you about license renewal.
You may also contact your sales representative at any time.
---

View File

@ -40,6 +40,8 @@ To deactivate license enforcement, remove the `useLicensedBinaries` feature flag
3. Use `kubectl` to apply and create the `License` resource in your InfluxDB
namespace:
<!--pytest.mark.skip-->
```sh
kubectl apply --filename license.yml --namespace influxdb
```
@ -101,4 +103,83 @@ spec:
Replace {{% code-placeholder-key %}}`PACKAGE_VERSION`{{% /code-placeholder-key %}} with
the version number to upgrade to.
## Troubleshoot licensing
After you have activated licensing, use the following signals to verify licensing
and troubleshoot issues with your {{< product-name omit="Clustered" >}}
cluster.
In your commands, replace the following:
- {{% code-placeholder-key %}}`NAMESPACE`{{% /code-placeholder-key %}}:
your [InfluxDB namespace](/influxdb/clustered/install/configure-cluster/#create-a-namespace-for-influxdb)
- {{% code-placeholder-key %}}`POD_NAME`{{% /code-placeholder-key %}}:
your [InfluxDB Kubernetes pod](/influxdb/clustered/install/deploy/#inspect-cluster-pods)
### Verify database components
After you [install your license](#install-your-influxdb-license),
run the following command to check that database pods start up and are in the
`Running` state:
<!--pytest.mark.skip-->
{{% code-placeholders "NAMESPACE" %}}
```sh
kubectl get pods -l app=iox --namespace NAMESPACE
```
{{% /code-placeholders %}}
If a `Pod` fails to start, run the following command to view pod information:
<!--pytest.mark.skip-->
{{% code-placeholders "POD_NAME|NAMESPACE" %}}
```sh
kubectl describe pod POD_NAME --namespace NAMESPACE
```
{{% /code-placeholders %}}
### Verify the `Secret` exists
Run the following command to verify that the licensing activation created a
`iox-license` secret:
<!--pytest.mark.skip-->
{{% code-placeholders "NAMESPACE" %}}
```sh
kubectl get secret iox-license --namespace NAMESPACE
```
If the secret doesn't exist,
[view `license-controller` logs](#view-license-controller-logs) for
more information or errors.
{{% /code-placeholders %}}
### View `license controller` logs
The `license controller` component creates a `Secret` named `iox-license` from your
`License`.
To view `license controller` logs for troubleshooting, run the following
command:
<!--pytest.mark.skip-->
{{% code-placeholders "NAMESPACE" %}}
```sh
kubectl logs deployment/license-controller --namespace NAMESPACE
```
{{% /code-placeholders %}}
{{< page-nav prev="/influxdb/clustered/install/configure-cluster/" prevText="Configure your cluster" next="/influxdb/clustered/install/deploy/" nextText="Deploy your cluster" >}}

View File

@ -12,6 +12,17 @@ weight: 202
canonical: /influxdb/cloud-dedicated/reference/release-notes/influxctl/
---
## v2.9.4 {date="2024-07-25"}
### Bug Fixes
- Resolve crash when parsing error message and authentication was null.
### Dependency Updates
- Update `golang.org/x/mod` from 0.18.0 to 0.19.0
- Update `google.golang.org/grpc` from 1.64.0 to 1.65.0
## v2.9.3 {date="2024-06-26"}
### Bug Fixes

View File

@ -55,7 +55,7 @@ influxdb_cloud_dedicated:
list_order: 3
latest: cloud-dedicated
link: "https://www.influxdata.com/contact-sales-form/"
latest_cli: 2.9.3
latest_cli: 2.9.4
placeholder_host: cluster-id.a.influxdb.io
influxdb_clustered: