Home Manual Reference Source Test

Typedef

Static Public Summary
public

FieldType is an enumeration of InfluxDB field data types.

public

FieldType is an enumeration of InfluxDB field data types.

public

A IClusterConfig can be provided into new InfluxDB(config) when you have a multiple Influx nodes to connect to.

public

IPingStats is returned from InfluxDB#ping.

public

IPoint is passed to the client's write methods to store a point in InfluxDB.

public

Pool options can be passed into the database to configure the behaviour of the connection pool.

public

The IQueryOptions allow you to configure how queries are run against Influx.

public

Schema options can be passed into the new InfluxDB() constructor to help define the shape of your data.

public

A ISingleHostConfig can be provided into new InfluxDB(config) when you have a single Influx address to connect to.

public

IWriteOptions configure how points are written in the database.

Static Public

public FieldType: Number source

FieldType is an enumeration of InfluxDB field data types.

Example:

import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType

const schema = {
  measurement: 'my_measurement',
  fields: {
    my_int: FieldType.INTEGER,
    my_float: FieldType.FLOAT,
    my_string: FieldType.STRING,
    my_boolean: FieldType.BOOLEAN,
  }
}

public FieldType: Number source

FieldType is an enumeration of InfluxDB field data types.

Example:

import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType

const schema = {
  measurement: 'my_measurement',
  fields: {
    my_int: FieldType.INTEGER,
    my_float: FieldType.FLOAT,
    my_string: FieldType.STRING,
    my_boolean: FieldType.BOOLEAN,
  }
}

public IClusterConfig: Object source

A IClusterConfig can be provided into new InfluxDB(config) when you have a multiple Influx nodes to connect to.

Properties:

NameTypeAttributeDescription
username String
  • optional
  • default: 'root'

Username for connecting to the database.

password String
  • optional
  • default: 'root'

Password for connecting to the database.

database String
  • optional

Default database to operate on. Providing this will let you omit database names in most operations, and is convenient if your app is primarily dealing with a single database.

hosts Array

A list of Influx hosts to connect to.

hosts.host String
  • optional
  • default: '127.0.0.1'

Influx host to connect to.

hosts.port Number
  • optional
  • default: 8086

Influx port to connect to.

hosts.protocol String
  • optional
  • default: 'http'

Protocol to connect over, either 'http' or 'https'.

hosts.options https.RequestOptions
  • optional
  • default: {}

Option overrides to use in passing to http.request or https.request.

pool IPoolOptions
  • optional

Options for the connection pool.

schema ISchemaOptions[]
  • optional

An optional list of data schema to use.

Example:

import { InfluxDB } from 'influx'; // or const InfluxDB = require('influx').InfluxDB

// Connect to a single host with a full set of config details and
// a custom schema
const client = new InfluxDB({
  database: 'my_db',
  username: 'connor',
  password: 'pa$$w0rd',
  hosts: [
    { host: 'db1.example.com' },
    { host: 'db2.example.com' },
  ]
  schema: [{
    measurement: 'perf',
    tags: ['hostname'],
    fields: {
      memory_usage: FieldType.INTEGER,
      cpu_usage: FieldType.FLOAT,
      is_online: FieldType.BOOLEAN,
    }
  }]
})

public IPingStats: Object source

IPingStats is returned from InfluxDB#ping.

Properties:

NameTypeAttributeDescription
url Url

URL is the host's URL

online Boolean

Whether the request was completed successfully.

res http.ServerResponse

The raw response from the server, may be null on a timeout or HTTP error.

rtt Number

Total time the server took to respond, in milliseconds

version String

Version number the server reports to run

public IPoint: Object source

IPoint is passed to the client's write methods to store a point in InfluxDB.

Properties:

NameTypeAttributeDescription
measurement String

Measurement is the Influx measurement name.

tags Object<String, String>
  • optional

Tags is the list of tag values to insert.

fields Object<String, *>
  • optional

Fields is the list of field values to insert.

timestamp Date | string | number
  • optional

Specifies a timestamp for this point. This can be a Date object, in which case we'll adjust it to the desired precision, or a numeric string or number, in which case it gets passed directly to Influx.

