跳至主要内容

Telemetry、OpenTelemetry、BMC 與 Grafana/Loki 的關係

一句話總結:Telemetry 是資料本身;OpenTelemetry 是收集與傳輸的標準和工具;BMC 是硬體層的資料來源之一;Loki / Prometheus / Tempo 負責存,Grafana 負責看。


1. Telemetry 是什麼​

Telemetry(遙測)原意是「在遠端量測,把資料傳回來分析」。在電腦系統中,它指把系統運作狀態收集起來,送到別處儲存與分析。

軟體 observability 一般把 telemetry 分成三類訊號,近年再加上 profiles:1

三者各自回答的問題不同:

訊號回答的問題特性
Metrics「有沒有出問題?多嚴重?」便宜、可聚合、適合告警
Logs「發生了什麼事?」細節多、量大、較貴
Traces「慢在哪一段?」跨服務因果關係

Trace 的樣子​

一個 request 經過多個服務,每一段就是一個 span:


2. OpenTelemetry 是什麼​

OpenTelemetry(OTel)是 CNCF 專案,2019 年由 OpenTracing + OpenCensus 合併而成。23 它的目標是統一 telemetry 的產生與傳輸標準,避免被特定廠商綁住;儲存與視覺化則刻意留給其他工具。2

OTel 的組成​

Collector 內部 pipeline​

Collector 是整個 OTel 生態裡最實用的元件,可以把它想成 telemetry 的路由器:4

送進 Loki 用的是 otlphttp:Loki 3.0 起原生接收 OTLP,5 早期專用的 loki exporter 在 2024 年 7 月標為 deprecated,並已在 Collector contrib v0.131.0 移除。6

比喻: OTel 定義了水管與插頭的規格。下游接什麼水庫(Loki、Prometheus)、用什麼儀表(Grafana),都可以自由替換。


3. 跟 BMC 的關係​

BMC 是一個硬體層、out-of-band 的 telemetry 來源。即使 host OS 當機或還沒開機,BMC 仍然能回報狀態。

In-band 與 Out-of-band​

In-band(Host 端)Out-of-band(BMC)
典型工具OTel SDK、node_exporterRedfish、IPMI
資料應用效能、OS 資源溫度、電源、風扇、硬體錯誤
Host 當機時❌ 看不到✅ 仍可回報
誕生背景雲原生 / 微服務伺服器硬體管理

OpenBMC 內部的 telemetry 資料流​

圖中的 sensor、telemetry daemon 與 Redfish 服務都是 OpenBMC 的上游元件。789

Redfish TelemetryService 資源結構​

資源名稱依 DMTF 的 TelemetryService schema。10

Pull 與 Push 兩種取得方式​


4. Grafana、Loki 這些是什麼​

它們是後端儲存與視覺化,位於 OTel 水管的下游。Grafana Labs 的整套工具常被稱為 LGTM stack:

Loki 為什麼便宜:只對 label 建索引​

  • Elasticsearch:對每個字建全文索引,查詢快,但儲存與運算都貴。
  • Loki:log 內容本身不建索引,只用 label 找到 stream,再對 chunk 做 grep 式掃描。11這種做法便宜,但 label 要設計好。高基數的欄位(如 request_id)不要放進 label。12

5. 全部串起來:資料中心的整體架構​

分層對照​

層做什麼代表
來源產生 telemetry應用程式、Linux、BMC
標準 / 傳輸定義格式、搬運OpenTelemetry(SDK、OTLP、Collector)
儲存存與查詢Prometheus/Mimir、Loki、Tempo
視覺化看、告警Grafana

6. 實際情境:把軟體和硬體資料關聯起來​

同時收集 in-band 與 out-of-band 資料,價值在於能跨層找出根因:

如果只有 host 端的 OTel 資料,只能看到「node07 變慢」。加上 BMC 的 telemetry,才能一路追到「風扇壞了」。


7. 名詞速查​

名詞一句話
Telemetry從系統收集回來的狀態資料(metrics / logs / traces / profiles)
Observability能從外部訊號推斷系統內部狀態的能力
OpenTelemetry產生與傳輸 telemetry 的開放標準和工具
OTLPOTel 的傳輸協定
OTel Collector接收、加工、轉送 telemetry 的 agent / gateway
BMC伺服器上獨立的管理控制器,提供 out-of-band 硬體遙測
Redfish TelemetryServiceRedfish 定義的 metric 報表與訂閱機制
SELSystem Event Log,BMC 記錄的硬體事件
Prometheus / Mimirmetrics 資料庫(Mimir 是可水平擴展的版本)
Loki只索引 label 的 log 資料庫
Tempotrace 資料庫
Grafana視覺化與告警 UI,本身不存資料
AlloyGrafana 版的 OTel Collector13

參考資料​

Footnotes​

  1. OpenTelemetry Blog, OpenTelemetry announces support for profiling, 2024-03-19. https://opentelemetry.io/blog/2024/profiling/ ↩

  2. OpenTelemetry, What is OpenTelemetry?(History 一節). https://opentelemetry.io/docs/what-is-opentelemetry/ ↩ ↩2

  3. CNCF, A Brief History of OpenTelemetry (So Far), 2019-05-21. https://www.cncf.io/blog/2019/05/21/a-brief-history-of-opentelemetry-so-far/ ↩

  4. OpenTelemetry, Collector Architecture. https://opentelemetry.io/docs/collector/architecture/ ↩

  5. Grafana Loki, How is native OTLP endpoint different from Loki Exporter. https://grafana.com/docs/loki/latest/send-data/otel/native_otlp_vs_loki_exporter/ ↩

  6. opentelemetry-collector-contrib, CHANGELOG(v0.131.0:移除 Loki Exporter). https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CHANGELOG.md ↩

  7. openbmc/dbus-sensors. https://github.com/openbmc/dbus-sensors ↩

  8. openbmc/telemetry. https://github.com/openbmc/telemetry ↩

  9. openbmc/bmcweb. https://github.com/openbmc/bmcweb ↩

  10. DMTF Redfish, TelemetryService schema. https://redfish.dmtf.org/schemas/v1/TelemetryService.json ↩

  11. Grafana Loki, Understand labels. https://grafana.com/docs/loki/latest/get-started/labels/ ↩

  12. Grafana Loki, Label best practices. https://grafana.com/docs/loki/latest/get-started/labels/bp-labels/ ↩

  13. Grafana Alloy, Introduction. https://grafana.com/docs/alloy/latest/introduction/ ↩