Typedef
Static Public Summary | ||
public |
A ConnectionConfiguration must be provided when calling Connection.create so that you can start writing data into InfluxDB. |
|
public |
DataPoint can be passed into |
|
public |
Field is a key-value pair in InfluxDB’s data structure that records metadata and the actual data value. |
|
public |
FieldType is an enumeration of InfluxDB field data types. |
|
public |
This is the main import of the influxdb-node.js package. |
|
public |
Schema describes tags and fields that can be used with a measurement. |
|
public |
Tag is a key-value pair in InfluxDB’s data structure that records metadata. |
Static Public
public ConnectionConfiguration: Object source
A ConnectionConfiguration must be provided when calling Connection.create so that you can start writing data into InfluxDB.
Properties:
Name | Type | Attribute | Description |
username | String |
|
Username for connecting to the database. |
password | String |
|
Password for connecting to the database. |
database | String |
|
Database to work with |
autoCreateDatabase | Boolean |
|
Automatically create database if it doesn't exist yet. To successfully connect to InfluxDB with autoCreateDatabase=true the database user authentication must be turned off or you must have admin privileges granted |
hostUrl | String |
|
InfluxDB host url to connect to. For InfluxCloud use https scheme and don't forget to pass username and password properties. For UDP access use a URL in the following form: udp://127.0.0.1:8089. For more information on using the UDP InfluxDB service check the documentation https://github.com/influxdata/influxdb/blob/master/services/udp/README.md |
schema | Schema[] |
|
schema of measurements accessed by this connection, validated when writing data points into InfluxDB. See Schema for more information. |
autoGenerateTimestamps | Boolean |
|
When writing data points without a timestamp:
|
batchSize | Number |
|
Number of data points in a batch. Data points written into the InfluxDBConnection are buffered in the connection until the batch size is reached or maximumWriteDelay is reached (see below.) To learn more about batching see Connection.write. |
maximumWriteDelay | Number |
|
Maximum number of milliseconds the data point can be buffered in the InfluxDBConnection. When this limit is reached for a single data point written, any older data points are also written into InfluxDB. To learn more about batching see Connection.write. |
autoResolveBufferedWritePromises | Boolean |
|
if true the Promise returned by Connection.write will be automatically resolved when the data are put into the buffer. This is useful for larger batch sizes for performance reasons and to avoid pollution of log files (there will be just one error generated for the whole batch on the last accepted Connection.write invocation). If false the Promise returned by Connection.write will always get rejected or resolved when the data points are written into InfluxDB. See more at Connection.write. |
batchWriteErrorHandler | function |
|
handler called when batch write to InfluxDB fails and the autoResolveBufferedWritePromises configuration property is set to true. This is useful in the case when the batch write gets triggered due to maximumWriteDelay expiration. See the example below: To learn more about batching see Connection.write. |
Example:
const InfluxDB = require('influx-nodejs')
// Connect to a single host with a full set of config details and
// a custom schema
const connection = new InfluxDB.Connection({
database: 'my_db',
username: 'influxUser33',
password: 'awesomeflux!',
hostUrl: 'http://db1.example.com:8086' },
schema: [{
measurement: 'serverLoad',
tags: ['hostname'],
fields: {
memory_usage: InfluxDB.FieldType.INTEGER,
cpu_usage: InfluxDB.FieldType.FLOAT,
is_online: InfluxDB.FieldType.BOOLEAN,
}
}],
batchWriteErrorHandler(e, dataPoints) { // this is the same as the default value
console.log('[DefaultBatchWriteErrorHandler] Error writing data points into InfluxDB:' +
dataPoints,e);
}
})
public DataPoint: Object source
DataPoint can be passed into Connection.write(dataPoint)
method
so that you can write points to the database.
See: https://docs.influxdata.com/influxdb/latest/introduction/getting_started/#writing-and-exploring-data
Properties:
Name | Type | Attribute | Description |
measurement | String | Name of the measurement |
|
timestamp | Date | String | Number |
|
timestamp of the measurement point. You can pass the following type of values:
|
tags | Tag[] | Object | Tags to be stored together with the data point. Two formats are supported:
|
|
fields | Field[] | Object | Fields to be stored together with the data point. Two formats are supported:
|
Example:
let dataPoint1={
measurement : 'outdoorThermometer',
timestamp: '1465839830100400200',
tags: { location: 'outdoor' },
fields: { temperature: 18.3 }
}
let dataPoint2={
measurement : 'outdoorThermometer',
timestamp: '1465839831270501600',
tags: [ { key: 'location', value: 'greenhouse' } ]
fields: [ { key: 'temperature', value: 23.7 } ]
}
public Field: Object source
Field is a key-value pair in InfluxDB’s data structure that records metadata and the actual data value. See: https://docs.influxdata.com/influxdb/latest/concepts/glossary/#field
Example:
let field={
key: 'temperature',
value: 23.7
}
public FieldType: Number source
FieldType is an enumeration of InfluxDB field data types.
Example:
const schema = {
measurement: 'my_measurement',
fields: {
my_int: FieldType.INTEGER,
my_float: FieldType.FLOAT,
my_string: FieldType.STRING,
my_boolean: FieldType.BOOLEAN
}
}
public InfluxDB: Object source
This is the main import of the influxdb-node.js package.
Properties:
Name | Type | Attribute | Description |
Connection | Connection | reference to the Connection object |
|
FieldType | FieldType | reference to the FieldType object, used to define measurement schemas |
Example:
const InfluxDB=require('influxdb-nodejs');
const connection=new InfluxDB.Connection({
hostUrl: 'http://localhost:8086',
database: 'mydb'
});
...
public Schema: Object source
Schema describes tags and fields that can be used with a measurement.
It's recommended, but not required to use a schema; it is used to:
- Coerce your data (properly converting JavaScript Number to either floats or integers that are available in InfluxDB)
- Provide immediate error feedback if data supplied to the {@Connection#write} method are not compliant with the schema. An error is signaled when there is a field/tag which is not present in your schema, or the data type of a field does not match the schema.
See FieldType for available field types.
Properties:
Name | Type | Attribute | Description |
measurement | String | Name of the measurement |
|
fields | Object[] |
|
Field names and their corresponding types for the given measurement. If left undefined no field validation will be executed. |
tags | String[] |
|
List of allowed tag names for the measurement. If left undefined no tag validation will be executed. |
Example:
const schema = {
measurement: 'my_measurement',
tags: ['someTag', 'someOtherTag']
fields: {
my_int: InfluxDB.FieldType.INTEGER,
my_float: InfluxDB.FieldType.FLOAT,
my_string: InfluxDB.FieldType.STRING,
my_boolean: InfluxDB.FieldType.BOOLEAN
}
}
public Tag: Object source
Tag is a key-value pair in InfluxDB’s data structure that records metadata. See: https://docs.influxdata.com/influxdb/latest/concepts/glossary/#tag
Example:
let tag={
key: 'location',
value: 'outdoor'
}