Getting started with InfluxDB

How to send data from Node.js to InfluxDB

You can find here some examples of Node.js code to send data to an InfluxDB V2 server.

These examples are designed to run with a Stackhero for InfluxDB. You'll more informations about Stackhero here:

The code uses the official influxDB library to connect to your InfluxDB server from Node.js.

How to use these examples

This example will connect to your InfluxDB server.

  1. Connect to your InfluxDB web UI (on https://XXXXX.stackhero-network.com) and create a bucket (Load Data/Buckets/Create Bucket). Give it the name stackherotest.

  2. Still in InfluxDB web UI and create a token (Load Data/API Tokens/Generate API token/Read/Write API Token).

  3. Retrieve the token you have just created (click on its name to get it).

  4. Clone this repository: git clone https://github.com/stackhero-io/influxdbGettingStarted && cd influxdbGettingStarted

  5. Copy the file .env-example to .env and fill it with your credentials.

  6. Install dependencies: npm install.

  7. Run the script: npm run start.

You can see the script code in the file app.js and see how it works to use it as an example.