Skip to content

MonitoringPlugin zh TW

ArchiBot edited this page Apr 22, 2024 · 7 revisions

監控外掛程式

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


擷圖

顯示

擷圖


需求

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


啟用外掛程式

ASF does not come with MonitoringPlugin bundled by default, however, it's included as optional addition in every ASF release. Download the plugin from the official release that matches your ASF version, then create a dedicated plugins/ArchiSteamFarm.OfficialPlugins.Monitoring directory for the plugin, and finally extract the archive there.

On the next launch of ASF, the logs will indicate that the plugin has been successfully loaded through standard ASF logging mechanism. You can also verify this by navigating to /Api/metrics URL in your IPC interface. If you are using IPC password, you'll need proper authorization, e.g. appending ?password=<YourIPCPassword> to the /Api/metrics URL. The content you see should look similar to below:

# 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
(...)

Metrics regarding ASF and the bots have dedicated prefix asf_ in their name. Other metrics e.g. regarding the .NET runtime or ASF's HttpClient are automatically generated based on universal .NET process rules and do not carry such prefix.


Prometheus 設定

Once you verified the plugin is working correctly, you can add a scrape configuration to your Prometheus instance as such:

scrape_configs:
  - job_name: ArchiSteamFarm
    metrics_path: /Api/metrics
    params:
      - password:
          - YourIPCPassword
    static_configs:
      - targets:
          - 127.0.0.1:1242

Naturally, you need to ensure that your hosted Prometheus instance is able to reach ASF's IPC interface, adapt password and targets accordingly to your usage. If you do not have IPC password set (which is not recommended), you can skip the addition of the params section. In case you're running multiple ASF instances with different IPC passwords, you can add additional scrape configurations, one per instance, as the query parameters can not be set on a per-target basis. Otherwise, you can declare several targets if they share the same password.


Grafana 儀表板

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

Clone this wiki locally