Member-only story
Getting Started with JavaScript and InfluxDB 2.0
With 200+ plugins, Telegraf has a wide variety of methods for scraping, writing, and querying data to and from InfluxDB. However, sometimes users need to perform data collection outside of the capabilities of Telegraf. Perhaps they need to collect custom data and monitor application performance. Maybe they want to take advantage of external tools and libraries to create beautiful web-based visualizations for their users. In these cases, it makes sense to take advantage of InfluxDB’s Client Libraries. Today, we will focus on how to use the latest InfluxDB JavaScript Client Library with InfluxDB 2.0.
Important note: InfluxDB v1.8 includes both the Flux engine for queries and InfluxDB v2 HTTP write APIs as well. This means that if you aren’t quite ready to use InfluxDB v2 today and you are planning to leverage the new client libraries, you can! These read and write compatibility options allow you to future-proof your code!
Tutorial requirements and setup
This tutorial was executed on a MacOS system with Node installed via Homebrew, per the Node.js documentation.
#update brew before installing
brew update
brew install node
#check to make sure you have successfully installed Node and NPM
node -v
npm -v
The easiest way to get started using the InfluxDB v2 JavaScript Client is to clone the examples directory in the influxdb-client-js repo.