InfluxDB

Integrate Thingsee IoT data with InfluxDB time series database

InfluxDB is a purpose-built time series platform for IoT analytics and monitoring.

Overview

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#73F9C1','primaryTextColor':'#143633','primaryBorderColor':'#143633','lineColor':'#143633','secondaryColor':'#C7FDE6','tertiaryColor':'#F6FAFA','clusterBkg':'#F6FAFA','clusterBorder':'#143633'}}}%%
flowchart TB
    subgraph InfluxDBPlatform["InfluxDB"]
        DASH[Dashboards]
        ALERT[Alerting]
        API[Query API]
        I[InfluxDB]
    end
    
    T[Thingsee Cloud]
    
    T -->|Line Protocol| I
    I --> DASH & ALERT & API

Setup

1. Install InfluxDB

Follow InfluxDB installation guide or use InfluxDB Cloud.

2. Configure Access

Create access credentials:

  • Organization name
  • Bucket name
  • Write token

3. Request Integration

Contact Haltian with:

  • InfluxDB server URL
  • Write token
  • Organization name
  • Bucket name

Data Schema

Thingsee Cloud converts messages to InfluxDB line protocol:

InfluxDB ConceptThingsee Mapping
BucketYour bucket name
MeasurementtsmId value
FieldThingsee message property
TagtsmTuid (device serial)
TimestamptsmTs (Unix seconds)

Example

Thingsee message:

{
  "tsmId": 12100,
  "tsmEv": 10,
  "tsmTs": 1520416221,
  "tsmTuid": "TSPR04E2O90201558",
  "temp": 21.3,
  "humd": 45.2
}

InfluxDB line protocol:

12100,tsmTuid=TSPR04E2O90201558 temp=21.3,humd=45.2 1520416221000000000

Querying Data

Flux Query Language

Get latest temperature for all devices:

from(bucket: "thingsee")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "12100")
  |> filter(fn: (r) => r._field == "temp")
  |> last()

Average temperature by device:

from(bucket: "thingsee")
  |> range(start: -24h)
  |> filter(fn: (r) => r._measurement == "12100")
  |> filter(fn: (r) => r._field == "temp")
  |> mean()
  |> group(columns: ["tsmTuid"])

Detect temperature anomalies:

from(bucket: "thingsee")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "12100")
  |> filter(fn: (r) => r._field == "temp")
  |> filter(fn: (r) => r._value > 30 or r._value < 10)

InfluxQL (v1 compatibility)

SELECT mean("temp") FROM "12100" 
WHERE time > now() - 24h 
GROUP BY time(1h), "tsmTuid"

Dashboards

InfluxDB includes built-in dashboard capabilities:

Create Dashboard

  1. Open InfluxDB UI
  2. Go to Dashboards → Create Dashboard
  3. Add cells with Flux queries
  4. Configure visualizations

Example Visualizations

Cell TypeQueryDescription
Line graphTemperature over timefilter(fn: (r) => r._field == "temp")
GaugeLatest battery levelfilter(fn: (r) => r._field == "batl") |> last()
TableDevice statusGroup by tsmTuid with latest values
HeatmapOccupancy patternsCount of presence events

Alerting

Configure alerts with InfluxDB Checks:

Low Battery Alert

import "influxdata/influxdb/monitor"

check = {
    _check_id: "low-battery",
    _check_name: "Low Battery Alert",
    _type: "threshold",
    tags: {}
}

from(bucket: "thingsee")
  |> range(start: -5m)
  |> filter(fn: (r) => r._measurement == "1110")
  |> filter(fn: (r) => r._field == "batl")
  |> last()
  |> monitor.check(
      crit: (r) => r._value < 20,
      warn: (r) => r._value < 40,
      data: check
  )

No Data Alert

from(bucket: "thingsee")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "12100")
  |> count()
  |> map(fn: (r) => ({ r with _level: if r._value == 0 then "crit" else "ok" }))

Retention Policies

Configure data retention based on needs:

// Create bucket with 30-day retention
influx bucket create \
  --name thingsee \
  --org your-org \
  --retention 30d

Consider tiered storage:

  • Hot: Recent data (7 days), fast queries
  • Warm: Historical data (1 year), slower queries
  • Cold: Archive (3+ years), object storage

Integration with Grafana

InfluxDB integrates seamlessly with Grafana:

  1. Add InfluxDB as data source
  2. Use Flux or InfluxQL queries
  3. Build advanced dashboards
  4. Set up unified alerting

Resources