Point the OpenTelemetry vCenter receiver at an all NFS cluster and you get a metric called vcenter.host.disk.latency.avg. It looks like exactly what you wanted. On an NFS estate it is mostly measuring the host’s boot device, because the vSphere counters behind it belong to the SCSI disk group and an NFS datastore is not a SCSI device. Meanwhile the counters that do describe your NFS datastores, per host and per datastore, are not collected by the receiver at all. This post maps what each latency number actually measures on the NFS I/O path, what the receiver can and cannot see, and how to fill the gaps with a small PowerCLI bridge, the array’s own metrics, and a handful of ESXi commands that do not need vsish.
Level: intermediate to advanced · Stack: vSphere 8 / VCF 9, otelcol-contrib v0.166+, VCF PowerCLI 9, Prometheus 3.x, Grafana 11+ · Build time: about 2 hours
Contents
- The problem: disk latency that is not your NFS latency
- Where latency is measured on the NFS I/O path
- What the vcenterreceiver actually exposes
- What it cannot see
- Filling the gaps
- Collection architecture
- Template: collector configuration
- Template: PowerCLI bridge and cross-check
- Template: PromQL set
- Template: Grafana alert rules
- End-to-end workflow
- Troubleshooting
- What’s next
01. The problem: disk latency that is not your NFS latency
Every storage conversation eventually becomes a latency conversation, and on NFS the conversation goes wrong in a predictable way. The application team says the database is slow. The virtualization team opens the vSphere Client, looks at the host Disk chart, and sees nothing alarming. The storage team opens the array GUI and sees sub millisecond response times. All three are telling the truth, and none of them is looking at the same layer.
NFS makes this worse than block storage for three reasons. First, there is no LUN, so the SCSI device counters that VMware admins learned to read on VMFS (the ones behind esxtop’s DAVG, KAVG and GAVG) simply do not describe an NFS datastore. Second, the network sits in the middle of every I/O, so the gap between what the array reports and what the host experiences is real and can be large. Third, the per datastore counters that do exist for NFS live in a different counter group, datastore, which most collectors, including the OpenTelemetry vCenter receiver, do not query.
The short version. On NFS, use
vcenter.vm.disk.latency.avgfor what each virtual disk experiences, bridge the host leveldatastore.totalReadLatency.averageanddatastore.totalWriteLatency.averagecounters in yourself for per host, per datastore latency, and scrape the array for its own view. Do not usevcenter.host.disk.latency.avgfor NFS at all.
If you are still choosing between NFS versions, the protocol differences that affect latency and path behaviour are covered in NFSv3 and NFSv4.1 in VMware vSphere. Everything in this post applies to both; where the commands differ, I call it out.
02. Where latency is measured on the NFS I/O path
Before collecting anything, be precise about where each number is taken. A write from a guest passes through six layers before it is acknowledged, and every latency counter you can get covers a contiguous slice of that stack, always from some point down to the bottom. That property is what makes subtraction useful.
The block storage habit is to think in esxtop terms: DAVG for the device, KAVG for the VMkernel, GAVG as their sum and the number the guest feels. Those columns are defined for SCSI devices. For NFS the closest analogues are these, and the mapping is approximate by nature.
| Block storage habit | Closest NFS analogue | Where you get it | In vcenterreceiver? |
|---|---|---|---|
| GAVG (what the VM’s disk sees) | Per virtual disk total latency | virtualDisk.totalReadLatency.average / totalWriteLatency; esxtop v view LAT/rd, LAT/wr | Yes: vcenter.vm.disk.latency.avg |
| KAVG + DAVG (host to storage) | Per host, per datastore total latency from the NFS client | datastore.totalReadLatency.average / totalWriteLatency, instance = datastore UUID | No |
| DAVG alone | No clean equivalent. There is no device layer below the NFS client; network and server time are inseparable from the host side | Array-reported latency gives you the server part; the remainder is network plus client queueing | No |
| QAVG (queue) | NFS client queueing, visible indirectly | esxtop NFS view, vmkernel.log queue and latency warnings | No |
| Guest await | Same in both worlds | In-guest agent (iostat, PerfMon, OTel host metrics) | No |
Two notes on the esxtop side. Broadcom’s KB on NFS latency log messages (KB 335047) directs you to press n for the NFS view on ESXi 7.x and 8.x hosts and enable the DAVG/cmd and KAVG/cmd fields; check h on your build, because esxtop views have moved between releases. And Broadcom’s KB 427727 reads a rise in both KAVG and DAVG on the NFS datastore as I/O queueing on the host caused by a slow NFS server. In other words, on NFS do not read DAVG as “the disk” the way you would on a LUN.
The ESXi kernel also does some of this work for you. Since ESXi 7.0 for NFSv3 and 7.0 Update 1 for NFSv4.1, the NFS client keeps a moving average of I/O latency per volume and logs to vmkernel.log when it deteriorates, for example NFS volume <name> performance has deteriorated. I/O latency increased from average value of 4873(us) to 8900(us), and when the average exceeds a threshold that defaults to 10 ms. Those lines are cheap, early and per volume, and they are what post 10 in this series turns into alerts.
03. What the vcenterreceiver actually exposes
The vCenter receiver (vcenter in otelcol-contrib) is still alpha for metrics, and every metric in its metadata.yaml is marked development stability. Names and attributes can change between releases, so pin your collector version and read the changelog before upgrading. The table below is taken from the receiver’s metadata.yaml and, more usefully, from its source: the metric names tell you little until you know which vSphere counter feeds each one.
| Metric (default) | vSphere counter behind it | Granularity | Attributes | Useful on NFS? |
|---|---|---|---|---|
vcenter.vm.disk.latency.avg (on), ms | virtualDisk.totalReadLatency.average, virtualDisk.totalWriteLatency.average | Per VM, per virtual disk | direction read/write, disk_type, object (e.g. scsi0:0) | Yes. Best per VMDK signal |
vcenter.vm.disk.latency.max (on), ms | disk.maxTotalLatency.latest | Per VM | object | Treat with suspicion; it is a disk group counter |
vcenter.vm.disk.throughput (on), KiBy/s | virtualDisk.read.average, virtualDisk.write.average | Per VM, per virtual disk | direction, object | Yes, for weighting |
vcenter.host.disk.latency.avg (on), ms | disk.totalReadLatency.average, disk.totalWriteLatency.average | Per host, per SCSI device | direction, object (device name) | No. NFS datastores are not in the disk group |
vcenter.host.disk.latency.max (on), ms | disk.maxTotalLatency.latest | Per host | object | No, same reason |
vcenter.host.disk.throughput (on), KiBy/s | disk.read.average, disk.write.average | Per host, per SCSI device | direction, object | No |
vcenter.host.network.packet.drop.rate, .error.rate (on) | net.dropped*, net.errors* | Per host, per vmnic | direction, object | Yes, as context for NFS path problems |
vcenter.datastore.disk.usage, .utilization (on) | Datastore summary properties | Per datastore | disk_state | Capacity only, no latency |
vcenter.datastore.maintenance.status, vcenter.host.connection.status, vcenter.datastore.alarm.count (off) | Inventory properties | Per object | state enums | Yes, as context. Added in v0.166.0, disabled by default |
Four details in the source code matter more than anything in the metric descriptions.
- One sample per scrape. The receiver queries vSphere’s 20 second real time interval with
MaxSample: 1for hosts and, through govmomi’s default, for VMs too. At the defaultcollection_intervalof 2 minutes you see one 20 second average out of every six. At 60 seconds you see one in three. Short latency spikes between scrapes are invisible. That matters when you later compute a “p95”: it is the 95th percentile of sampled 20 second averages, not of individual I/Os. - All instances. govmomi requests instance
*, so you get one series per virtual disk (object="scsi0:0","scsi0:1", and so on) plus aggregates where vCenter provides them. Good for detail, and it is where your series count comes from (post 08 does the arithmetic). disk_typeis alwaysvirtual. The VM query list includesdisk.totalReadLatency.average, but the code only records thevirtualDiskcounters, labelleddisk_type="virtual". Do not wait forphysicalseries on NFS; the current code never emits them.- No datastore on the VM series. VM metrics carry
vcenter.vm.name,vcenter.vm.id, host, cluster, resource pool and datacenter as resource attributes, but not the datastore. A VM with disks on two datastores is common, so you need a VMDK to datastore mapping to aggregate per datastore. Section 05 builds one.
The receiver documentation says the VM disk latency metric needs performance counter level 2 and that some per device host metrics need level 3 or 4. If one of these metrics stays empty while others arrive, the statistics level configured in vCenter is the first thing to check.
04. What it cannot see
With that mapping in hand, here is the list of NFS questions the receiver alone cannot answer.
- Per host, per datastore latency. The single most useful NFS number, because it isolates one host’s path to one export. The counters exist (
datastore.totalReadLatency.average,datastore.totalWriteLatency.average, plusdatastore.numberReadAveraged.averageanddatastore.numberWriteAveraged.averagefor IOPS) with the datastore UUID as the instance. The receiver does not request them. - Per datastore aggregates of VM latency. Without a VMDK to datastore map you cannot say “the 95th percentile VMDK on
nfs-gold-01is at 18 ms”. - Anything between the NFS client and the array. Network round trip, retransmits on the storage VLAN, a congested uplink. The receiver gives per vmnic drop and error rates, which are useful context but not a latency figure.
- The array’s own view. Front end NFS operation latency, cache hit ratio, back end latency. Only the array knows.
- Queueing inside the NFS client. The evidence lives in esxtop and
vmkernel.log. Broadcom’s KB 427727 also uses avsishnode formaxQDepthReached;vsishis a debugging shell meant for support engagements, so this post deliberately builds on counters, esxcli and logs instead. - The guest’s own experience. Guest queueing and filesystem overhead (G minus A in Figure 1) needs an agent inside the guest. Post 05 covers that for Kubernetes nodes.
05. Filling the gaps
5.1 Host per datastore latency: a PowerCLI bridge that speaks OTLP
The cleanest way to get the datastore counters into the same pipeline is a small PowerShell loop that reads them from vCenter’s real time interval and pushes them to the collector’s OTLP/HTTP receiver as JSON. It needs nothing installed on ESXi, runs from any Linux or Windows box with PowerShell 7 and VCF PowerCLI (Broadcom renamed the module from VMware.PowerCLI to VCF.PowerCLI with the 9.0 release), and uses the same read only service account as the receiver.
Three choices make it work well. It asks for the last four 20 second samples every 60 seconds, so consecutive runs overlap and you get every real time sample rather than one in three; identical duplicates are accepted by Prometheus. It maps the counter instance, which is the datastore UUID from the datastore’s Info.Url, back to the datastore name, the same trick LucD published on the VMware community forum years ago. And it names its metrics in a namespace that cannot collide with the receiver: vsphere.host.datastore.latency (unit ms) and vsphere.host.datastore.operations (unit {operations}/s), with direction, vcenter.datastore.name and vsphere.datastore.type as data point attributes and the host, cluster and vCenter as resource attributes.
5.2 The VMDK to datastore map
The same script emits an info style metric, vsphere.vm.disk.info, value 1, one series per virtual disk, labelled with the VM’s instance UUID (matching the receiver’s vcenter.vm.id), the disk’s instance name in the same format vSphere uses for the virtualDisk counters (scsi0:0, nvme0:1, sata0:0), and the datastore. In PromQL a group_left join then attaches the datastore to every receiver latency series. It refreshes inventory every 10 minutes and re-sends the info series each cycle so it never goes stale.
5.3 ESXi side triage without vsish
When a dashboard says one host is slow on one datastore, these are the commands to run on that host. They are read only and safe on production.
# Which NFS datastores are mounted, from which server, over which vmknic
esxcli storage nfs list
esxcli storage nfs41 list
# Per-volume NFS client parameters, including MaxQueueDepth (ESXi 7.0 U3+ honours it)
esxcli storage nfs param get -v <DATASTORE_NAME>
# TCP sessions to the NFS server (2049 is NFS)
esxcli network ip connection list | grep 2049
# Path MTU and round trip from the storage vmknic, do not fragment, jumbo sized
vmkping -I <VMK_STORAGE> -s 8972 -d -c 20 <NFS_SERVER_IP>
# Recent NFS latency warnings from the kernel's moving average
grep -E 'NFS volume .* performance has (deteriorated|improved)|exceeded threshold' /var/run/log/vmkernel.log | tail -20
# esxtop: interactive NFS view is 'n' on 7.x/8.x per Broadcom KB 335047.
# Batch capture for later analysis: all counters, 5 s interval, 10 minutes.
esxtop -b -a -d 5 -n 120 > /tmp/esxtop-$(hostname)-$(date +%Y%m%d%H%M).csv
head -1 /tmp/esxtop-*.csv | tr ',' '\n' | grep -i -n 'nfs' | head
The last line is there because esxtop’s batch CSV column names vary by build; find the NFS columns first, then load the file into Windows PerfMon or a spreadsheet. If vmkping with -d -s 8972 fails while a plain vmkping works, you have an MTU mismatch on the storage path, which on NFS shows up as erratic latency long before anything fails outright.
5.4 The array side
Most NFS arrays expose either a Prometheus endpoint, natively or through a vendor exporter, or a REST API. The collector handles both without vendor specific code: the prometheus receiver scrapes the exporter exactly as Prometheus would, and the http_check receiver (renamed from httpcheck; the old name still works as a deprecated alias) probes the management API and emits httpcheck.duration, httpcheck.status and httpcheck.error. Name the array’s latency metric in your queries once you know what your exporter calls it; I use <ARRAY_LATENCY_METRIC> as a placeholder below. Make sure you know whether your array reports per export, per filesystem or per controller, and whether the unit is microseconds or milliseconds, before you subtract it from anything.
06. Collection architecture
The collector runs as a VM next to vCenter, not on ESXi. The bridge can run on the same VM. Prometheus 3.x receives metrics natively over OTLP when started with --web.enable-otlp-receiver, on the path /api/v1/otlp/v1/metrics, which removes a translation hop and keeps the collector’s persistent queue useful. Two Prometheus side settings matter: resource attributes are not promoted to labels by default, so you list the vcenter.* ones explicitly, and an out of order window lets a replayed queue land after an outage. Prometheus’ own OpenTelemetry guide suggests 30 minutes as a starting point.
Metric names translate predictably with the default UnderscoreEscapingWithSuffixes strategy: dots become underscores and the unit becomes a suffix, so vcenter.vm.disk.latency.avg with unit ms becomes vcenter_vm_disk_latency_avg_milliseconds, and a unit in curly braces such as {KiBy/s} is dropped. Attributes become labels the same way: vcenter.datastore.name becomes vcenter_datastore_name. Verify against your own Prometheus with the label values API in step 6 of the workflow before you build dashboards.
07. Template: collector configuration
Requires otelcol-contrib v0.166.0 or later (for the newer state metrics and the otlp_http and http_check component names). Secrets come from the environment; section 11 shows where they are set.
# /etc/otelcol-contrib/config.yaml
# otelcol-contrib >= v0.166.0. vcenter receiver is alpha: pin the version.
extensions:
health_check:
endpoint: 0.0.0.0:13133
file_storage/queue:
directory: /var/lib/otelcol-contrib/queue
create_directory: true
receivers:
vcenter/vc01:
endpoint: https://<VCENTER_FQDN>
username: ${env:VCENTER_USER}
password: ${env:VCENTER_PASSWORD}
collection_interval: 60s # default 2m; 60s = one of every three 20 s samples
initial_delay: 10s
max_query_metrics: 256 # keep <= vpxd.stats.maxQueryMetrics on vCenter
tls:
ca_file: /etc/otelcol-contrib/certs/vcenter-ca.pem
metrics:
# Latency-relevant metrics. All enabled by default; listed so nobody disables them by accident.
vcenter.vm.disk.latency.avg:
enabled: true
vcenter.vm.disk.throughput:
enabled: true
vcenter.host.network.packet.drop.rate:
enabled: true
vcenter.host.network.packet.error.rate:
enabled: true
vcenter.datastore.disk.utilization:
enabled: true
# SCSI-device counters: meaningless for NFS-only clusters. Keep if you also run VMFS.
vcenter.host.disk.latency.avg:
enabled: true
# Disabled by default, cheap and useful context on NFS (v0.166.0+).
vcenter.datastore.maintenance.status:
enabled: true
vcenter.datastore.alarm.count:
enabled: true
vcenter.host.connection.status:
enabled: true
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318 # PowerCLI bridge pushes here. Firewall to the bridge host.
prometheus/array:
config:
scrape_configs:
- job_name: nfs-array
scrape_interval: 30s
scheme: https
tls_config:
ca_file: /etc/otelcol-contrib/certs/array-ca.pem
static_configs:
- targets: ['<ARRAY_EXPORTER_HOST>:<ARRAY_EXPORTER_PORT>']
labels:
array: <ARRAY_NAME>
http_check/array:
collection_interval: 30s
targets:
- endpoint: https://<ARRAY_MGMT_FQDN>/<HEALTH_PATH>
method: GET
tls:
ca_file: /etc/otelcol-contrib/certs/array-ca.pem
processors:
memory_limiter:
check_interval: 1s
limit_mib: 1536
spike_limit_mib: 300
resource/vc01:
attributes:
- key: vcenter.server # our own attribute: the receiver does not emit one
value: <VCENTER_FQDN>
action: upsert
exporters:
otlp_http/prometheus:
endpoint: http://<PROMETHEUS_HOST>:9090/api/v1/otlp # /v1/metrics is appended
sending_queue:
storage: file_storage/queue
queue_size: 5000
batch:
flush_timeout: 5s
min_size: 2000
retry_on_failure:
enabled: true
max_elapsed_time: 15m
service:
extensions: [health_check, file_storage/queue]
pipelines:
metrics/vcenter:
receivers: [vcenter/vc01]
processors: [memory_limiter, resource/vc01]
exporters: [otlp_http/prometheus]
metrics/nfs:
receivers: [otlp, prometheus/array, http_check/array]
processors: [memory_limiter]
exporters: [otlp_http/prometheus]
And the Prometheus side. Start Prometheus with --web.enable-otlp-receiver and add:
# prometheus.yml (Prometheus 3.x)
otlp:
promote_resource_attributes:
- vcenter.server
- vcenter.datacenter.name
- vcenter.cluster.name
- vcenter.host.name
- vcenter.vm.name
- vcenter.vm.id
- vcenter.datastore.name
storage:
tsdb:
out_of_order_time_window: 30m
Note that batching sits inside the exporter’s sending_queue rather than in a batch processor. The Collector SIG deprecated the batch processor in November 2026 in favour of exporter level batching; post 08 explains the queue in detail.
08. Template: PowerCLI bridge and cross-check
Save as /opt/nfs-latency/nfs-latency-bridge.ps1. It reads VCENTER_SERVER, VCENTER_USER, VCENTER_PASSWORD and optionally OTLP_METRICS_URL from the environment. Run it once with -Once to test, then as a service.
#Requires -Version 7.2
<#
.SYNOPSIS
Bridges vSphere per-host, per-NFS-datastore latency/IOPS and a VMDK->datastore map
into an OpenTelemetry Collector over OTLP/HTTP JSON.
.NOTES
Install-Module VCF.PowerCLI (or VMware.PowerCLI 13.x against vCenter 8).
Read-only vCenter role is sufficient.
#>
param(
[string]$VCenter = $env:VCENTER_SERVER,
[string]$OtlpUrl = ($env:OTLP_METRICS_URL ?? 'http://127.0.0.1:4318/v1/metrics'),
[int] $IntervalSec = 60,
[int] $InventoryMinutes = 10,
[int] $ChunkSize = 400,
[switch]$Once
)
$ErrorActionPreference = 'Stop'
$scope = @{ name = 'nfs-latency-bridge'; version = '1.0.0' }
$counters = @('datastore.totalReadLatency.average', 'datastore.totalWriteLatency.average',
'datastore.numberReadAveraged.average', 'datastore.numberWriteAveraged.average')
function New-Attr([string]$k, $v) { @{ key = $k; value = @{ stringValue = [string]$v } } }
function ConvertTo-UnixNano([datetime]$t) {
$ms = ([DateTimeOffset]$t.ToUniversalTime()).ToUnixTimeMilliseconds()
return ('{0}000000' -f $ms)
}
function Connect-Vc {
if ($global:DefaultVIServer -and $global:DefaultVIServer.IsConnected) { return }
$sec = ConvertTo-SecureString $env:VCENTER_PASSWORD -AsPlainText -Force
$cred = [pscredential]::new($env:VCENTER_USER, $sec)
Connect-VIServer -Server $VCenter -Credential $cred | Out-Null
}
function Get-NfsDatastoreMap {
# Counter instance for datastore.* is the UUID at the end of Info.Url
$map = @{}
Get-Datastore | Where-Object { $_.Type -in 'NFS', 'NFS41' } | ForEach-Object {
$uuid = $_.ExtensionData.Info.Url.TrimEnd('/').Split('/')[-1]
$map[$uuid] = [pscustomobject]@{ Name = $_.Name; Type = $_.Type }
}
$map
}
function Get-VDiskMap {
# One row per virtual disk: VM instance UUID, counter-style instance name, datastore
$prefix = @{ ParaVirtualSCSIController = 'scsi'; VirtualLsiLogicController = 'scsi'
VirtualLsiLogicSASController = 'scsi'; VirtualBusLogicController = 'scsi'
VirtualNVMEController = 'nvme'; VirtualAHCIController = 'sata'; VirtualIDEController = 'ide' }
$views = Get-View -ViewType VirtualMachine -Property Name, Config.InstanceUuid, Config.Template, Config.Hardware.Device
foreach ($v in $views) {
if (-not $v.Config -or $v.Config.Template) { continue }
$devs = $v.Config.Hardware.Device
foreach ($d in ($devs | Where-Object { $_ -is [VMware.Vim.VirtualDisk] })) {
$ctl = $devs | Where-Object { $_.Key -eq $d.ControllerKey }
$p = $prefix[$ctl.GetType().Name]
if (-not $p) { continue }
if ($d.Backing.FileName -notmatch '^\[(?<ds>[^\]]+)\]') { continue }
[pscustomobject]@{
VmId = $v.Config.InstanceUuid; VmName = $v.Name
Object = '{0}{1}:{2}' -f $p, $ctl.BusNumber, $d.UnitNumber
Datastore = $Matches.ds
}
}
}
}
function Get-HostDatastoreResourceMetrics($nfsMap) {
$hosts = Get-VMHost -State Connected, Maintenance
if (-not $hosts) { return @() }
$stats = Get-Stat -Entity $hosts -Stat $counters -Realtime -MaxSamples 4 -ErrorAction SilentlyContinue |
Where-Object { $nfsMap.ContainsKey($_.Instance) }
foreach ($g in ($stats | Group-Object { $_.Entity.Name })) {
$h = $g.Group[0].Entity
$lat = [System.Collections.Generic.List[object]]::new()
$ops = [System.Collections.Generic.List[object]]::new()
foreach ($s in $g.Group) {
$ds = $nfsMap[$s.Instance]
$dir = if ($s.MetricId -match 'Read') { 'read' } else { 'write' }
$dp = @{ timeUnixNano = (ConvertTo-UnixNano $s.Timestamp); asDouble = [double]$s.Value
attributes = @((New-Attr 'direction' $dir), (New-Attr 'vcenter.datastore.name' $ds.Name),
(New-Attr 'vsphere.datastore.type' $ds.Type)) }
if ($s.MetricId -like '*Latency*') { $lat.Add($dp) } else { $ops.Add($dp) }
}
@{
resource = @{ attributes = @((New-Attr 'vcenter.server' $VCenter), (New-Attr 'vcenter.host.name' $h.Name),
(New-Attr 'vcenter.cluster.name' $h.Parent.Name)) }
scopeMetrics = @(@{ scope = $scope; metrics = @(
@{ name = 'vsphere.host.datastore.latency'; unit = 'ms'
description = 'Host NFS client latency per datastore (datastore.total*Latency.average)'
gauge = @{ dataPoints = $lat.ToArray() } },
@{ name = 'vsphere.host.datastore.operations'; unit = '{operations}/s'
description = 'Host operations per second per datastore (datastore.number*Averaged.average)'
gauge = @{ dataPoints = $ops.ToArray() } }) })
}
}
}
function Get-DiskInfoResourceMetrics($vdisks, $nfsMap) {
$now = ConvertTo-UnixNano (Get-Date)
$typeByName = @{}; foreach ($e in $nfsMap.Values) { $typeByName[$e.Name] = $e.Type }
foreach ($vmGroup in ($vdisks | Group-Object VmId)) {
$first = $vmGroup.Group[0]
$dps = foreach ($r in $vmGroup.Group) {
$t = $typeByName[$r.Datastore] ?? 'other'
@{ timeUnixNano = $now; asDouble = 1.0
attributes = @((New-Attr 'object' $r.Object), (New-Attr 'vcenter.datastore.name' $r.Datastore),
(New-Attr 'vsphere.datastore.type' $t)) }
}
@{
resource = @{ attributes = @((New-Attr 'vcenter.server' $VCenter), (New-Attr 'vcenter.vm.id' $first.VmId),
(New-Attr 'vcenter.vm.name' $first.VmName)) }
scopeMetrics = @(@{ scope = $scope; metrics = @(
@{ name = 'vsphere.vm.disk.info'; unit = ''
description = 'VMDK to datastore mapping, value always 1'
gauge = @{ dataPoints = @($dps) } }) })
}
}
}
function Send-Otlp([object[]]$resourceMetrics) {
for ($i = 0; $i -lt $resourceMetrics.Count; $i += $ChunkSize) {
$chunk = $resourceMetrics[$i..([math]::Min($i + $ChunkSize, $resourceMetrics.Count) - 1)]
$body = @{ resourceMetrics = @($chunk) } | ConvertTo-Json -Depth 32 -Compress
Invoke-RestMethod -Method Post -Uri $OtlpUrl -ContentType 'application/json' -Body $body -TimeoutSec 20 | Out-Null
}
}
$lastInventory = [datetime]::MinValue
$nfsMap = @{}; $vdisks = @()
do {
$started = Get-Date
try {
Connect-Vc
if (($started - $lastInventory).TotalMinutes -ge $InventoryMinutes) {
$nfsMap = Get-NfsDatastoreMap
$vdisks = @(Get-VDiskMap)
$lastInventory = $started
Write-Host ("{0:u} inventory: {1} NFS datastores, {2} virtual disks" -f $started, $nfsMap.Count, $vdisks.Count)
}
$rm = @(Get-HostDatastoreResourceMetrics $nfsMap)
if ($rm.Count) { Send-Otlp $rm }
$di = @(Get-DiskInfoResourceMetrics $vdisks $nfsMap)
if ($di.Count) { Send-Otlp $di }
Write-Host ("{0:u} sent {1} host resources, {2} VM disk-info resources" -f (Get-Date), $rm.Count, $di.Count)
} catch {
Write-Warning ("{0:u} cycle failed: {1}" -f (Get-Date), $_.Exception.Message)
if ($_.Exception.Message -match 'session|not authenticated|NotAuthenticated') {
Disconnect-VIServer -Server * -Force -Confirm:$false -ErrorAction SilentlyContinue
}
}
if ($Once) { break }
$sleep = $IntervalSec - ((Get-Date) - $started).TotalSeconds
if ($sleep -gt 0) { Start-Sleep -Seconds ([int]$sleep) }
} while ($true)
A systemd unit for it, on the collector VM:
# /etc/systemd/system/nfs-latency-bridge.service
[Unit]
Description=NFS datastore latency bridge (PowerCLI -> OTLP)
After=network-online.target otelcol-contrib.service
Wants=network-online.target
[Service]
Type=simple
User=nfsbridge
EnvironmentFile=/etc/nfs-latency/bridge.env
ExecStart=/usr/bin/pwsh -NoProfile -NonInteractive -File /opt/nfs-latency/nfs-latency-bridge.ps1
Restart=always
RestartSec=30
MemoryMax=1G
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
# /etc/nfs-latency/bridge.env (chmod 600, owner nfsbridge)
VCENTER_SERVER=<VCENTER_FQDN>
VCENTER_USER=<SVC_ACCOUNT>@vsphere.local
VCENTER_PASSWORD=<SET_FROM_YOUR_SECRET_STORE>
OTLP_METRICS_URL=http://127.0.0.1:4318/v1/metrics
The cross-check script is what you run when someone doubts the dashboard. It goes straight to vCenter, bypassing the collector, Prometheus and every query in this post, and prints the same numbers for one datastore: per host latency and IOPS over the last five minutes with outliers flagged, then the worst virtual disks on that datastore.
#Requires -Version 7.2
# Compare-NfsLatency.ps1 - independent check of what the dashboards claim, for one datastore.
param(
[Parameter(Mandatory)][string]$Datastore,
[int]$Samples = 15, # 15 x 20 s = last 5 minutes of real-time data
[double]$OutlierFactor = 2.0,
[double]$MinMs = 5.0
)
$ErrorActionPreference = 'Stop'
if (-not ($global:DefaultVIServer -and $global:DefaultVIServer.IsConnected)) {
$cred = [pscredential]::new($env:VCENTER_USER, (ConvertTo-SecureString $env:VCENTER_PASSWORD -AsPlainText -Force))
Connect-VIServer -Server $env:VCENTER_SERVER -Credential $cred | Out-Null
}
$ds = Get-Datastore -Name $Datastore
$uuid = $ds.ExtensionData.Info.Url.TrimEnd('/').Split('/')[-1]
$hosts = Get-VMHost -Datastore $ds | Where-Object { $_.ConnectionState -in 'Connected', 'Maintenance' }
$stat = 'datastore.totalReadLatency.average', 'datastore.totalWriteLatency.average',
'datastore.numberReadAveraged.average', 'datastore.numberWriteAveraged.average'
$raw = Get-Stat -Entity $hosts -Stat $stat -Realtime -MaxSamples $Samples | Where-Object Instance -eq $uuid
function Avg($rows, $id) { [math]::Round((($rows | Where-Object MetricId -eq $id | Measure-Object Value -Average).Average), 2) }
$rows = foreach ($g in ($raw | Group-Object { $_.Entity.Name })) {
[pscustomobject]@{
Host = $g.Name
ReadMs = Avg $g.Group 'datastore.totalReadLatency.average'
WriteMs = Avg $g.Group 'datastore.totalWriteLatency.average'
ReadIops = Avg $g.Group 'datastore.numberReadAveraged.average'
WriteIops = Avg $g.Group 'datastore.numberWriteAveraged.average'
}
}
$sorted = @($rows.WriteMs | Sort-Object)
$median = if ($sorted.Count) { $sorted[[int][math]::Floor(($sorted.Count - 1) / 2)] } else { 0 }
"Datastore {0} ({1}), uuid {2}, median host write latency {3} ms over last {4} s" -f $ds.Name, $ds.Type, $uuid, $median, ($Samples * 20)
$rows | Select-Object *, @{ n = 'Flag'; e = { if ($median -gt 0 -and $_.WriteMs -ge $OutlierFactor * $median -and $_.WriteMs -ge $MinMs) { 'OUTLIER' } else { '' } } } |
Sort-Object WriteMs -Descending | Format-Table -AutoSize
# Worst virtual disks that live on this datastore
$vms = Get-VM -Datastore $ds | Where-Object PowerState -eq 'PoweredOn'
$onDs = @{}
foreach ($vm in $vms) {
$devs = $vm.ExtensionData.Config.Hardware.Device
foreach ($d in ($devs | Where-Object { $_ -is [VMware.Vim.VirtualDisk] -and $_.Backing.FileName -like "[$($ds.Name)]*" })) {
$c = $devs | Where-Object Key -eq $d.ControllerKey
$p = switch -Wildcard ($c.GetType().Name) { '*SCSI*' { 'scsi' } '*LsiLogic*' { 'scsi' } '*BusLogic*' { 'scsi' } '*NVME*' { 'nvme' } '*AHCI*' { 'sata' } '*IDE*' { 'ide' } }
$onDs['{0}|{1}{2}:{3}' -f $vm.Name, $p, $c.BusNumber, $d.UnitNumber] = $true
}
}
if ($vms) {
Get-Stat -Entity $vms -Stat 'virtualDisk.totalReadLatency.average', 'virtualDisk.totalWriteLatency.average' -Realtime -MaxSamples $Samples |
Where-Object { $onDs.ContainsKey('{0}|{1}' -f $_.Entity.Name, $_.Instance) } |
Group-Object { $_.Entity.Name }, Instance, MetricId |
ForEach-Object { [pscustomobject]@{ VM = $_.Group[0].Entity.Name; Disk = $_.Group[0].Instance
Counter = ($_.Group[0].MetricId -replace 'virtualDisk\.total|\.average', '')
AvgMs = [math]::Round(($_.Group | Measure-Object Value -Average).Average, 2) } } |
Sort-Object AvgMs -Descending | Select-Object -First 15 | Format-Table -AutoSize
}
09. Template: PromQL set
All queries assume the names produced by the configuration above. Two habits keep them honest: weight latency by IOPS when you aggregate across hosts (an idle host at 40 ms should not dominate a busy host at 2 ms), and remember that every “percentile” here is a percentile of 20 second averages.
# 1. IOPS-weighted write latency per NFS datastore, across all hosts that mount it (ms)
sum by (vcenter_datastore_name) (
avg_over_time(vsphere_host_datastore_latency_milliseconds{direction="write"}[5m])
* on (vcenter_host_name, vcenter_datastore_name, direction)
avg_over_time(vsphere_host_datastore_operations_per_second{direction="write"}[5m])
)
/
sum by (vcenter_datastore_name) (
avg_over_time(vsphere_host_datastore_operations_per_second{direction="write"}[5m])
)
# 2. p95 over the last hour of the worst host per datastore (p95 of 20 s averages)
max by (vcenter_datastore_name, direction) (
quantile_over_time(0.95, vsphere_host_datastore_latency_milliseconds[1h])
)
# 3. "One host differs from the rest": each host's latency divided by the median
# of all hosts on the same datastore. Only datastores with 3+ hosts, only above 5 ms.
(
avg_over_time(vsphere_host_datastore_latency_milliseconds[15m])
/ on (vcenter_datastore_name, direction) group_left
quantile by (vcenter_datastore_name, direction) (0.5,
avg_over_time(vsphere_host_datastore_latency_milliseconds[15m]))
)
and on (vcenter_host_name, vcenter_datastore_name, direction)
(avg_over_time(vsphere_host_datastore_latency_milliseconds[15m]) > 5)
and on (vcenter_datastore_name, direction)
(count by (vcenter_datastore_name, direction) (vsphere_host_datastore_latency_milliseconds) >= 3)
# 4. Per-VMDK latency from the receiver, with the datastore attached via the info metric
avg_over_time(vcenter_vm_disk_latency_avg_milliseconds[10m])
* on (vcenter_vm_id, object) group_left (vcenter_datastore_name, vsphere_datastore_type)
vsphere_vm_disk_info
# 5. p95 across all VMDKs on each NFS datastore ("the 95th percentile disk")
quantile by (vcenter_datastore_name, direction) (0.95,
avg_over_time(vcenter_vm_disk_latency_avg_milliseconds[10m])
* on (vcenter_vm_id, object) group_left (vcenter_datastore_name, vsphere_datastore_type)
vsphere_vm_disk_info{vsphere_datastore_type=~"NFS.*"}
)
# 6. Time spent above the NFS client (A - B in Figure 1), per host and datastore.
# Indicative only: different sampling, and VM side is per-VMDK, not IOPS-weighted.
avg by (vcenter_host_name, vcenter_datastore_name, direction) (
avg_over_time(vcenter_vm_disk_latency_avg_milliseconds[10m])
* on (vcenter_vm_id, object) group_left (vcenter_datastore_name)
vsphere_vm_disk_info{vsphere_datastore_type=~"NFS.*"}
)
- on (vcenter_host_name, vcenter_datastore_name, direction)
avg_over_time(vsphere_host_datastore_latency_milliseconds[10m])
# 7. Network plus client queueing (B - C): host view minus the array's own view.
# Replace <ARRAY_LATENCY_METRIC> and its label with what your exporter exposes,
# and convert units first if the array reports microseconds.
max by (vcenter_datastore_name) (
avg_over_time(vsphere_host_datastore_latency_milliseconds{direction="write"}[10m])
)
- on (vcenter_datastore_name)
label_replace(avg_over_time(<ARRAY_LATENCY_METRIC>[10m]),
"vcenter_datastore_name", "$1", "<ARRAY_EXPORT_LABEL>", "(.*)")
# 8. Is the bridge alive? (returns 1 when no host datastore data in the last 5 minutes)
absent_over_time(vsphere_host_datastore_latency_milliseconds[5m])
Query 3 is the one that earns its keep. Array side problems move every host together, so the ratio stays near 1 and query 1 catches them instead. A single host with a bad uplink, a misnegotiated port, a different MTU, or an NFSv4.1 session that lost a path stands out immediately as a ratio of 2, 3 or 10, even when its absolute latency is still under any static threshold.
Query 6 deserves caution. It mixes the receiver’s one sample per minute with the bridge’s full 20 second resolution and compares per VMDK averages with an IOPS-weighted host figure. Use it to spot a persistent gap (SIOC throttling, a VM with a tiny queue depth, a snapshot chain) rather than to read precise milliseconds.
10. Template: Grafana alert rules
File provisioned rules, for provisioning/alerting/nfs-latency.yaml. Replace <PROMETHEUS_DS_UID> with your Prometheus data source UID. Each rule uses an instant PromQL query as A and a server side threshold expression as C, which is the shape Grafana exports.
apiVersion: 1
groups:
- orgId: 1
name: nfs-datastore-latency
folder: vSphere Storage
interval: 1m
rules:
- uid: nfs-ds-write-latency-high
title: NFS datastore write latency high
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: <PROMETHEUS_DS_UID>
model:
refId: A
instant: true
range: false
expr: |
sum by (vcenter_datastore_name) (
avg_over_time(vsphere_host_datastore_latency_milliseconds{direction="write"}[10m])
* on (vcenter_host_name, vcenter_datastore_name, direction)
avg_over_time(vsphere_host_datastore_operations_per_second{direction="write"}[10m])
)
/
sum by (vcenter_datastore_name) (
avg_over_time(vsphere_host_datastore_operations_per_second{direction="write"}[10m])
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [10] }
for: 10m
noDataState: OK
execErrState: Error
labels: { severity: warning, domain: storage }
annotations:
summary: 'NFS datastore {{ $labels.vcenter_datastore_name }} write latency {{ humanize $values.A.Value }} ms'
description: 'IOPS-weighted across all hosts for 10 minutes. Every host affected usually means the array or a shared network segment; check the array dashboard and query 7.'
- uid: nfs-host-outlier
title: One host slower than its peers on an NFS datastore
condition: C
data:
- refId: A
relativeTimeRange: { from: 1800, to: 0 }
datasourceUid: <PROMETHEUS_DS_UID>
model:
refId: A
instant: true
range: false
expr: |
(
avg_over_time(vsphere_host_datastore_latency_milliseconds[15m])
/ on (vcenter_datastore_name, direction) group_left
quantile by (vcenter_datastore_name, direction) (0.5,
avg_over_time(vsphere_host_datastore_latency_milliseconds[15m]))
)
and on (vcenter_host_name, vcenter_datastore_name, direction)
(avg_over_time(vsphere_host_datastore_latency_milliseconds[15m]) > 5)
and on (vcenter_datastore_name, direction)
(count by (vcenter_datastore_name, direction) (vsphere_host_datastore_latency_milliseconds) >= 3)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [2] }
for: 15m
noDataState: OK
execErrState: Error
labels: { severity: warning, domain: storage }
annotations:
summary: '{{ $labels.vcenter_host_name }} is {{ humanize $values.A.Value }}x the median {{ $labels.direction }} latency on {{ $labels.vcenter_datastore_name }}'
description: 'Peers on the same export are fine, so suspect this host path: vmknic, uplink, switch port, MTU, NFS 4.1 session. Run the section 5.3 commands on the host.'
- uid: nfs-vmdk-p95-high
title: 95th percentile VMDK latency high on an NFS datastore
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: <PROMETHEUS_DS_UID>
model:
refId: A
instant: true
range: false
expr: |
quantile by (vcenter_datastore_name, direction) (0.95,
avg_over_time(vcenter_vm_disk_latency_avg_milliseconds[10m])
* on (vcenter_vm_id, object) group_left (vcenter_datastore_name, vsphere_datastore_type)
vsphere_vm_disk_info{vsphere_datastore_type=~"NFS.*"}
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [20] }
for: 15m
noDataState: OK
execErrState: Error
labels: { severity: warning, domain: storage }
annotations:
summary: 'p95 VMDK {{ $labels.direction }} latency on {{ $labels.vcenter_datastore_name }} is {{ humanize $values.A.Value }} ms'
- uid: nfs-bridge-stale
title: NFS latency bridge has stopped reporting
condition: C
data:
- refId: A
relativeTimeRange: { from: 600, to: 0 }
datasourceUid: <PROMETHEUS_DS_UID>
model:
refId: A
instant: true
range: false
expr: absent_over_time(vsphere_host_datastore_latency_milliseconds[5m])
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [0] }
for: 5m
noDataState: OK
execErrState: Error
labels: { severity: critical, domain: observability }
annotations:
summary: 'No per-datastore NFS latency for 5 minutes. Every rule above is blind until this is fixed.'
The thresholds are starting points, not recommendations for your workload. Broadcom’s own guidance treats sustained latency above roughly 10 ms as worth investigating, and the ESXi NFS client warns at 10 ms by default, which is why the first rule uses it. Tune the VMDK p95 threshold to the workloads on each datastore tier; a backup target and a database tier should not share one number.
11. End-to-end workflow
From an empty Linux VM (any current RHEL, Rocky, Ubuntu or Debian) to alerts firing. Each step ends with a check and what you should see.
- Create a read only service account in vCenter, propagated from the vCenter root. Check:
pwsh -c 'Connect-VIServer <VCENTER_FQDN> -User <SVC_ACCOUNT>@vsphere.local; (Get-Datastore | ? Type -like "NFS*").Count'prints the number of NFS datastores, not an error. - Install otelcol-contrib v0.166.0 or later from the official release packages. Check:
otelcol-contrib --versionprints the version;otelcol-contrib components | grep -E 'vcenter|http_check|file_storage'lists all three. - Add the secrets to
/etc/otelcol-contrib/otelcol-contrib.conf, the package’s environment file:VCENTER_USER=...andVCENTER_PASSWORD=..., thenchmod 600. Check:sudo systemctl show otelcol-contrib -p EnvironmentFileslists that file. - Drop in the collector config from section 07 and validate it. Check:
otelcol-contrib validate --config=/etc/otelcol-contrib/config.yamlreturns silently with exit code 0; thensudo systemctl restart otelcol-contrib && curl -s localhost:13133returns a JSON status of server available. - Enable the OTLP receiver in Prometheus with
--web.enable-otlp-receiverand theotlpandstorage.tsdbblocks from section 07. Check:curl -s http://<PROMETHEUS_HOST>:9090/api/v1/status/flags | grep -o '"web.enable-otlp-receiver":"true"'prints the flag. - Confirm receiver metrics arrive and learn their exact names. Check:
curl -s http://<PROMETHEUS_HOST>:9090/api/v1/label/__name__/values | tr ',' '\n' | grep vcenter_vm_diskshowsvcenter_vm_disk_latency_avg_millisecondswithin two collection intervals. If the name differs, adjust the queries before going further. - Run the bridge once.
sudo -u nfsbridge pwsh -File /opt/nfs-latency/nfs-latency-bridge.ps1 -Once. Check: it prints an inventory line with a non zero NFS datastore count andsent N host resources; Prometheus then returns series forvsphere_host_datastore_latency_millisecondsandvsphere_vm_disk_info. - Enable the bridge service:
sudo systemctl enable --now nfs-latency-bridge. Check:journalctl -u nfs-latency-bridge -n 5shows asentline per minute and no warnings. - Cross-check one datastore. Run
Compare-NfsLatency.ps1 -Datastore <NFS_DATASTORE>and, for the same five minutes, PromQL query 1. Check: the IOPS-weighted figure and the per host table agree within rounding; the worst VMDKs listed match query 4. - Provision the alert rules and restart Grafana. Check: Alerting, Alert rules shows the four rules in folder vSphere Storage in state Normal; temporarily lower the outlier rule threshold to 1.1 and confirm it goes Pending on at least one host, then restore it.
12. Troubleshooting
| Symptom | Likely cause | Check | Fix |
|---|---|---|---|
vcenter_host_disk_latency_avg is flat and low while VMs are slow | Expected on NFS: it measures SCSI devices such as the boot disk | object label values are device names, no NFS datastores | Use the bridge metrics for per host NFS latency; optionally disable the metric on NFS only clusters |
No vcenter_vm_disk_latency_avg series | Statistics level too low, or VMs powered off | vCenter, Configure, Statistics; check VM power state | Raise the level for the affected interval per the receiver docs; powered off VMs have no real time data |
| Bridge prints 0 NFS datastores | Datastore type is not NFS or NFS41 in PowerCLI, or the account cannot see them | Get-Datastore | Select Name,Type as the service account | Fix permissions or adjust the type filter |
| Bridge sends data but Prometheus has none | OTLP receiver not enabled, or resource attributes not promoted, so series collapse or lack labels | Collector debug log; /api/v1/status/flags | Enable --web.enable-otlp-receiver and the promote_resource_attributes list |
| Prometheus logs out of order or out of bounds samples after an outage | Persistent queue replaying data older than the OOO window | prometheus_tsdb_out_of_order_samples_total | Raise out_of_order_time_window to cover your longest expected outage |
| Query 4 returns nothing | Join labels do not match: VM id or object format differs | Compare vcenter_vm_id and object values on both metrics | Check controller type mapping in Get-VDiskMap; NVMe and SATA disks use different prefixes |
| Outlier alert on one host only after a vMotion storm | Short lived queueing on the NFS client during migrations | Correlate with vMotion events and the host’s vmknic throughput | Raise for to 20m or exclude hosts in maintenance |
| Host latency high, array latency low, every host affected | Network between hosts and array: shared switch, uplink saturation, MTU | Query 7; vmkping -d -s 8972; switch port counters | Fix the network path; on NFSv3 review teaming policy and port binding |
vmkernel.log shows performance has deteriorated but dashboards are calm | Spike shorter than the dashboard window, or the receiver sampling missed it | Bridge data at 20 s resolution for that minute | Alert on the log lines as well (post 10) |
Performance charts in the vSphere Client show counter.disk.read.label | Known vCenter 9.x localisation issue after the storage counter groups were consolidated | Broadcom KB 450943 | Cosmetic in the UI; counter keys used by the API are what this post queries |
13. What’s next
You now have three latency numbers on one time axis, the VMDK view from the receiver, the host and datastore view from the bridge, and the array’s own view, plus alerts that tell an array problem from a single host path problem. The next step is to catch the failures that happen faster than any metric scrape: Catching NFS APD before vCenter does, with OTel logs builds on the vmkernel.log latency lines shown here, using the syslog pipeline from Part 3. If you want to follow one slow request all the way down to these datastore panels, read Part 6: trace to datastore. Before you roll this out across a large estate, Sizing the OTel Collector for vSphere works out what the extra series and the bridge cost. Receiver basics are in Part 2, the backend wiring in Part 4, and the NFS protocol background in NFSv3 and NFSv4.1 in VMware vSphere.
Checked against otelcol-contrib v0.166.0 (vcenter receiver alpha, metrics at development stability), the Collector’s exporterhelper documentation as of December 2026, Prometheus 3.x OTLP ingestion, and VCF PowerCLI 9. Metric names in Prometheus depend on the translation strategy; confirm them in your environment before copying the queries verbatim. Validate collection load against your own vCenter before pointing this at production.
Leave a Reply