⏱ Time Series
InfluxDB on Windows + Grafana — Full Setup Guide
Install InfluxDB on Windows, create a database and API token, connect it to Grafana as a data source and write your first Flux queries. Covers both InfluxDB 2.x and legacy 1.x.
Step 1 — Download and install InfluxDB on Windows
# Download InfluxDB 2.x for Windows
$version = "2.7.11"
$url = "https://dl.influxdata.com/influxdb/releases/influxdb2-$version-windows.zip"
Invoke-WebRequest -Uri $url -OutFile "influxdb.zip"
Expand-Archive -Path "influxdb.zip" -DestinationPath "C:\InfluxDB" -Force
# Create data directory
New-Item -ItemType Directory "C:\InfluxDB\data" -Force | Out-NullStep 2 — Install InfluxDB as a Windows Service
# Register the service
sc.exe create InfluxDB `
binPath= "C:\InfluxDB\influxd.exe" `
start= auto `
DisplayName= "InfluxDB"
# Start InfluxDB
Start-Service -Name "InfluxDB"
# Verify it is running
Invoke-WebRequest "http://localhost:8086/ping" -UseBasicParsingStep 3 — Initial setup
Open http://localhost:8086 in your browser. Complete the setup wizard:
- Create an admin username and password
- Enter an organisation name (e.g. my-org)
- Create an initial bucket (e.g. metrics)
- Copy the generated API token — you will need it for Grafana and Telegraf
# Or set up via CLI
C:\InfluxDB\influx.exe setup `
--username admin `
--password StrongPassword! `
--org my-org `
--bucket metrics `
--retention 30d `
--forceStep 4 — Collect Windows metrics with Telegraf
Telegraf is the official metrics agent for InfluxDB. It collects Windows performance counters and sends them to InfluxDB.
# Download Telegraf for Windows
$tUrl = "https://dl.influxdata.com/telegraf/releases/telegraf-1.32.0_windows_amd64.zip"
Invoke-WebRequest -Uri $tUrl -OutFile "telegraf.zip"
Expand-Archive -Path "telegraf.zip" -DestinationPath "C:\Telegraf" -ForceCreate C:\Telegraf\telegraf.conf:
[agent]
interval = "10s"
flush_interval = "10s"
[[outputs.influxdb_v2]]
urls = ["http://localhost:8086"]
token = "YOUR_INFLUXDB_API_TOKEN"
organization = "my-org"
bucket = "metrics"
# Windows CPU
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
ObjectName = "Processor"
Instances = ["_Total"]
Counters = ["% Processor Time", "% Idle Time"]
Measurement = "win_cpu"
# Windows Memory
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
ObjectName = "Memory"
Counters = ["Available Bytes", "% Committed Bytes In Use"]
Measurement = "win_mem"# Install Telegraf as a service
C:\Telegraf\telegraf.exe --service install --config C:\Telegraf\telegraf.conf
Start-Service -Name "telegraf"Step 5 — Connect InfluxDB to Grafana
In Grafana go to Connections → Data sources → Add new → InfluxDB:
Query language: Flux
URL: http://localhost:8086
Organisation: my-org
Token: YOUR_INFLUXDB_API_TOKEN
Default bucket: metricsClick Save & test. Then explore data in Grafana → Explore with a Flux query:
from(bucket: "metrics")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "win_cpu")
|> filter(fn: (r) => r._field == "% Processor Time")Firewall rules for InfluxDB
# Allow Grafana and Telegraf to reach InfluxDB
New-NetFirewallRule `
-DisplayName "InfluxDB API" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 8086 `
-RemoteAddress 127.0.0.1 `
-Action AllowSecurity: For local-only use, restrict InfluxDB to localhost (127.0.0.1) and block external access to port 8086.