[Fact] device_status

도메인 개요 #

항목설명
목적센서, 로봇, 설비 등 IoT 기기의 상태 보고(ping, 지연, 오류) 및 오프라인/이상 상태 감지
보고 주기기기별 heartbeat 주기 (30~180초)
연계 도메인dim_device, dim_device_threshold, dim_device_error_code, alarm_log

메시지 스키마(Kafka/Avro) #

{
  "timestamp": "2025-05-24T14:35:00Z",
  "device_id": "SENSOR_ENV_001",
  "device_type": "env_sensor",
  "location": "zone_7",
  "ip_address_hash": "0x7e239a...",  // ✅ 원본 IP는 저장 안함
  "status": {
    "ping_success": true,
    "latency_ms": 43,
    "last_success_at": "2025-05-24T14:34:30Z"
  },
  "error_code": null,
  "schema_version": "v2.0",
  "ingestion_timestamp": "2025-05-24T14:35:02Z"
}

이상 탐지 처리 흐름(Spark) #

항목내용
기준 테이블dim_device_threshold
Join Keydevice_id, device_type
이상 조건ping_success = false OR latency_ms > max_latency
timeout 판단timestamp - last_success_at > timeout_threshold
timeout 계산 기준timeout_threshold = heartbeat_cycle * 2.5
error_code 정규화dim_device_error_code 조인으로 설명 및 심각도 분석
DLQ 조건unit_mismatch, schema_error, timeout, error_code missing 등

Iceberg 저장 전략 #

항목내용
테이블명iot.fact_device_status
파티셔닝days(timestamp), bucket(16, device_id)
중복 제거 기준device_id + timestamp
TTL 정책최근 90일 (단기 장애 탐지용)

Kafka Topic 구성 #

iot.device_status:
  partitions: 8
  replication-factor: 3
  compression.type: zstd
  retention.ms: 604800000  # 7일

iot.device_status.dlq:
  partitions: 3
  retention.ms: 2592000000  # 30일

DLQ 설계 #

유형조건 예시처리 방식
ping 실패 (ping_success=false)즉시 DLQ or 알람ping_failure DLQ
latency 초과latency_ms > 300 등latency_violation DLQ
timeout 상태timestamp - last_success_at > 300초 등offline_timeout DLQ
error_code 누락status = false인데 코드 없음missing_error_code DLQ
invalid enum/typeschema 오류, 잘못된 device_type 등
schema_error DLQ

주요 모니터링 지표 #

device_status_success_ratio
device_offline_timeout_count
device_latency_p95
device_ping_failure_count
device_error_code_distribution

SLA 기준 #

항목기준
상태 보고 수집 지연≤ 3초
Spark → Iceberg 적재 지연≤ 10초
DLQ 비율≤ 0.1%
오프라인 탐지 지연 허용≤ 60초
알람 전파 지연≤ 2초

연계 흐름 #

flowchart LR
    KAFKA(Kafka: iot.device_status) --> SPARK(Spark Device Monitor)
    SPARK --> ICEBERG(Iceberg: fact_device_status)
    SPARK --> ALERT(Kafka: iot.alarm_log)
    ICEBERG --> TRINO(장치별 연결 안정성 분석)
    ICEBERG --> SUP(Superset: 장애 발생 위치 시각화)

관련 Dimension Table #

dim_device

필드명설명
device_id고유 ID
device_type센서, 로봇, 게이트웨이 등
location위치
install_date설치일
heartbeat_cycle보고 주기 (초)

dim_device_threshold

필드명설명
device_type센서/로봇 구분
max_latency지연 임계값 (ms)
timeout_multiplier기본값 2.5 → timeout = heartbeat × multiplier

dim_device_error_code

필드명설명
error_code코드
description오류 설명
severitywarning/critical