InfluxDB는 시계열 데이터(time-series data)를 효율적으로 저장하고 조회하기 위해 설계된 오픈 소스 데이터베이스 시스템입니다. IoT 센서, 모니터링 시스템, 애플리케이션 메트릭 등 시간 기반 데이터를 다루는 데 특화되어 있습니다.
| 항목 | 설명 |
|---|---|
| 시계열 데이터 | 시간(Time)과 값(Value)이 짝을 이루는 데이터. 예: 1초마다 측정되는 온도, CPU 사용률 등 |
| 메저먼트(Measurement) | RDB의 테이블 개념과 유사. 예: temperature, cpu_usage |
| 태그(Tag) | 인덱싱 가능한 메타데이터. 필터링/검색에 사용. 예: location=seoul |
| 필드(Field) | 실제 측정값 데이터. 예: value=23.4 |
| 타임스탬프(Timestamp) | 데이터가 기록된 시각. InfluxDB는 모든 데이터에 타임스탬프가 필수 |
measurement: temperature
tags: location=seoul, sensor=s1
fields: value=23.4
timestamp: 2025-05-27T09:00:00Z
POST /write?db=mydb
Body:
temperature,location=seoul,sensor=s1 value=23.4 1716781200000000000
temperature: Measurement
location=seoul,sensor=s1: 태그
value=23.4: 필드
1716781200000000000: Unix timestamp (나노초)
-- InfluxQL
SELECT value FROM temperature
WHERE location='seoul'
AND time >= now() - 1h
-- Flux
from(bucket: "mydb")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "temperature" and r.location == "seoul")
⚠️ InfluxDB는 기존 데이터를 직접 수정하지 않음.
같은 타임스탬프에 데이터를 다시 쓰면 덮어쓰기(Overwrite)가 됩니다.
temperature,location=seoul,sensor=s1 value=25.1 1716781200000000000
DELETE FROM temperature
WHERE time < now() - 7d
import "influxdata/influxdb/v1"
v1.delete(bucket: "mydb", predicate: (r) => r._measurement == "temperature", start: 0, stop: now())
센서/애플리케이션 → InfluxDB에 Line Protocol로 데이터 write
→ 필요 시 Flux/InfluxQL로 데이터 조회(read)
→ 시각화: Grafana, Chronograf, custom dashboard