InfluxDBClient for interacting with an InfluxDB server, simplifying common operations such as writing, querying.

Constructors

  • Creates a new instance of the InfluxDBClient from ClientOptions.

    Parameters

    Returns default

  • Creates a new instance of the InfluxDBClient from connection string.

    Parameters

    • connectionString: string

      connection string

    Returns default

    https://us-east-1-1.aws.cloud2.influxdata.com/?token=my-token&database=my-database

    Supported query parameters:
    - token - authentication token (required)
    - authScheme - token authentication scheme. Not set for Cloud access, set to 'Bearer' for Edge.
    - database - database (bucket) name
    - timeout - I/O timeout
    - precision - timestamp precision when writing data
    - gzipThreshold - payload size threshold for gzipping data
  • Creates a new instance of the InfluxDBClient from environment variables.

    Supported variables:

    • INFLUX_HOST - cloud/server URL (required)
    • INFLUX_TOKEN - authentication token (required)
    • INFLUX_AUTH_SCHEME - token authentication scheme. Not set for Cloud access, set to 'Bearer' for Edge.
    • INFLUX_TIMEOUT - I/O timeout
    • INFLUX_DATABASE - database (bucket) name
    • INFLUX_PRECISION - timestamp precision when writing data
    • INFLUX_GZIP_THRESHOLD - payload size threshold for gzipping data

    Returns default

Methods

  • Execute a query and return the results as an async generator.

    Parameters

    • query: string

      The query string.

    • Optionaldatabase: string

      The name of the database to query.

    • queryOptions: Partial<QueryOptions> = ...

      The options for the query (default: { type: 'sql' }).

    Returns AsyncGenerator<Record<string, any>, void, void>

    An async generator that yields maps of string keys to any values.

       client.query('SELECT * from net', 'traffic_db', {
    type: 'sql',
    headers: {
    'channel-pref': 'eu-west-7',
    'notify': 'central',
    },
    })
  • Execute a query and return the results as an async generator.

    Parameters

    • query: string

      The query string.

    • Optionaldatabase: string

      The name of the database to query.

    • queryOptions: Partial<QueryOptions> = ...

      The type of query (default: {type: 'sql'}).

    Returns AsyncGenerator<PointValues, void, void>

    An async generator that yields PointValues object.

    client.queryPoints('SELECT * FROM cpu', 'performance_db', {
    type: 'sql',
    params: {register: 'rax'},
    })