Skip to content

Instantly share code, notes, and snippets.

@kui
Last active November 8, 2025 08:45
Show Gist options
  • Select an option

  • Save kui/52bbb6acba40d51421cce811815aa6d2 to your computer and use it in GitHub Desktop.

Select an option

Save kui/52bbb6acba40d51421cce811815aa6d2 to your computer and use it in GitHub Desktop.
Windows で各種リソースを時系列データとしてグラフ化する

これが実現できる。

スクリーンショット

HWiNFO だと期待した形で情報が取れなかったので、OhmGraphite を使うことにした。

構成としては以下でやっていく。すべてローカルで動かし、Windowsサービス化する。

1. OhmGraphite インストール

から最新版をダウンロードして適当な場所に展開する。今回は C:\OhmGraphite に展開した。 記述時点のバージョン v0.36.0 では Pown.IO のインストールが必要なのでそれもやっておく。

設定 c:\OhmGraphite\OhmGraphite.exe.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="type" value="prometheus" />
    <add key="prometheus_port" value="4445" />
    <add key="prometheus_host" value="localhost" />
  </appSettings>
</configuration>

hostとしてバインドするのはあくまでlocalhostとしておく。今回はすべてのプロセスがlocalhost上で動作する前提で進めるので。

PowerShell:

PS C:\OhmGraphite> .\OhmGraphite.exe install
[SC] CreateService SUCCESS

[SC] ChangeServiceConfig2 SUCCESS
PS C:\OhmGraphite> .\OhmGraphite.exe start
OhmGraphite started

http://localhost:4445/metrics でPrometheus向けのメトリクスが見えることを確認する。

2. Prometheus インストール

から最新版をダウンロードして適当な場所に展開する。今回は C:\Prometheus に展開した。 記述時点のLTSバージョンは3.5.0。

Prometheusの設定ファイル C:\Prometheus\prometheus.yml:

global:
  scrape_interval: 30s
scrape_configs:
  - job_name: 'ohmgraphite'
    static_configs:
      - targets: ['localhost:4445']

prometheus.exeをダブルクリックして動作確認をする。http://localhost:9090/targets で "ohmgraphite" ジョブが UP になっていることを確認する。

http://localhost:9090/query?g0.expr=ohm_cpu_celsius&g0.tab=graph などでメトリクスが取得できることを確認する。これはCPU温度を表すグラフ。

問題なさそうならCtrl+CでPrometheusを停止する。

サービス化のための設定ファイル C:\Prometheus\prometheus-service.xml:

<!--
  WinSW configuration file
  https://github.com/winsw/winsw
-->
<service>
  <id>Prometheus</id>
  <name>Prometheus</name>
  <executable>prometheus.exe</executable>
  <arguments>
    --web.listen-address=localhost:9090
    --storage.tsdb.retention.time=30d
    --storage.tsdb.retention.size=1GB
  </arguments>
  <workingdirectory>%BASE%</workingdirectory>
  <depend>Tcpip</depend>
  <depend>Eventlog</depend>
  <log mode="roll-by-size" />
</service>

WinSWをダウンロードして、実行ファイルを C:\Prometheus\prometheus-service.exe と名前変更して配置し、下記実行する。

PS C:\Prometheus> .\prometheus-service.exe install
2025-11-08 16:22:54,847 INFO  - Installing service 'Prometheus (Prometheus)'...
2025-11-08 16:22:54,879 INFO  - Service 'Prometheus (Prometheus)' was installed successfully.
PS C:\Prometheus> .\prometheus-service.exe start
2025-11-08 16:33:15,559 INFO  - Starting service 'Prometheus (Prometheus)'...
2025-11-08 16:33:16,013 INFO  - Service 'Prometheus (Prometheus)' started successfully.

http://localhost:9090/targets で先ほど同様 "ohmgraphite" ジョブが UP になっていることを確認する。

3. Grafana インストール

からインストーラーをダウンロードしてインストールする。インストーラーを実行するとサービス化も自動でやってくれる。 ほか同様の手順でWinSWでサービス化してインストールする選択肢もあるが不要ならそれが一番なのでインストーラーを使う。 記述時点のバージョンは12.2.1。

設定ファイル C:\Program Files\GrafanaLabs\grafana\conf\custom.ini:

[server]
http_addr = 127.0.0.1

TODO: 匿名アクセス設定してもよさそう

サービスを再起動する。

http://localhost:3000/ にアクセスして admin/admin でログインする。パスワード変更を促されるけどスキップ。

左カラムから Connections → "Add new Connection" でPrometheusを探して下記のように入力する。

ページ下部の "Save & Test" をクリックして動作確認。

4. ダッシュボードインポート

左カラムから Dashboards → "Import" をクリックする。 Dashboard URL には https://grafana.com/grafana/dashboards/11587-ohm-windows-desktop/ を使う。 これは OhmGraphite の README に載っているダッシュボード。

Load を押し、Prometheus の項目に先ほど作成した "Local Prometheus" を選択して "Import" をクリックする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment