Use InfluxDB 3 Core
Overview
Migrate the IoT API sample application from InfluxDB 2.x to InfluxDB 3 Core using the @influxdata/influxdb3-client JavaScript client library.
Phase 1: Core Migration ✅
Environment Changes
| Variable |
New Value |
Replaces |
| INFLUX_HOST |
http://localhost:8181 |
INFLUX_URL |
| INFLUX_DATABASE |
iot_center |
INFLUX_BUCKET |
| INFLUX_DATABASE_AUTH |
iot_center_devices |
INFLUX_BUCKET_AUTH |
| INFLUX_TOKEN |
Admin token |
Same |
INFLUX_ORG |
Removed |
Not used in InfluxDB 3 |
References
Related
## Use InfluxDB 3 Core
Overview
Migrate the IoT API sample application from InfluxDB 2.x to InfluxDB 3 Core using the @influxdata/influxdb3-client JavaScript client library.
Phase 1: Core Migration ✅
Environment Changes
| Variable |
New Value |
Replaces |
INFLUX_HOST |
http://localhost:8181 |
INFLUX_URL |
INFLUX_DATABASE |
iot_center |
INFLUX_BUCKET |
INFLUX_DATABASE_AUTH |
iot_center_devices |
INFLUX_BUCKET_AUTH |
INFLUX_TOKEN |
Admin token |
Same |
INFLUX_ORG |
Removed |
Not used in InfluxDB 3 |
Client Library Migration
- Replace
@influxdata/influxdb-client with @influxdata/influxdb3-client v2.0.0
- Use
InfluxDBClient class with { host, token } configuration
- Use
Point class for line protocol construction
- Use
client.query(sql, database) for SQL queries
- Use
client.write(data, database) for writes
Query Language Migration
- Convert all Flux queries to SQL
- InfluxDB 3 Core supports SQL queries only (no Flux)
- Query limit: Last 72 hours of data (Core limitation)
Authentication Changes
- InfluxDB 3 Core does not have the Authorizations API
- Implement application-level device tokens stored in
iot_center_devices database
- Generate tokens using
crypto.randomBytes(32).toString('hex')
- Store device credentials as line protocol with
deviceauth measurement
API Endpoints Migrated
Phase 2: Core Enhancements
Last Value Cache (LVC)
Sub-10ms query performance for latest device readings.
influxdb3 create last_cache \
--database iot_center \
--table environment \
--key-columns deviceId \
--value-columns Temperature,Humidity,Pressure,CO2
Use case: Real-time dashboard showing current sensor values for all devices.
Distinct Value Cache (DVC)
Fast metadata lookups without full table scans.
influxdb3 create distinct_cache \
--database iot_center \
--table environment \
--columns deviceId,deviceType,location
Use case: Populate device filter dropdowns, list available locations.
Processing Engine
Python plugins for data processing triggered by WAL writes, schedules, or HTTP requests.
Example: Temperature Alert Plugin
# temperature_alert.py
def process_writes(influxdb3_local, table_batches, args):
for table_batch in table_batches:
if table_batch["table_name"] == "environment":
for row in table_batch["rows"]:
if row.get("Temperature", 0) > args.get("threshold", 30):
influxdb3_local.write(
f'alerts,deviceId={row["deviceId"]},type=temperature '
f'value={row["Temperature"]},message="High temperature"'
)
Use cases:
- Temperature threshold alerts (WAL trigger)
- Daily device health summary (scheduled)
- On-demand data aggregation (HTTP request)
Technical Notes
InfluxDB 3 Core Limitations
| Limitation |
Description |
| Query window |
Last 72 hours only |
| Authentication |
No resource tokens (use application-level auth) |
| Availability |
Single node only |
| Processing Engine |
Python plugins only |
Data Model Changes
| InfluxDB 3 |
InfluxDB 2.x |
| Database |
Bucket |
| Table |
Measurement |
| Tags |
Tags |
| Fields |
Fields |
References
Related
Use InfluxDB 3 Core
Overview
Migrate the IoT API sample application from InfluxDB 2.x to InfluxDB 3 Core using the
@influxdata/influxdb3-clientJavaScript client library.Phase 1: Core Migration ✅
Environment Changes
INFLUX_ORGReferences
Related
- PR feat: migrate to InfluxDB 3 Core with influxdb3-javascript client #18: Initial migration implementation
- Branch:
## Use InfluxDB 3 Coreclaude/influxdb3-migration-v3-pMqwyOverview
Migrate the IoT API sample application from InfluxDB 2.x to InfluxDB 3 Core using the
@influxdata/influxdb3-clientJavaScript client library.Phase 1: Core Migration ✅
Environment Changes
INFLUX_HOSThttp://localhost:8181INFLUX_URLINFLUX_DATABASEiot_centerINFLUX_BUCKETINFLUX_DATABASE_AUTHiot_center_devicesINFLUX_BUCKET_AUTHINFLUX_TOKENINFLUX_ORGClient Library Migration
@influxdata/influxdb-clientwith@influxdata/influxdb3-clientv2.0.0InfluxDBClientclass with{ host, token }configurationPointclass for line protocol constructionclient.query(sql, database)for SQL queriesclient.write(data, database)for writesQuery Language Migration
Authentication Changes
iot_center_devicesdatabasecrypto.randomBytes(32).toString('hex')deviceauthmeasurementAPI Endpoints Migrated
GET /api/devices- List all devices (SQL query)GET /api/devices/:deviceId- Get single device (SQL query with parameter)POST /api/devices/create- Create device with application tokenGET /api/measurements- Query telemetry data (SQL query)Phase 2: Core Enhancements
Last Value Cache (LVC)
Sub-10ms query performance for latest device readings.
Use case: Real-time dashboard showing current sensor values for all devices.
Distinct Value Cache (DVC)
Fast metadata lookups without full table scans.
Use case: Populate device filter dropdowns, list available locations.
Processing Engine
Python plugins for data processing triggered by WAL writes, schedules, or HTTP requests.
Example: Temperature Alert Plugin
Use cases:
Technical Notes
InfluxDB 3 Core Limitations
Data Model Changes
References
Related
claude/influxdb3-migration-v3-pMqwy