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.
This example will connect to your InfluxDB server.
-
Connect to your InfluxDB web UI (on
https://XXXXX.stackhero-network.com
) and create a bucket (Load Data
/Buckets
/Create Bucket
). Give it the namestackherotest
. -
Still in InfluxDB web UI and create a token (
Load Data
/API Tokens
/Generate API token
/Read/Write API Token
). -
Retrieve the token you have just created (click on its name to get it).
-
Clone this repository:
git clone https://github.com/stackhero-io/influxdbGettingStarted && cd influxdbGettingStarted
-
Copy the file
.env-example
to.env
and fill it with your credentials. -
Install dependencies:
npm install
. -
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.