Skip to content

MonitoringPlugin zh TW

ArchiBot edited this page Oct 6, 2026 · 10 revisions

監控外掛程式

MonitoringPlugin是ASF的官方外掛程式,它使您能夠透過Prometheus時間序列資料庫監控ASF程序。


擷圖

顯示

擷圖


需求

由於技術限制,這個外掛程式需要使用generic變體版本的ASF。


啟用外掛程式

預設情形下ASF不附隨MonitoringPlugin,但它仍作為選擇性的附加元件存在於每個ASF版本中。從官方版本頁面下載符合您ASF版本的外掛程式,然後為該外掛程式建立一個專屬的plugins/ArchiSteamFarm.OfficialPlugins.Monitoring資料夾,並將壓縮檔解壓縮至其中。

在下次啟動ASF時,外掛程式將會透過標準ASF記錄機制來通知您成功啟用。您也可以前往IPC介面/Api/metrics URL來驗證。若您使用IPC密碼,您需要提供正確的驗證資訊,例如在/Api/metrics URL後面加上?password=<您的IPC密碼>。您看到的內容應該類似下列:

# TYPE asf_build_info gauge
# HELP asf_build_info Build information about ASF in form of label values
asf_build_info{variant="source",version="6.0.2.5"} 1 1713715703686

# TYPE asf_runtime_info gauge
# HELP asf_runtime_info Runtime information about ASF in form of label values
asf_runtime_info{framework=".NET 8.0.4",operating_system="Debian GNU/Linux trixie/sid",runtime="linux-x64"} 1 1713715703686
(...)

與ASF及其Bot的指標,會在它們的名稱中含有專屬前綴asf_。其他的指標例如.NET執行環境或ASF的HttpClient,是依據通用.NET程序規則自動產生的,並不會帶有此前綴。


Prometheus 設定

在您確認外掛程式正確運作後,可以像這樣在您的Prometheus實例中新增一個收集設定:

scrape_configs:
  - job_name: ArchiSteamFarm
    metric_name_escaping_scheme: underscores # Remove if using Prometheus V2.x - read more below
    metrics_path: /Api/metrics
    params:
      password:
        - YourIPCPassword
    static_configs:
      - targets:
          - 127.0.0.1:1242

很明顯您需要確保您代管的Prometheus實例能夠存取ASF的IPC介面,並依您的實際使用方式填寫password及targets。若您並未設定IPC密碼(並不建議這樣做),則能跳過params部分。若您執行多個擁有不同IPC密碼的ASF實例,您可以新增額外的收集設定來對應每個實例,因為無法針對每個實例來設定出查詢參數。但如果它們使用相同的密碼,您就能直接宣告多個targets。


Grafana 儀表板

在Prometheus收集到您的各項數據後,您就能使用Grafana來視覺化這些資料。外掛程式自帶了由標準IPC機制提供的/grafana-dashboard.json檔案,因此假設您以預設設定執行您的ASF實例,就可以在這裡下載。或者,您也可以從我們的儲存庫中抓取。


Prometheus, Grafana dashboard and metrics escaping scheme

ASF supports various metrics escaping schemes since V6.3.8.4, with unified, complete solution starting from V6.3.9.4 (as part of #3607).

This unfortunately causes a slight issue in regards to our Grafana dashboard, since for that to work you need precise metric names as parsed by Prometheus, and that software behaves in two different ways by default depending on whether you use V2.x or V3.x version of it. See UTF-8 Prometheus docs for more info.

While waiting for Prometheus V3.x to get widely adopted (with debian stable as current guideline), we recommend legacy approach, that is:

  • Our Grafana dashboard comes with underscore names by default, that are recognized by Prometheus V2.x
  • Use metric_name_escaping_scheme: underscores as part of ASF scrape config (as in example above), if using Prometheus V3.x

This is because, while Prometheus V3.x can be easily configured to use the legacy approach, Prometheus V2.x has no such job-specific option to force the new one to be used.

In the future, we'll likely refactor our Grafana dashboard to use the new recommended defaults, and the setting will no longer be required. Today doing that would cause issues for older Prometheus users, which is not warranted.

Of course, the plugin in ASF itself supports all different formatting options, so you can always pick the one you like and adapt the Grafana dashboard to it yourself - we're just making it easier for you with a simple one-line config change recommendation.

Clone this wiki locally