監控

KES 伺服器提供一個 metrics API 端點,以 Prometheus 輸出格式公開各種伺服器指標。

Prometheus 設定

請依照下列步驟開始使用 Prometheus 監控 KES。

  1. 產生 Prometheus 憑證

    建立供 Prometheus 伺服器用來向 KES 驗證的憑證。

    $ kes identity new --key client.key --cert client.crt prometheus
    
      Private key:  client.key
      Certificate:  client.crt
      Identity:     2169daa644eb18b41d85214a20f7272d449e85ef4f1bf3e2609fbe3fa7ca00cd
    
  2. 建立 KES 政策

    在 KES 伺服器上建立一項政策,允許 Prometheus 抓取指標。

    policy:
      prometheus:
        allow:
        - /v1/metrics
        identities:
        - 2169daa644eb18b41d85214a20f7272d449e85ef4f1bf3e2609fbe3fa7ca00cd # Use the identity of your client.crt
    
    修改組態檔後,重新啟動 KES 伺服器。
  3. 建立 Prometheus 抓取設定

    設定 Prometheus 在抓取 KES 指標時使用 TLS 用戶端憑證。

    global:
      scrape_interval:     15s
      evaluation_interval: 15s
    
    scrape_configs:
      - job_name: KES
        scheme: https
        tls_config:
          cert_file: client.crt
          key_file:  client.key
          # ca_file: public.crt           # Optionally, specify the KES server CA certificate or the self-signed KES server certificate. 
        metrics_path: /v1/metrics
        static_configs:
          - targets: ['localhost:7373']   # Specify KES endpoint.
    

在 KES 和 Prometheus 伺服器啟動後,Prometheus 應會偵測並顯示新的 KES 目標。

Grafana

若要使用圖形儀表板,您可以將 Prometheus 抓取的 KES 指標連線至 Grafana。

An example Grafana dashboard in dark mode showing KES metrics

MinIO 為 KES 提供 Grafana 儀表板設定範例。請參閱 Github 上的 JSON 檔案。

參考