Prometheus 監控整合是 Genero Enterprise 6 版本(2025 年底發布)的核心功能,提供系統和服務的監控與可觀測性能力。
什麼是 Prometheus?
Prometheus 是一個「免費的開放原始碼指標收集與監控工具」,用於監控系統和服務。一個典型的監控平台包含以下元件:
- Exporters(匯出器):在受監控主機上執行,負責提供指標資料。
- Prometheus:集中收集和儲存指標資料。
- Alertmanager:根據指標觸發警示通知。
- Grafana:視覺化儀表板工具。
- PromQL:Prometheus 的查詢語言。
在這個生態系中,Genero 工具扮演 Exporter 的角色,對外提供指標資料供 Prometheus 定期收集。
支援 Prometheus 的 Genero 產品
以下 Genero 產品可提供指標資料:
- Genero Application Server (GAS)
- Genero BDL(搭配 Prometheus 套件)
- Genero Report Writer
- Four Js License Manager
- SSO、GIP 及 Delegation Services
重要限制
使用 Prometheus 有一個重要前提:必須有東西在監聽 Prometheus 的輪詢請求。以下情境無法提供指標資料:
- 使用 Direct Connection 或 Local Execution 執行的應用程式
- Genero Mobile 或 Web 應用程式
- 非 Distributed Mode 的 Genero Report Writer
此外,Prometheus 以固定間隔(通常 15-30 秒)進行輪詢,因此指標的更新會有時間延遲。
快速入門步驟
GAS 的 Prometheus 快速入門說明如下:
- 下載並安裝 Prometheus
- 在 GAS 中啟用 Prometheus(設定
res.prometheus.enabled = TRUE) - 設定 Prometheus 存取 GAS 的指標端點(
/metrics)
在 4GL 程式中建立自訂指標
透過 Genero BDL 的 Prometheus 套件,可以在 4GL 程式中建立自訂指標。實作分為四個步驟:
步驟一:匯入套件
IMPORT prometheus
步驟二:定義變數
DEFINE counter prometheus.Counter
DEFINE gauge prometheus.Gauge
DEFINE histogram prometheus.Histogram
步驟三:建立指標
LET counter = prometheus.Counter.create(
"counter_hello", "a counter", ["labela", "labelb"])
LET gauge = prometheus.Gauge.create(
"gauge_hello", "a gauge", ["labela", "labelb"])
LET histogram = prometheus.Histogram.create(
"histogram_hello", "a histogram",
[0.25, 0.75, 0.9], ["labela", "labelb"])
步驟四:記錄數值
CALL counter.inc(["valuea", "valueb"])
CALL gauge.set(4.2, ["valuea", "valueb"])
CALL histogram.observe(5.2, ["valuea", "valueb"])
指標類型說明
- Counter(計數器):只增不減的累計值,適合記錄請求次數、錯誤次數等。
- Gauge(量表):可增可減的瞬時值,適合記錄目前連線數、記憶體使用量等。
- Histogram(直方圖):記錄觀測值的分佈,適合記錄請求回應時間等。
Grafana 視覺化整合
Grafana 提供 Prometheus 資料的視覺化儀表板。透過 PromQL 查詢語言,可以結合多個指標進行複雜的分析,例如計算各時間段的錯誤請求百分比。
文件中提供了多個指標列表的說明頁面,涵蓋 GAS/SSO/GIP 指標、Genero Report Writer 指標,以及 Four Js License Manager 指標。
原文:https://4js.com/ask-reuben/ig-311/
· 有任何 Genero 技術問題或翻譯疑問,歡迎來信
support@t100.app