Welcome @mohanrajpandiyan to the Grafana forum.
Do you have Telegraf streaming any data into InfluxDB, and are you already able to see that data in Grafana?
Since you are on Windows, this is significantly more difficult than on Linux because Windows does not standardly expose Fan Speed or detailed Battery Health (like cycle counts) to standard monitoring tools.
To get Fan Speed and CPU Temp, you must use a third-party helper app. To get Battery Cycles, you must use a custom PowerShell script.
Here is the two-part solution specifically for Windows.
Part 1: CPU Temp & Fan Speed (Requires “LibreHardwareMonitor”)
Windows WMI (the standard data source) rarely includes fan speeds. You need a tool to bridge the hardware sensors to WMI so Telegraf can read them.
-
Download: Get LibreHardwareMonitor (it is a more updated fork of OpenHardwareMonitor).
-
Run: Extract and run LibreHardwareMonitor.exe as Administrator.
-
Configure: Go to Options → Enable WMI. (This is the critical step).
-
Telegraf Config: Now that the data is in WMI, use the inputs.win_perf_counters plugin to read it.
Ini, TOML
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# LibreHardwareMonitor exposes sensors under this object name
ObjectName = "LHM-Hardware-Sensor"
Counters = ["Value"]
Instances = ["*"]
Measurement = "hardware_sensors"
# This will pull in CPU Temps, Fan RPMs, and voltages.
Note: You must keep LibreHardwareMonitor running in the background for this to work.
Part 2: Battery Health, Cycles & Status (PowerShell Script)
The standard Windows plugins won’t calculate “Health %” or find “Cycle Count.” You must use the inputs.exec plugin to run a PowerShell script that queries the deep root/wmi namespace.
1. Create the Script Save the following code as C:\Program Files\Telegraf\get_battery.ps1.
PowerShell
# Get Static Data (Capacity, Cycles)
$static = Get-WmiObject -Namespace root/wmi -Class BatteryStaticData -ErrorAction SilentlyContinue
# Get Dynamic Data (Current Status, Level)
$status = Get-WmiObject -Namespace root/cimv2 -Class Win32_Battery -ErrorAction SilentlyContinue
if ($static -and $status) {
# Calculate Health
# Note: Values are usually valid, but prevent div by zero
if ($static.DesignedCapacity -gt 0) {
$health = [math]::Round(($static.FullChargedCapacity / $static.DesignedCapacity) * 100, 2)
} else {
$health = 0
}
# Map Status Code to Text
# 1=Discharging, 2=AC/Charging, 3=Fully Charged, etc.
$statusText = switch ($status.BatteryStatus) {
1 {"Discharging"}
2 {"Charging"}
3 {"Full"}
4 {"Low"}
5 {"Critical"}
Default {"Unknown"}
}
# Output in InfluxDB Line Protocol format
# measurement,tags fields
Write-Host "win_battery,source=powershell health=$health,cycle_count=$($static.CycleCount),percent=$($status.EstimatedChargeRemaining),status_code=$($status.BatteryStatus),status_text=""$statusText"""
}
2. Configure Telegraf Add this to your telegraf.conf.
Ini, TOML
[[inputs.exec]]
# command to run the powershell script
commands = ["powershell -ExecutionPolicy Bypass -File \"C:\\Program Files\\Telegraf\\get_battery.ps1\""]
# data format strictly implied by the script output
data_format = "influx"
# Don't run this too often; battery stats change slowly
interval = "1m"
timeout = "10s"
Summary of Data You Will Get
-
From Part 1 (LHM):
-
You will see measurements named hardware_sensors.
-
Look for Instance tags containing cpu or fan.
-
Field Value will contain the temperature or RPM.
-
From Part 2 (Script):
-
Measurement: win_battery
-
Fields:
-
health (0-100%)
-
cycle_count (Integer)
-
percent (Current battery level)
-
status_text (“Charging”, “Discharging”, etc.)