influx

  • Version 5.9.2
  • Published
  • 158 kB
  • No dependencies
  • MIT license

Install

npm i influx
yarn add influx
pnpm add influx

Overview

InfluxDB Client

Index

Variables

Functions

Classes

Interfaces

Enums

Type Aliases

Variables

variable escape

const escape: {
measurement: (val: string) => string;
quoted: (val: string) => string;
stringLit: (val: string) => string;
tag: (val: string) => string;
};
  • TagEscaper escapes tag keys, tag values, and field keys. {Object} {function(s: string): string } quoted Escapes and wraps quoted values, such as database names. {function(s: string): string } stringLit Escapes and wraps string literals. {function(s: string): string } measurement Escapes measurement names on the line protocol. {function(s: string): string } tag Escapes tag keys, take values, and field keys on the line protocol.

    Example 1

    console.log(escape.quoted('my_"db')); // => "my_"db" console.log(escape.stringLit('hello'world')); // => 'hello'world'

    console.log(escape.measurement('my measurement')); // => my\ measurement console.log(escape.tag('my tag=')); // => my\ tag=

variable Precision

const Precision: Readonly<{
Hours: string;
Microseconds: string;
Milliseconds: string;
Minutes: string;
Nanoseconds: string;
Seconds: string;
}>;
  • Precision is a map of available Influx time precisions. {Object.<String, String>}

    Example 1

    console.log(Precision.Hours); // => 'h' console.log(Precision.Minutes); // => 'm' console.log(Precision.Seconds); // => 's' console.log(Precision.Milliseconds); // => 'ms' console.log(Precision.Microseconds); // => 'u' console.log(Precision.Nanoseconds); // => 'n'

Functions

function parseMeasurement

