Skip to content

Update app to use InfluxDB 3 Enterprise #39

@jstirnaman

Description

@jstirnaman

Use InfluxDB 3 Enterprise

Overview

Extend the IoT API sample application to leverage InfluxDB 3 Enterprise features for production-ready deployments with historical data access, resource tokens, and enhanced monitoring.

Prerequisite: Complete InfluxDB 3 Core migration first.


Phase 3: Enterprise Migration

Resource Tokens

Replace application-level tokens with InfluxDB 3 Enterprise resource tokens for fine-grained access control.

Token Format: db:DATABASE:PERMISSIONS

# Create read-only token for a device
influxdb3 create token \
  --description "Device sensor-001 read token" \
  --resource "db:iot_center:read"

Create read-write token for device registration

influxdb3 create token
--description "Device registration service"
--resource "db:iot_center:read,write"
--resource "db:iot_center_devices:read,write"

Implementation:

  • Update device creation to generate Enterprise resource tokens
  • Store token metadata in device registry
  • Validate tokens server-side before processing requests

Historical Data Queries

Remove 72-hour query limitation for full historical analysis.

Use cases:

  • Long-term trend analysis
  • Historical reporting
  • Data export for ML training

API Enhancements:

// GET /api/measurements?range=30d
// GET /api/measurements?start=2024-01-01&end=2024-12-31

High Availability

Enterprise supports clustered deployments for production reliability.

Considerations:

  • Connection pooling for multiple nodes
  • Retry logic with backoff
  • Health check endpoints

Phase 4: Enterprise Enhancements

InfluxDB 3 Explorer UI Integration

Leverage the built-in web UI for data exploration and debugging.

Features to document:

Feature Description
SQL Query Editor Autocomplete and syntax highlighting
Real-time Visualization Interactive charts and graphs
Table Browser Schema and table exploration
Query History Saved and recent queries

Migration Checklist

  • Upgrade InfluxDB 3 Core to Enterprise
  • Migrate application tokens to resource tokens
  • Update API to support historical queries
  • Configure connection pooling for HA
  • Set up Grafana dashboards
  • Document Explorer UI usage
  • Deploy scheduled processing plugins
  • Update monitoring and alerting

References


Related

## Use InfluxDB 3 Enterprise

Overview

Extend the IoT API sample application to leverage InfluxDB 3 Enterprise features for production-ready deployments with historical data access, resource tokens, and enhanced monitoring.

Prerequisite: Complete InfluxDB 3 Core migration first.


Phase 3: Enterprise Migration

Resource Tokens

Replace application-level tokens with InfluxDB 3 Enterprise resource tokens for fine-grained access control.

Token Format: db:DATABASE:PERMISSIONS

# Create read-only token for a device
influxdb3 create token \
  --description "Device sensor-001 read token" \
  --resource "db:iot_center:read"

# Create read-write token for device registration
influxdb3 create token \
  --description "Device registration service" \
  --resource "db:iot_center:read,write" \
  --resource "db:iot_center_devices:read,write"

Implementation:

  • Update device creation to generate Enterprise resource tokens
  • Store token metadata in device registry
  • Validate tokens server-side before processing requests

Historical Data Queries

Remove 72-hour query limitation for full historical analysis.

Use cases:

  • Long-term trend analysis
  • Historical reporting
  • Data export for ML training

API Enhancements:

// GET /api/measurements?range=30d
// GET /api/measurements?start=2024-01-01&end=2024-12-31

High Availability

Enterprise supports clustered deployments for production reliability.

Considerations:

  • Connection pooling for multiple nodes
  • Retry logic with backoff
  • Health check endpoints

Phase 4: Enterprise Enhancements

InfluxDB 3 Explorer UI Integration

Leverage the built-in web UI for data exploration and debugging.

Features to document:

Feature Description
SQL Query Editor Autocomplete and syntax highlighting
Real-time Visualization Interactive charts and graphs
Table Browser Schema and table exploration
Query History Saved and recent queries

Integration points:

  • Link from API error responses to Explorer for debugging
  • Document Explorer URL patterns for deep linking

Grafana Dashboard Integration

Build monitoring dashboards using Grafana with InfluxDB 3 as data source.

Example Dashboards:

1. Device Overview Dashboard

Panel Type Description
Active Devices Gauge Current count of registered devices
Registration Timeline Time Series Device registrations over time
Devices by Type Pie Chart Distribution of device types

2. Telemetry Monitoring Dashboard

Panel Type Description
Temperature/Humidity Time Series Trends per device
Anomaly Alerts Alert List Threshold violations
Ingestion Rate Stat Panel Data points per second

3. System Health Dashboard

Panel Type Description
API Response Times Histogram Latency distribution
Error Rates Bar Chart Errors by endpoint
Query Performance Time Series Database query metrics

Grafana Data Source Configuration:

datasources:
  - name: InfluxDB 3
    type: influxdb
    url: http://localhost:8181
    jsonData:
      version: Flux  # Use SQL plugin when available
      organization: ""
      defaultBucket: iot_center

Advanced Processing Engine

Enterprise-scale processing with additional capabilities.

Scheduled Aggregation Plugin:

# hourly_rollup.py - Runs every hour
def process_scheduled(influxdb3_local, args):
    # Query last hour of raw data
    results = influxdb3_local.query("""
        SELECT 
            deviceId,
            AVG(Temperature) as avg_temp,
            MAX(Temperature) as max_temp,
            MIN(Temperature) as min_temp
        FROM environment
        WHERE time >= now() - INTERVAL '1 hour'
        GROUP BY deviceId
    """)
    
    # Write aggregated data to rollup table
    for row in results:
        influxdb3_local.write(
            f'environment_hourly,deviceId={row["deviceId"]} '
            f'avg_temp={row["avg_temp"]},max_temp={row["max_temp"]},min_temp={row["min_temp"]}'
        )

Enterprise-Specific Environment Variables

# .env.production
INFLUX_HOST=https://influxdb.example.com
INFLUX_TOKEN=enterprise-admin-token
INFLUX_DATABASE=iot_center
INFLUX_DATABASE_AUTH=iot_center_devices

# Enterprise-specific
INFLUX_ENABLE_RESOURCE_TOKENS=true
INFLUX_CLUSTER_NODES=node1:8181,node2:8181,node3:8181

Core vs Enterprise Comparison

Feature Core Enterprise
Query Window 72 hours Unlimited
Resource Tokens No Yes
High Availability No Yes
Processing Engine Yes Yes (enhanced)
Explorer UI Yes Yes
Grafana Support Yes Yes

Migration Checklist

  • Upgrade InfluxDB 3 Core to Enterprise
  • Migrate application tokens to resource tokens
  • Update API to support historical queries
  • Configure connection pooling for HA
  • Set up Grafana dashboards
  • Document Explorer UI usage
  • Deploy scheduled processing plugins
  • Update monitoring and alerting

References


Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions