Asynchronous API that writes time-series data into InfluxDB. This API always buffers points/lines to create batches under the hood to optimize data transfer to InfluxDB server, use flush to send the buffered data to InfluxDB immediately.

interface WriteApi {
    convertTime?: (
        value: undefined | string | number | Date,
    ) => undefined | string;
    defaultTags?: { [key: string]: string };
    path: string;
    close(): Promise<void>;
    dispose(): number;
    flush(withRetryBuffer?: boolean): Promise<void>;
    useDefaultTags(tags: { [key: string]: string }): WriteApi;
    writePoint(point: Point): void;
    writePoints(points: ArrayLike<Point>): void;
    writeRecord(record: string): void;
    writeRecords(records: string[]): void;
}

Hierarchy (View Summary)

Properties

convertTime?: (value: undefined | string | number | Date) => undefined | string

convertTime serializes Point's timestamp to a line protocol value

defaultTags?: { [key: string]: string }

default tags to add to every point

path: string

HTTP path and query parameters of InfluxDB query API. It is automatically initialized to /api/v2/write?org=..., but it can be changed after the API is obtained.

Methods

  • Flushes this writer and cancels retries of write operations that failed.

    Returns Promise<void>

    completition promise

  • Unlike close, dispose simply quits without trying to flush the buffered data.

    Returns number

    count of points that were not written to InfluxDB

  • Flushes pending writes to the server.

    Parameters

    • OptionalwithRetryBuffer: boolean

      flush also all the scheduled retries

    Returns Promise<void>

    completition promise

  • Instructs to use the following default tags when writing points. Not applicable for writing records/lines.

    Parameters

    • tags: { [key: string]: string }

      default tags

    Returns WriteApi

    this

MMNEPVFCICPMFPCPTTAAATR