-
Notifications
You must be signed in to change notification settings - Fork 0
component factory a log adapter
factory-a-log-adapter는 Factory A의 Safe-Edge 결과와 K3s 상태를 canonical JSON으로 변환해 local outbox에 저장하는 컴포넌트다. IoT Core publish는 하지 않는다.
InfluxDB safe_edge_db
environment_data / ai_detection / acoustic_detection
K3s API / kubectl fallback
nodes / pods
Prometheus
node CPU / memory / disk metrics
factory-a-log-adapter
-> factory_state / infra_state JSON
-> /var/lib/aegis/outbox/{message_id}.json
edge-iot-publisher
-> MQTT publish
adapter는 물리 장치에 직접 접근하지 않는다. BME280, camera, microphone을 사용하는 기존 Safe-Edge workload가 InfluxDB에 결과를 쓰고, adapter는 그 결과와 cluster 상태를 읽어 공통 계약으로 맞춘다.
| 입력 | 기본 endpoint | 사용 데이터 |
|---|---|---|
| InfluxDB | http://influxdb-svc.monitoring.svc.cluster.local:8086 |
온도, 습도, 기압, AI fire/fall/bend, acoustic event |
| Prometheus | http://prometheus-svc.monitoring.svc.cluster.local:9090 |
node CPU/memory/disk 사용률 |
| Kubernetes API | in-cluster service account, 실패 시 kubectl
|
node ready, pod phase, restart count, placement |
기본 workload 목록:
monitoring/bme280-sensor
ai-apps/safe-edge-integrated-ai
ai-apps/safe-edge-audio
monitoring/influxdb
monitoring/prometheus
monitoring/grafana
기본 3초 주기로 최근 window를 집계한다.
{
"schema_version": "0.1.0",
"factory_id": "factory-a",
"node_id": "worker2",
"environment_type": "physical-rpi",
"input_module_type": "sensor",
"source_type": "factory_state",
"payload": {
"aggregation_window_seconds": 3,
"sensor": {
"sample_count": 5,
"temperature_celsius_avg": 24.6,
"humidity_percent_avg": 58.1,
"pressure_hpa_avg": 1012.7
},
"ai_result": {
"sample_count": 3,
"fire_score": 0.0,
"fall_score": 0.6667,
"bend_score": 0.3333,
"abnormal_sound": "none"
}
}
}abnormal_sound 기준:
| 조건 | 값 |
|---|---|
acoustic 샘플 없음 또는 sum(is_danger) == 0
|
none |
위험 감지 + event_type 있음 |
대표 event_type
|
| 위험 감지 + label 없음 | abnormal_sound |
기본 20초 주기로 cluster 상태를 만든다.
{
"source_type": "infra_state",
"node_id": "cluster",
"payload": {
"heartbeat": {
"agent_status": "alive",
"last_spool_write_status": "unknown",
"last_spool_write_at": null
},
"node_summary": {
"total": 3,
"ready": 3,
"not_ready": 0
},
"nodes": [
{
"node_id": "worker2",
"role": "sensor-ai-audio-preferred",
"ready": true,
"cpu_usage_percent": 44.8,
"memory_usage_percent": 63.0,
"disk_usage_percent": 45.5,
"network_reachability": "ok"
}
],
"workloads": [
{
"namespace": "ai-apps",
"name": "safe-edge-integrated-ai",
"status": "Running",
"ready": true,
"restart_count": 0,
"node_id": "worker2"
}
],
"devices": {
"bme280": { "available": true, "last_seen_at": "2026-05-14T01:00:00Z" },
"camera": { "available": true, "last_seen_at": "2026-05-14T01:00:00Z" },
"microphone": { "available": true, "last_seen_at": "2026-05-14T01:00:00Z" }
}
}
}adapter는 같은 filesystem 안에서 atomic rename으로 파일을 완성한다.
/var/lib/aegis/outbox/tmp/{message_id}.*.tmp
-> /var/lib/aegis/outbox/{message_id}.json
중복 message_id 파일이 이미 있으면 덮어쓰지 않는다. publish 성공 후 삭제와 validation 실패 quarantine은 edge-iot-publisher 책임이다.
python3 factory_a_log_adapter.py --once factory_state
python3 factory_a_log_adapter.py --once infra_state
python3 factory_a_log_adapter.py --once all
python3 factory_a_log_adapter.py --loopHelm 기본 interval:
| 환경변수 | 기본 |
|---|---|
AEGIS_FACTORY_STATE_INTERVAL_SECONDS |
3 |
AEGIS_INFRA_STATE_INTERVAL_SECONDS |
20 |
AEGIS_FACTORY_STATE_WINDOW_SECONDS |
3 |
AEGIS_INFLUXDB_FALLBACK_SAMPLE_LIMIT |
5 |
factory_state가 3초인 이유는 Safety Score 계산의 재료인 센서, AI, 오디오 결과가 실시간으로 변하기 때문이다. InfluxDB safe_edge_db의 retention은 1d이며 adapter는 매 3초마다 최근 window를 읽는다. IoT에는 "현재 snapshot" 하나만 가면 되므로 InfluxDB 전체 이력을 보내는 것이 아니라 가장 최신 집계값만 전달한다.
infra_state가 20초인 이유는 K3s API와 Prometheus 호출이 상대적으로 비용이 크고, cluster 상태는 센서 측정값보다 훨씬 느리게 변하기 때문이다. node ready 상태나 pod restart count는 3초마다 폴링할 필요가 없다.
factory-a K3s ai-apps namespace
-> aegis-spoke Helm chart
-> factoryALogAdapter.enabled: true
-> outbox Longhorn PVC /var/lib/aegis/outbox
Factory B/C에서는 이 컴포넌트를 켜지 않는다.
관련 문서
- 시스템 아키텍처
- 제어 & 데이터 플레인
- Dashboard VPC 설계
- 하드웨어 배치
- Hub EKS 네임스페이스
- Tailscale Mesh VPN
- 데이터 생명주기
- 데이터 조회 모델
- 실시간 갱신 구조
- IoT 데이터 계약
- Reporting Pipeline
- 로컬 스토리지
- 클라우드 스토리지
- Edge Agent
- Edge AI 탐지
- Factory-A Log Adapter
- Dummy Sensor
- Edge IoT Publisher
- Lambda Data Processor
- Risk Normalizer
- Risk Score Engine
- Pipeline Status Aggregator
- Graph Aggregator 5m
- Cloud Infra Collector
- Daily Report Generator
- Risk Alert Dispatcher
- Image Snapshot Pipeline
- Dashboard Backend
- Dashboard Web
- AI 채팅 어시스턴트