Class ClientConfig

java.lang.Object
com.influxdb.v3.client.config.ClientConfig

public final class ClientConfig extends Object
The ClientConfig holds the configurations for the InfluxDBClient client.

You can configure following properties:

  • host - hostname or IP address of the InfluxDB server
  • token - authentication token for accessing the InfluxDB server
  • organization - organization to be used for operations
  • database - database to be used for InfluxDB operations
  • writePrecision - precision to use when writing points to InfluxDB
  • defaultTags - defaultTags added when writing points to InfluxDB
  • gzipThreshold - threshold when gzip compression is used for writing points to InfluxDB
  • responseTimeout - timeout when connecting to InfluxDB
  • allowHttpRedirects - allow redirects for InfluxDB connections
  • disableServerCertificateValidation - disable server certificate validation for HTTPS connections
  • proxy - HTTP proxy selector
  • authenticator - HTTP proxy authenticator
  • headers - headers to be added to requests

If you want to create a client with custom configuration, you can use following code:

 ClientConfig config = new ClientConfig.Builder()
     .host("https://us-east-1-1.aws.cloud2.influxdata.com")
     .token("my-token".toCharArray())
     .database("my-database")
     .writePrecision(WritePrecision.S)
     .gzipThreshold(4096)
     .proxy(ProxySelector.of(new InetSocketAddress("proxy.local", 8888)))
     .build();

 try (InfluxDBClient client = InfluxDBClient.getInstance(config)) {
     //
     // your code here
     //
 } catch (Exception e) {
     throw new RuntimeException(e);
 }
 
Immutable class.
  • Method Details

    • getHost

      @Nonnull public String getHost()
      Gets URL of the InfluxDB server.
      Returns:
      URL of the InfluxDB server
    • getToken

      @Nullable public char[] getToken()
      Gets authentication token for accessing the InfluxDB server.
      Returns:
      authentication token for accessing the InfluxDB server, may be null
    • getOrganization

      @Nullable public String getOrganization()
      Gets organization to be used for operations.
      Returns:
      organization to be used for operations, may be null
    • getDatabase

      @Nullable public String getDatabase()
      Gets database to be used for InfluxDB operations.
      Returns:
      database to be used for InfluxDB operations, may be null
    • getWritePrecision

      @Nullable public WritePrecision getWritePrecision()
      Gets the default precision to use for the timestamp of points. If no precision is specified then 'ns' is used.
      Returns:
      the default precision to use for the timestamp of points, may be null
    • getGzipThreshold

      @Nonnull public Integer getGzipThreshold()
      Gets the threshold for compressing request body using GZIP.
      Returns:
      the threshold in bytes
    • getDefaultTags

      public Map<String,String> getDefaultTags()
      Gets default tags used when writing points.
      Returns:
      default tags
    • getTimeout

      @Nonnull public Duration getTimeout()
      Gets the default timeout to use for the API calls. Default to '10 seconds'.
      Returns:
      the default timeout to use for the API calls
    • getAllowHttpRedirects

      @Nonnull public Boolean getAllowHttpRedirects()
      Gets the automatically following HTTP 3xx redirects. Default to 'false'.
      Returns:
      the automatically following HTTP 3xx redirects
    • getDisableServerCertificateValidation

      @Nonnull public Boolean getDisableServerCertificateValidation()
      Gets the disable server SSL certificate validation. Default to 'false'.
      Returns:
      the disable server SSL certificate validation
    • getProxy

      @Nullable public ProxySelector getProxy()
      Gets the proxy.
      Returns:
      the proxy, may be null
    • getAuthenticator

      @Nullable public Authenticator getAuthenticator()
      Gets the (proxy) authenticator.
      Returns:
      the (proxy) authenticator
    • getHeaders

      @Nullable public Map<String,String> getHeaders()
      Gets custom headers for requests.
      Returns:
      the headers
    • validate

      public void validate()
      Validates the configuration properties.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object