parseMeasurement: (q: measurement) => string;

    function parseWhere

    parseWhere: (q: where) => string;

      function toNanoDate

      toNanoDate: (timestamp: string) => INanoDate;
      • Covers a nanoseconds unix timestamp to a INanoDate for node-influx. The timestamp is provided as a string to prevent precision loss.

        Please see [A Moment for Times](https://node-influx.github.io/manual/ usage.html#a-moment-for-times) for a more complete and eloquent explanation of time handling in this module.

        Parameter timestamp

        Example 1

        const date = toNanoDate('1475985480231035600')

        // You can use the returned Date as a normal date: expect(date.getTime()).to.equal(1475985480231);

        // We decorate it with two additional methods to read // nanosecond-precision results: expect(date.getNanoTime()).to.equal('1475985480231035600'); expect(date.toNanoISOString()).to.equal('2016-10-09T03:58:00.231035600Z');

      Classes

      class Expression

      class Expression implements IExpressionHead, IExpressionTail, IBinaryOp {}
      • Expression is used to build filtering expressions, like those used in WHERE clauses. It can be used for fluent and safe building of queries using untrusted input.

        Example 1

        e => e .field('host').equals.value('ares.peet.io') .or .field('host').matches(/example.com$/) .or .expr(e => e .field('country').equals.value('US') .and .field('state').equals.value('WA'));

        // Generates: // "host" = 'ares.peet.io' OR "host" ~= /example.com$/ OR \ // ("county" = 'US' AND "state" = 'WA')

      property and

      readonly and: Expression;
      • Chains on an AND clause to the expression.

      property div

      readonly div: Expression;
      • Chains on a / operator to the expression.

      property doesntMatch

      readonly doesntMatch: Expression;
      • Chains on a !` conditional to the expression to match regexes.

      property equals

      readonly equals: Expression;
      • Chains on a = conditional to the expression.

      property gt

      readonly gt: Expression;
      • Chains on a > conditional to the expression.

      property gte

      readonly gte: Expression;
      • Chains on a >= conditional to the expression.

      property lt

      readonly lt: Expression;
      • Chains on a < conditional to the expression.

      property lte

      readonly lte: Expression;
      • Chains on a <= conditional to the expression.

      property matches

      readonly matches: Expression;
      • Chains on a =~ conditional to the expression to match regexes.

      property minus

      readonly minus: Expression;
      • Chains on a - operator to the expression.

      property notEqual

      readonly notEqual: Expression;
      • Chains on a != conditional to the expression.

      property or

      readonly or: Expression;
      • Chains on an OR clause to the expression.

      property plus

      readonly plus: Expression;
      • Chains on a + operator to the expression.

      property times

      readonly times: Expression;
      • Chains on a * operator to the expression.

      method exp

      exp: (fn: (e: Expression) => Expression) => this;
      • Inserts a subexpression; invokes the function with a new expression that can be chained on.

        Parameter fn

        Example 1

        e.field('a').equals.value('b') .or.expr(e => e.field('b').equals.value('b') .and.field('a').equals.value('c')) .toString() // "a" = 'b' OR ("b" = 'b' AND "a" = 'c')

      method field

      field: (name: string) => this;
      • Inserts a field reference into the expression; the name will be automatically escaped.

        Parameter name

      method tag

      tag: (name: string) => this;
      • Inserts a tag reference into the expression; the name will be automatically escaped.

        Parameter name

      method toString

      toString: () => string;
      • Converts the expression into its InfluxQL representation.

      method value

      value: (value: any) => this;
      • Value chains on a value to the expression.

        - Numbers will be inserted verbatim - Strings will be escaped and inserted - Booleans will be inserted correctly - Dates will be formatted and inserted correctly, including INanoDates. - Regular expressions will be inserted correctly, however an error will be thrown if they contain flags, as regex flags do not work in Influx - Otherwise we'll try to call .toString() on the value, throwing if we cannot do so.

        Parameter value

      class InfluxDB

      class InfluxDB {}
      • InfluxDB is the public interface to run queries against your database. This is a 'driver-level' module, not a a full-fleged ORM or ODM; you run queries directly by calling methods on this class.

        Please check out some of [the tutorials](https://node-influx.github.io/manual/tutorial.html) if you want help getting started!

        Example 1

        const Influx = require('influx'); const influx = new Influx.InfluxDB({ host: 'localhost', database: 'express_response_db', schema: [ { measurement: 'response_times', fields: { path: Influx.FieldType.STRING, duration: Influx.FieldType.INTEGER }, tags: [ 'host' ] } ] })

        Example 2

        // Connect over HTTPS const Influx = require('influx'); const influx = new Influx.InfluxDB({ host: 'myinfluxdbhost', port: 443, protocol: 'https' database: 'express_response_db', schema: [ { measurement: 'response_times', fields: { path: Influx.FieldType.STRING, duration: Influx.FieldType.INTEGER }, tags: [ 'host' ] } ] })

        influx.writePoints([ { measurement: 'response_times', tags: { host: os.hostname() }, fields: { duration, path: req.path }, } ]).then(() => { return influx.query(` select * from response_times where host = $ order by time desc limit 10 `, { placeholders: { host: os.hostname() } }) }).then(rows => { rows.forEach(row => console.log(A request to ${row.path} took ${row.duration}ms)) })

      constructor

      constructor(options: ISingleHostConfig);

        constructor

        constructor(options: IClusterConfig);
        • Connect to an InfluxDB cluster by specifying a set of connection options.

        constructor

        constructor(url: string);
        • Connect to an InfluxDB instance using a configuration URL.

          Example 1

          new InfluxDB('http://user:password@host:8086/database')

        constructor

        constructor();
        • Connects to a local, default Influx instance.

        method addSchema

        addSchema: (schema: ISchemaOptions) => void;
        • Adds specified schema for better fields coercing.

          Parameter schema

          InfluxDB

        method alterRetentionPolicy

        alterRetentionPolicy: (
        name: string,
        options: IRetentionOptions
        ) => Promise<void>;
        • Alters an existing retention policy on a database.

          Parameter name

          The retention policy name

          Parameter options

          Parameter

          [options.database] Database to create the policy on, uses the default database if not provided.

          Parameter

          options.duration How long data in the retention policy should be stored for, should be in a format like 7d. See details [here](https://docs.influxdata.com/influxdb/v1.0/query_language/spec/#durations)

          Parameter

          options.replication How many servers data in the series should be replicated to.

          Parameter

          [options.default] Whether the retention policy should be the default policy on the database.

          Example 1

          influx.alterRetentionPolicy('7d', { duration: '7d', replication: 1, default: true })

        method createContinuousQuery

        createContinuousQuery: (
        name: string,
        query: string,
        database?: string,
        resample?: string
        ) => Promise<void>;
        • Creates a continuous query in a database

          Parameter name

          The query name, for later reference

          Parameter query

          The body of the query to run

          Parameter database

          If not provided, uses the default database.

          Parameter resample

          If provided, adds resample policy

          Example 1

          influx.createContinuousQuery('downsample_cpu_1h', ` SELECT MEAN(cpu) INTO "7d"."perf" FROM "1d"."perf" GROUP BY time(1m) `, undefined, 'RESAMPLE FOR 7m')

        method createDatabase

        createDatabase: (databaseName: string) => Promise<void>;
        • Creates a new database with the provided name.

          Parameter databaseName

          Example 1

          influx.createDatabase('mydb')

        method createRetentionPolicy

        createRetentionPolicy: (
        name: string,
        options: IRetentionOptions
        ) => Promise<void>;
        • Creates a new retention policy on a database. You can read more about [Downsampling and Retention](https://docs.influxdata.com/influxdb/v1.0/ guides/downsampling_and_retention/) on the InfluxDB website.

          Parameter name

          The retention policy name

          Parameter options

          Parameter

          [options.database] Database to create the policy on, uses the default database if not provided.

          Parameter

          options.duration How long data in the retention policy should be stored for, should be in a format like 7d. See details [here](https://docs.influxdata.com/influxdb/v1.0/query_language/spec/#durations)

          Parameter

          options.replication How many servers data in the series should be replicated to.

          Parameter

          [options.isDefault] Whether the retention policy should be the default policy on the database.

          Example 1

          influx.createRetentionPolicy('7d', { duration: '7d', replication: 1 })

        method createUser

        createUser: (
        username: string,
        password: string,
        admin?: boolean
        ) => Promise<void>;
        • Creates a new InfluxDB user.

          Parameter username

          Parameter password

          Parameter admin

          If true, the user will be given all privileges on all databases.

          Example 1

          influx.createUser('connor', 'pa55w0rd', true) // make 'connor' an admin

          // make non-admins: influx.createUser('not_admin', 'pa55w0rd')

        method dropContinuousQuery

        dropContinuousQuery: (name: string, database?: string) => Promise<void>;
        • Creates a continuous query in a database

          Parameter name

          The query name

          Parameter database

          If not provided, uses the default database.

          Example 1

          influx.dropContinuousQuery('downsample_cpu_1h')

        method dropDatabase

        dropDatabase: (databaseName: string) => Promise<void>;
        • Deletes a database with the provided name.

          Parameter databaseName

          Example 1

          influx.dropDatabase('mydb')

        method dropMeasurement

        dropMeasurement: (measurement: string, database?: string) => Promise<void>;
        • Removes a measurement from the database.

          Parameter measurement

          Parameter database

          the database the measurement lives in, optional if a default database is provided.

          Example 1

          influx.dropMeasurement('my_measurement')

        method dropRetentionPolicy

        dropRetentionPolicy: (name: string, database?: string) => Promise<void>;
        • Deletes a retention policy and associated data. Note that the data will not be immediately destroyed, and will hang around until Influx's bi-hourly cron.

          Parameter name

          The retention policy name

          Parameter database

          Database name that the policy lives in, uses the default database if not provided.

          Example 1

          influx.dropRetentionPolicy('7d')

        method dropSeries

        dropSeries: (
        options: b.measurement | b.where | { database: string }
        ) => Promise<void>;
        • Removes a one or more series from InfluxDB.

          Returns

          Example 1

          // The following pairs of queries are equivalent: you can chose either to // use our builder or pass in string directly. The builder takes care // of escaping and most syntax handling for you.

          influx.dropSeries({ where: e => e.tag('cpu').equals.value('cpu8') }) influx.dropSeries({ where: '"cpu" = 'cpu8'' }) // DROP SERIES WHERE "cpu" = 'cpu8'

          influx.dropSeries({ measurement: m => m.name('cpu').policy('autogen') }) influx.dropSeries({ measurement: '"cpu"."autogen"' }) // DROP SERIES FROM "autogen"."cpu"

          influx.dropSeries({ measurement: m => m.name('cpu').policy('autogen'), where: e => e.tag('cpu').equals.value('cpu8'), database: 'my_db' }) // DROP SERIES FROM "autogen"."cpu" WHERE "cpu" = 'cpu8'

        method dropShard

        dropShard: (shard_id: number) => Promise<void>;
        • Drops a shard with the provided number.

          Parameter shard_id

          Example 1

          influx.dropShard(3)

        method dropUser

        dropUser: (username: string) => Promise<void>;
        • Removes a user from the database.

          Parameter username

          Example 1

          influx.dropUser('connor')

        method getDatabaseNames

        getDatabaseNames: () => Promise<string[]>;
        • Returns array of database names. Requires cluster admin privileges.

          Returns

          a list of database names

          Example 1

          influx.getDatabaseNames().then(names => console.log('My database names are: ' + names.join(', ')));

        method getMeasurements

        getMeasurements: (database?: string) => Promise<string[]>;
        • Returns array of measurements.

          Parameter database

          the database the measurement lives in, optional if a default database is provided.

          Returns

          a list of measurement names

          Example 1

          influx.getMeasurements().then(names => console.log('My measurement names are: ' + names.join(', ')));

        method getSeries

        getSeries: (options?: {
        measurement?: string;
        database?: string;
        }) => Promise<string[]>;
        • Returns a list of all series within the target measurement, or from the entire database if a measurement isn't provided.

          Parameter options

          Parameter

          [options.measurement] if provided, we'll only get series from within that measurement.

          Parameter

          [options.database] the database the series lives in, optional if a default database is provided.

          Returns

          a list of series names

          Example 1

          influx.getSeries().then(names => { console.log('My series names in my_measurement are: ' + names.join(', ')) })

          influx.getSeries({ measurement: 'my_measurement', database: 'my_db' }).then(names => { console.log('My series names in my_measurement are: ' + names.join(', ')) })

        method getUsers

        getUsers: () => Promise<IResults<{ user: string; admin: boolean }>>;
        • Returns a list of users on the Influx database.

          Example 1

          influx.getUsers().then(users => { users.forEach(user => { if (user.admin) { console.log(user.user, 'is an admin!') } else { console.log(user.user, 'is not an admin!') } }) })

        method grantAdminPrivilege

        grantAdminPrivilege: (username: string) => Promise<void>;
        • Grants admin privileges to a specified user.

          Parameter username

          Example 1

          influx.grantAdminPrivilege('connor')

        method grantPrivilege

        grantPrivilege: (
        username: string,
        privilege: 'READ' | 'WRITE',
        database?: string
        ) => Promise<void>;
        • Grants a privilege to a specified user.

          Parameter username

          Parameter privilege

          Should be one of 'READ' or 'WRITE'

          Parameter database

          If not provided, uses the default database.

          Example 1

          influx.grantPrivilege('connor', 'READ', 'my_db') // grants read access on my_db to connor

        method parsePoint

        parsePoint: (point: IPoint, options?: IParseOptions) => IParsedPoint;
        • ParsePoint will perform the coercions/schema checks and return the data required for writing a point. This will throw an error if a schema check or coercion fails. This can be useful for flagging or "throwing out" bad points in a batch write to prevent the entire batch from getting aborted

          ---

          A note when using this function, InfluxDB#writePoints will still perform the same checks, so any pre-processed data will be checked for validity twice which has potential performance implications on large data sets

          Parameter point

          Parameter options

          Example 1

          // parse a point as if it is getting written to the default // databse with the default time precision influx.parsePoint({ measurement: 'perf', tags: { host: 'box1.example.com' }, fields: { cpu: getCpuUsage(), mem: getMemUsage() }, })

          // you can manually specify the database and time precision influx.parsePoint({ measurement: 'perf', tags: { host: 'box1.example.com' }, fields: { cpu: getCpuUsage(), mem: getMemUsage() }, }, { precision: 's', database: 'my_db' })

          // if an error occurs, you can catch the error with try...catch try { influx.parsePoint({ measurement: 'perf', tags: { host: 'box1.example.com', myExtraneousTag: 'value' }, fields: { cpu: getCpuUsage(), mem: getMemUsage(), myExtraneousField: 'value' }, }) } catch(err) { handleError(err); }

        method ping

        ping: (timeout: number) => Promise<IPingStats[]>;
        • Pings all available hosts, collecting online status and version info.

          Parameter timeout

          Given in milliseconds

          Example 1

          influx.ping(5000).then(hosts => { hosts.forEach(host => { if (host.online) { console.log(${host.url.host} responded in ${host.rtt}ms running ${host.version})) } else { console.log(${host.url.host} is offline :() } }) })

        method query

        query: {
        <T>(query: string[], options?: IQueryOptions): Promise<Array<IResults<T>>>;
        <T>(query: string, options?: IQueryOptions): Promise<IResults<T>>;
        };

          method queryRaw

          queryRaw: (query: string | string[], options?: IQueryOptions) => Promise<any>;
          • QueryRaw functions similarly to .query() but it does no fancy transformations on the returned data; it calls JSON.parse and returns those results verbatim.

            Parameter query

            Parameter options

            Example 1

            influx.queryRaw('select * from perf').then(rawData => { console.log(rawData) })

          method revokeAdminPrivilege

          revokeAdminPrivilege: (username: string) => Promise<void>;
          • Removes a admin privilege from a specified user.

            Parameter username

            Example 1

            influx.revokeAdminPrivilege('connor')

          method revokePrivilege

          revokePrivilege: (
          username: string,
          privilege: 'READ' | 'WRITE',
          database?: string
          ) => Promise<void>;
          • Removes a privilege from a specified user.

            Parameter username

            Parameter privilege

            Should be one of 'READ' or 'WRITE'

            Parameter database

            If not provided, uses the default database.

            Example 1

            influx.revokePrivilege('connor', 'READ', 'my_db') // removes read access on my_db from connor

          method setPassword

          setPassword: (username: string, password: string) => Promise<void>;
          • Sets a password for an Influx user.

            Parameter username

            Parameter password

            Example 1

            influx.setPassword('connor', 'pa55w0rd')

          method showContinousQueries

          showContinousQueries: (
          database?: string
          ) => Promise<IResults<{ name: string; query: string }>>;
          • Returns a list of continous queries in the database.

            Parameter database

            If not provided, uses the default database.

            Example 1

            influx.showContinousQueries()

          method showRetentionPolicies

          showRetentionPolicies: (
          database?: string
          ) => Promise<
          IResults<{
          default: boolean;
          duration: string;
          name: string;
          replicaN: number;
          shardGroupDuration: string;
          }>
          >;
          • Shows retention policies on the database

            Parameter database

            The database to list policies on, uses the default database if not provided.

            Example 1

            influx.showRetentionPolicies().then(policies => { expect(policies.slice()).to.deep.equal([ { name: 'autogen', duration: '0s', shardGroupDuration: '168h0m0s', replicaN: 1, default: true, }, { name: '7d', duration: '168h0m0s', shardGroupDuration: '24h0m0s', replicaN: 1, default: false, }, ]) })

          method showShards

          showShards: (
          database?: string
          ) => Promise<
          Array<{
          id: number;
          database: string;
          retention_policy: string;
          shard_group: number;
          start_time: string;
          end_time: string;
          expiry_time: string;
          owners: string;
          }>
          >;
          • Shows shards on the database

            Parameter database

            The database to list policies on, uses the default database if not provided.

            Example 1

            influx.showShards().then(shards => { expect(shards.slice()).to.deep.equal([ { id: 1 database: 'database', retention_policy: 'autogen', shard_group: 1, start_time: '2019-05-06T00:00:00Z', end_time: '2019-05-13T00:00:00Z', expiry_time: '2019-05-13T00:00:00Z', owners: null, }, ]) })

          method writeMeasurement

          writeMeasurement: (
          measurement: string,
          points: IPoint[],
          options?: IWriteOptions
          ) => Promise<void>;
          • WriteMeasurement functions similarly to InfluxDB#writePoints, but it automatically fills in the measurement value for all points for you.

            Parameter measurement

            Parameter points

            Parameter options

            Example 1

            influx.writeMeasurement('perf', [ { tags: { host: 'box1.example.com' }, fields: { cpu: getCpuUsage(), mem: getMemUsage() }, } ])

          method writePoints

          writePoints: (points: IPoint[], options?: IWriteOptions) => Promise<void>;
          • WritePoints sends a list of points together in a batch to InfluxDB. In each point you must specify the measurement name to write into as well as a list of tag and field values. Optionally, you can specify the time to tag that point at, defaulting to the current time.

            If you defined a schema for the measurement in the options you passed to new Influx(options), we'll use that to make sure that types get cast correctly and that there are no extraneous fields or columns.

            For best performance, it's recommended that you batch your data into sets of a couple thousand records before writing it. In the future we'll have some utilities within node-influx to make this easier.

            ---

            A note when using manually-specified times and precisions: by default we write using the ms precision since that's what JavaScript gives us. You can adjust this. However, there is some special behaviour if you manually specify a timestamp in your points: - if you specify the timestamp as a Date object, we'll convert it to milliseconds and manipulate it as needed to get the right precision - if provide a INanoDate as returned from toNanoTime or the results from an Influx query, we'll be able to pull the precise nanosecond timestamp and manipulate it to get the right precision - if you provide a string or number as the timestamp, we'll pass it straight into Influx.

            Please see the IPoint and IWriteOptions types for a full list of possible options.

            Parameter points

            Parameter options

            Example 1

            // write a point into the default database with // the default retention policy. influx.writePoints([ { measurement: 'perf', tags: { host: 'box1.example.com' }, fields: { cpu: getCpuUsage(), mem: getMemUsage() }, } ])

            // you can manually specify the database, // retention policy, and time precision: influx.writePoints([ { measurement: 'perf', tags: { host: 'box1.example.com' }, fields: { cpu: getCpuUsage(), mem: getMemUsage() }, timestamp: getLastRecordedTime(), } ], { database: 'my_db', retentionPolicy: '1d', precision: 's' })

          class Measurement

          class Measurement {}
          • Measurement creates a reference to a particular measurement. You can reference it solely by its name, but you can also specify the retention policy and database it lives under.

            Example 1

            m.name('my_measurement') // "my_measurement" m.name('my_measurement').policy('one_day') // "one_day"."my_measurement" m.name('my_measurement').policy('one_day').db('mydb') // "mydb"."one_day"."my_measurement"

          method db

          db: (db: string) => this;
          • Sets the database name.

            Parameter db

          method name

          name: (name: string) => this;
          • Sets the measurement name.

            Parameter name

          method policy

          policy: (retentionPolicy: string) => this;
          • Sets the retention policy name.

            Parameter retentionPolicy

          method toString

          toString: () => string;
          • Converts the measurement into its InfluxQL representation.

            Throws

            {Error} if a measurement name is not provided

          class Raw

          class Raw {}
          • You can provide Raw values to Influx methods to prevent it from escaping your provided string.

            Example 1

            influx.createDatabase(new Influx.Raw('This won't be escaped!'));

          constructor

          constructor(value: string);
          • Wraps a string so that it is not escaped in Influx queries.

            Parameter value

            Example 1

            influx.createDatabase(new Influx.Raw('This won't be escaped!'));

          method getValue

          getValue: () => string;
          • Returns the wrapped string.

          class ResultError

          class ResultError extends Error {}
          • A ResultError is thrown when a query generates errorful results from Influx.

          constructor

          constructor(message: string);

            Interfaces

            interface IBaseExpression

            interface IBaseExpression<T> {}

              property field

              field: (name: string) => T;
              • Inserts a field name in the expression.

              property tag

              tag: (name: string) => T;
              • Inserts a tag name in the expression.

              property value

              value: (value: any) => T;
              • Chains on a value to the expression. An error will be thrown if the value is a type we can't represent in InfluxQL, primarily null or undefined.

              interface IBinaryOp

              interface IBinaryOp {}

                property and

                and: IExpressionTail;
                • Adds an 'AND' operator

                property div

                div: IExpressionTail;
                • Adds a '/' division symbol

                property doesntMatch

                doesntMatch: IExpressionTail;
                • Adds a '!~' comparator to select entries not matching a regex.

                property equals

                equals: IExpressionTail;
                • Adds a '=' symbol

                property gt

                gt: IExpressionTail;
                • Adds a '>' symbol

                property gte

                gte: IExpressionTail;
                • Adds a '>=' symbol

                property lt

                lt: IExpressionTail;
                • Adds a '<' symbol

                property lte

                lte: IExpressionTail;
                • Adds a '<=' symbol

                property matches

                matches: IExpressionTail;
                • Adds a '=~' comparator to select entries matching a regex.

                property minus

                minus: IExpressionTail;
                • Adds a '-' subtraction symbol

                property notEqual

                notEqual: IExpressionTail;
                • Adds a '!=' comparator to select entries not equaling a certain value.

                property or

                or: IExpressionTail;
                • Adds an 'OR' operator

                property plus

                plus: IExpressionTail;
                • Adds a '+' addition symbol

                property times

                times: IExpressionTail;
                • Adds a '*' multiplication symbol

                interface IClusterConfig

                interface IClusterConfig {}

                  property database

                  database?: string;
                  • Default database to write information to.

                  property hosts

                  hosts: IHostConfig[];
                  • A list of cluster hosts to connect to.

                  property password

                  password?: string;
                  • Password for connecting to the database. Defaults to 'root'.

                  property pool

                  pool?: IPoolOptions;
                  • Settings for the connection pool.

                  property schema

                  schema?: ISchemaOptions[];
                  • A list of schema for measurements in the database.

                  property username

                  username?: string;
                  • Username for connecting to the database. Defaults to 'root'.

                  interface IExpressionHead

                  interface IExpressionHead extends IBaseExpression<IBinaryOp> {}

                    interface IExpressionTail

                    interface IExpressionTail extends IBaseExpression<IExpressionHead> {}

                      interface IHostConfig

                      interface IHostConfig {}

                        property host

                        host?: string;
                        • Influx host to connect to, defaults to 127.0.0.1.

                        property options

                        options?: RequestOptions;
                        • Optional request option overrides.

                        property path

                        path?: string;
                        • Path for Influx within the host, defaults to ''. May be used if Influx is behind a reverse proxy or load balancer.

                        property port

                        port?: number;
                        • Influx port to connect to, defaults to 8086.

                        property protocol

                        protocol?: 'http' | 'https';
                        • Protocol to connect over, defaults to 'http'.

                        interface INanoDate

                        interface INanoDate extends Date {}

                          property getNanoTime

                          getNanoTime: () => string;
                          • Returns the unix nanoseconds timestamp as a string.

                          property toNanoISOString

                          toNanoISOString: () => string;
                          • Formats the date as an ISO RFC3339 timestamp with nanosecond precision.

                          interface IParsedPoint

                          interface IParsedPoint extends IPoint {}

                            property castedTimestamp

                            castedTimestamp?: string;
                            • Casted Timestamp is the timestamp value after being casted to the desired precision. Default 'n'

                            property fieldsPairs

                            fieldsPairs: Array<[string, string]>;
                            • Fields Pairs is the list of key/value pairs for each field on the point

                            property tagsNames

                            tagsNames: string[];
                            • Tags Names is the list of tag names in the point

                            interface IParseOptions

                            interface IParseOptions {}

                              property database

                              database?: string;
                              • Database under which to write the points. This is required if a default database is not provided in Influx.

                              property precision

                              precision?: grammar.TimePrecision;
                              • Precision at which the points are written, defaults to nanoseconds 'n'.

                              interface IPingStats

                              interface IPingStats {}

                                property online

                                online: boolean;

                                  property res

                                  res: http.IncomingMessage;

                                    property rtt

                                    rtt: number;

                                      property url

                                      url: urlModule.Url;

                                        property version

                                        version: string;

                                          interface IPoint

                                          interface IPoint {}

                                            property fields

                                            fields?: {
                                            [name: string]: any;
                                            };
                                            • Fields is the list of field values to insert.

                                            property measurement

                                            measurement?: string;
                                            • Measurement is the Influx measurement name.

                                            property tags

                                            tags?: {
                                            [name: string]: string;
                                            };
                                            • Tags is the list of tag values to insert.

                                            property timestamp

                                            timestamp?: Date | string | number;
                                            • Timestamp tags this measurement with a date. 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.

                                            interface IPoolOptions

                                            interface IPoolOptions {}

                                              property backoff

                                              backoff?: IBackoffStrategy;
                                              • Options to configure the backoff policy for the pool. Defaults to using exponential backoff.

                                              property maxRetries

                                              maxRetries?: number;
                                              • Number of times we should retry running a query before calling back with an error.

                                              property requestTimeout

                                              requestTimeout?: number;
                                              • The length of time after which HTTP requests will error if they do not receive a response.

                                              interface IQueryOptions

                                              interface IQueryOptions {}

                                                property database

                                                database?: string;
                                                • Database under which to query the points. This is required if a default database is not provided in Influx.

                                                property placeholders

                                                placeholders?: Record<string, string | number>;
                                                • Any placeholders used by the query. Using these is strongly recommended to avoid injection attacks.

                                                property precision

                                                precision?: grammar.TimePrecision;
                                                • Defines the precision at which to query points. When left blank, it will query in nanosecond precision.

                                                property retentionPolicy

                                                retentionPolicy?: string;
                                                • Retention policy to query from, defaults to the DEFAULT database policy.

                                                interface IResponse

                                                interface IResponse {}
                                                • InfluxResults describes the result structure received from InfluxDB.

                                                  NOTE: if you're poking around in Influx, use curl, not the json formatter provided by the CLI. As of 1.0 this formatter changes the result structure and it will confuse you, as it did me ;)

                                                property results

                                                results: IResultEntry[];

                                                  interface IResults

                                                  interface IResults<T> extends Array<T> {}
                                                  • IResultsParser is a user-friendly results tables from raw Influx responses.

                                                  property group

                                                  group: (matcher: Tags) => T[];
                                                  • Group looks for and returns the first group in the results that matches the provided tags.

                                                    If you've used lodash or underscore, we do something quite similar to their object matching: for every row in the results, if it contains tag values matching the requested object, we return it.

                                                    Parameter matcher

                                                    Example 1

                                                    // Matching tags sets in queries: influx.query('select * from perf group by host').then(results => { expect(results.group({ host: 'ares.peet.io'})).to.deep.equal([ { host: 'ares.peet.io', cpu: 0.12, mem: 2435 }, { host: 'ares.peet.io', cpu: 0.10, mem: 2451 }, // ... ])

                                                    expect(results.group({ host: 'box1.example.com'})).to.deep.equal([ { host: 'box1.example.com', cpu: 0.54, mem: 8420 }, // ... ]) })

                                                  property groups

                                                  groups: () => Array<{
                                                  name: string;
                                                  tags: Tags;
                                                  rows: T[];
                                                  }>;
                                                  • Returns the data grouped into nested arrays, similarly to how it was returned from Influx originally.

                                                    Returns

                                                    Example 1

                                                    influx.query('select * from perf group by host').then(results => { expect(results.groups()).to.deep.equal([ { name: 'perf', tags: { host: 'ares.peet.io' }, rows: [ { host: 'ares.peet.io', cpu: 0.12, mem: 2435 }, { host: 'ares.peet.io', cpu: 0.10, mem: 2451 }, // ... ] } { name: 'perf', tags: { host: 'box1.example.com' }, rows: [ { host: 'box1.example.com', cpu: 0.54, mem: 8420 }, // ... ] } ]) })

                                                  interface IRetentionOptions

                                                  interface IRetentionOptions {}

                                                  property database

                                                  database?: string;

                                                    property duration

                                                    duration: string;

                                                      property isDefault

                                                      isDefault?: boolean;

                                                        property replication

                                                        replication: number;

                                                          interface ISchemaOptions

                                                          interface ISchemaOptions {}

                                                            property database

                                                            database?: string;
                                                            • The database the measurement lives under. Uses the default database if one is provided.

                                                            property fields

                                                            fields: {
                                                            [column: string]: FieldType;
                                                            };
                                                            • Columns is the map of column type definitions on the database.

                                                            property measurement

                                                            measurement: string;
                                                            • The measurement name this schema is describing.

                                                            property tags

                                                            tags: string[];
                                                            • A list of schema tag names.

                                                            interface ISingleHostConfig

                                                            interface ISingleHostConfig extends IHostConfig {}

                                                              property database

                                                              database?: string;
                                                              • Default database to write information to.

                                                              property password

                                                              password?: string;
                                                              • Password for connecting to the database. Defaults to 'root'.

                                                              property pool

                                                              pool?: IPoolOptions;
                                                              • Settings for the connection pool.

                                                              property schema

                                                              schema?: ISchemaOptions[];
                                                              • A list of schema for measurements in the database.

                                                              property username

                                                              username?: string;
                                                              • Username for connecting to the database. Defaults to 'root'.

                                                              interface IStringable

                                                              interface IStringable {}

                                                                property toString

                                                                toString: () => string;

                                                                  interface IWriteOptions

                                                                  interface IWriteOptions {}

                                                                    property database

                                                                    database?: string;
                                                                    • Database under which to write the points. This is required if a default database is not provided in Influx.

                                                                    property precision

                                                                    precision?: grammar.TimePrecision;
                                                                    • Precision at which the points are written, defaults to nanoseconds 'n'.

                                                                    property retentionPolicy

                                                                    retentionPolicy?: string;
                                                                    • Retention policy to write the points under, defaults to the DEFAULT database policy.

                                                                    Enums

                                                                    enum FieldType

                                                                    enum FieldType {
                                                                    FLOAT = 0,
                                                                    INTEGER = 1,
                                                                    STRING = 2,
                                                                    BOOLEAN = 3,
                                                                    }
                                                                    • FieldType is an enumeration of InfluxDB field data types. {Number} FieldType

                                                                      Example 1

                                                                      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, } }

                                                                    member BOOLEAN

                                                                    BOOLEAN = 3

                                                                      member FLOAT

                                                                      FLOAT = 0

                                                                        member INTEGER

                                                                        INTEGER = 1

                                                                          member STRING

                                                                          STRING = 2

                                                                            Type Aliases

                                                                            type measurement

                                                                            type measurement = {
                                                                            measurement: string | ((m: Measurement) => IStringable);
                                                                            };

                                                                              type TimePrecision

                                                                              type TimePrecision = 'n' | 'u' | 'ms' | 's' | 'm' | 'h';

                                                                                type where

                                                                                type where = {
                                                                                where: string | ((e: IExpressionHead) => IStringable);
                                                                                };

                                                                                  Package Files (8)

                                                                                  Dependencies (0)

                                                                                  No dependencies.

                                                                                  Dev Dependencies (34)

                                                                                  Peer Dependencies (0)

                                                                                  No peer dependencies.

                                                                                  Badge

                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/influx.

                                                                                  • Markdown
                                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/influx)
                                                                                  • HTML
                                                                                    <a href="https://www.jsdocs.io/package/influx"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>