InfluxDB PHP Client
Public Member Functions | Public Attributes | List of all members
InfluxDB2\Client Class Reference

Public Member Functions

 __construct (array $options)
 
 createWriteApi (array $writeOptions=null, array $pointSettings=null)
 
 createUdpWriter ()
 
 createQueryApi ()
 
 health ()
 
 ping ()
 
 close ()
 
 getConfiguration ()
 
 createService ($serviceClass)
 

Public Attributes

const VERSION = 'dev'
 
 $options
 
 $closed = false
 

Detailed Description

@template T

Constructor & Destructor Documentation

◆ __construct()

InfluxDB2\Client::__construct ( array  $options)

Client constructor.

Example how to create a client:

 client = new Client([
     "url" => "http://localhost:8086",
     "token" => "my-token",
     "bucket" => "my-bucket",
     "precision" => WritePrecision::NS,
     "org" => "my-org",
     "debug" => false,
     "logFile" => "php://output",
     "tags" => ['id' => '1234',
         'hostname' => '${env.Hostname}'],
     "timeout" => 2,
     "ipVersion" => 6,
     ]);

Client can be configured with following properties:

  • url: InfluxDB server API url (ex. http://localhost:8086).
  • token: auth token
  • bucket: destination bucket for writes
  • org: organization bucket for writes
  • precision: precision for the unix timestamps within the body line-protocol
  • verifySSL: Turn on/off SSL certificate verification. Set to false to disable certificate verification.
  • debug: enable verbose logging of http requests
  • logFile: log output
  • tags: default tags
  • timeout: The number of seconds to wait while trying to connect to a server. Use 0 to wait indefinitely.
  • proxy: Pass a string to specify an HTTP proxy, or an array to specify different proxies for different protocols.
  • allow_redirects: Describes the redirect behavior for requests.
  • ipVersion: Specifies which version of IP to use, supports 4 and 6 as possible values (UDP Writer).
Parameters
array$options

Member Function Documentation

◆ close()

InfluxDB2\Client::close ( )

Close all connections into InfluxDB

◆ createQueryApi()

InfluxDB2\Client::createQueryApi ( )

Get the Query client.

Returns
QueryApi

◆ createService()

InfluxDB2\Client::createService (   $serviceClass)

Creates the instance of api service

Parameters
$serviceClass
Returns
object service instance

◆ createUdpWriter()

InfluxDB2\Client::createUdpWriter ( )
Returns
UdpWriter
Exceptions

Exception

◆ createWriteApi()

InfluxDB2\Client::createWriteApi ( array  $writeOptions = null,
array  $pointSettings = null 
)

Write time series data into InfluxDB through the WriteApi. $writeOptions = [ 'writeType' => methods of write (WriteType::SYNCHRONOUS - default, WriteType::BATCHING) 'batchSize' => the number of data point to collect in batch ]

Parameters
array | null$writeOptionsArray containing the write parameters (See above)
array | null$pointSettingsArray of default tags
Returns
WriteApi

◆ health()

InfluxDB2\Client::health ( )

Get the health of an instance.

Deprecated:
Use ping() instead
Returns
HealthCheck

◆ ping()

InfluxDB2\Client::ping ( )

Checks the status of InfluxDB instance and version of InfluxDB.

Returns
array with response headers: 'X-Influxdb-Build', 'X-Influxdb-Version'

Member Data Documentation

◆ VERSION

const InfluxDB2\Client::VERSION = 'dev'

Client version updated by: 'make release VERSION=1.5.0'


The documentation for this class was generated from the following file: