Developerapi

AsyncAPI 规范

AsyncAPI Specification

观测数据上行与告警推送的事件契约(MQTT / WebSocket),定义主题结构与载荷。

01

概览

观测数据上行与告警推送的事件契约(MQTT / WebSocket),定义主题结构与载荷。

02

要点

事件主题采用层级结构:siyb/v1/{site_id}/{device_id}/{metric_id},时间戳放载荷内而非依赖 Broker 时间。

03

要点 2

告警事件单独通道:siyb/v1/alerts/{site_id},载荷含条件组合与置信度,反对单传感器直接告警。

04

示例

asyncapi: 3.0.0
info:
  title: SIYB E Telemetry Events
  version: 1.0.0
channels:
  telemetry:
    address: siyb/v1/{site_id}/{device_id}/{metric_id}
    messages:
      observation:
        payload:
          type: object
          required: [metric_id, value, unit, observed_at, quality_flag]
          properties:
            metric_id:    { type: string }
            value:        { type: [number, 'null'] }
            unit:         { type: string }
            observed_at:  { type: string, format: date-time }
            quality_flag: { enum: [ok, suspect, invalid, corrected, missing, interpolated] }
  alerts:
    address: siyb/v1/alerts/{site_id}
    messages:
      alert:
        payload:
          type: object
          required: [alert_id, conditions, confidence]
          properties:
            alert_id:    { type: string }
            conditions:  { type: array, items: { type: object } }
            confidence:  { type: number, minimum: 0, maximum: 1 }
            human_review:{ type: boolean, description: 是否需要人工确认 }
CLOSE

把 AsyncAPI 规范 用起来

需要把技术判断落到项目?

进入行业应用与智能选型中心,获取场景设计、选型与实施参考。