public IPoolOptions: Object source

Pool options can be passed into the database to configure the behaviour of the connection pool.

Properties:

NameTypeAttributeDescription
maxRetries Number
  • optional
  • default: 2

Number of times we should retry running a query before calling back with an error.

requestTimeout Number
  • optional
  • default: 30000

The length of time after which HTTP requests will error if they do not receive a response.

backoff IBackoffStrategy
  • optional

The backoff strategy to use for unhealthy connections. Defaults to an exponential backoff with an initial delay of 300ms and a maximum delay of 10 seconds.

public IQueryOptions: Object source

The IQueryOptions allow you to configure how queries are run against Influx.

Properties:

NameTypeAttributeDescription
precision TimePrecision
  • optional

Defines the precision at which to query points. Defaults to querying in nanosecond precision.

retentionPolicy String
  • optional

Retention policy to query from, defaults to the DEFAULT retention policy.

database String
  • optional

Database under which to query the points. This is required if a database is not provided in Influx client.

public ISchemaOptions: Object source

Schema options can be passed into the new InfluxDB() constructor to help define the shape of your data. Each schema config corresponds to a measurement in Influx

It's recommended, but not required, that you make use of schema; internally we use them to be smarter about coercing your data, and providing immediate error feedback if you try to write data which doesn't fit in your schema: either if you include tags of fields which are not present in your schema, or you enter the wrong datatype for one of your schema fields.

Properties:

NameTypeAttributeDescription
database String
  • optional

The database where the measurement lives. This is required if you don't provide a default database in Influx.

measurement String

The measurement name in Influx this refers to

fields Object<String, FieldType>

A mapping of fields names to their data types. It's assumed that this is a comprehensive mapping of every field you might write.

tags String[]

A list of tag names in this measurement. It's assumed that this is a comprehensive list of every tag you might write.

Example:

{
  measurement: 'perf',
  tags: ['hostname'],
  fields: {
    memory_usage: FieldType.INTEGER,
    cpu_usage: FieldType.FLOAT,
    is_online: FieldType.BOOLEAN,
  }
}

public ISingleHostConfig: Object source

A ISingleHostConfig can be provided into new InfluxDB(config) when you have a single Influx address to connect to.

Properties:

NameTypeAttributeDescription
username String
  • optional
  • default: 'root'

Username for connecting to the database.

password String
  • optional
  • default: 'root'

Password for connecting to the database.

database String
  • optional

Default database to operate on. Providing this will let you omit database names in most operations, and is convenient if your app is primarily dealing with a single database.

host String
  • optional
  • default: '127.0.0.1'

Influx host to connect to.

port Number
  • optional
  • default: 8086

Influx port to connect to.

protocol String
  • optional
  • default: 'http'

Protocol to connect over, either 'http' or 'https'.

options https.RequestOptions
  • optional
  • default: {}

Option overrides to use in passing to http.request or https.request.

pool IPoolOptions
  • optional

Options for the connection pool.

schema ISchemaOptions[]
  • optional

An optional list of data schema to use.

Example:

import { InfluxDB } from 'influx'; // or const InfluxDB = require('influx').InfluxDB

// Connect to a single host with a full set of config details and
// a custom schema
const client = new InfluxDB({
  database: 'my_db',
  host: 'localhost',
  port: 8086,
  username: 'connor',
  password: 'pa$$w0rd',
  schema: [{
    measurement: 'perf',
    tags: ['hostname'],
    fields: {
      memory_usage: FieldType.INTEGER,
      cpu_usage: FieldType.FLOAT,
      is_online: FieldType.BOOLEAN,
    }
  }]
})

public IWriteOptions: Object source

IWriteOptions configure how points are written in the database.

Properties:

NameTypeAttributeDescription
precision TimePrecision
  • optional

Precision at which the points are written, defaults to milliseconds 'ms'. Influx recommends that you use the coarsest precision possible in order to maximize efficiency.

retentionPolicy String
  • optional

The retention policy to insert the points under, uses the DEFAULT policy if not provided.

database String
  • optional

The database to insert the points in, uses the adapter's default database if not provided.