VMware Cloud Community
snandy
Contributor
Contributor

Not able find datastore.totalReadLatency.average using Get-StatType

Hi All

I am using powershell to get the latency.

Below is the powershell code for reference 

 

$vmName = ""

$stat = "datastore.totalReadLatency.average","datastore.totalWriteLatency.average"
$entity = Get-VM -Name $vmName | select -Unique
$start = (Get-Date).AddHours(-1)

$dsTab = @{}
$dsTab = Get-Datastore | Where {$_.Type -eq "VMFS"} | %{
  $key = $_.ExtensionData.Info.Vmfs.Uuid
  if(!$dsTab.ContainsKey($key)){
    $dsTab.Add($key,$_.Name)
  }
  else{
    "Datastore $($_.Name) with UUID $key already in hash table"
  }
}

Get-Stat -Entity $entity -Stat $stat -Start $start |
Group-Object -Property {$_.Entity.Name} | %{
  $vmName = $_.Values[0]
  $VMReadLatency = $_.Group |
    where {$_.MetricId -eq "datastore.totalReadLatency.average"} |
    Measure-Object -Property Value -Average |
    Select -ExpandProperty Average
  $VMWriteLatency = $_.Group |
    where {$_.MetricId -eq "datastore.totalWriteLatency.average"} |
    Measure-Object -Property Value -Average |
    Select -ExpandProperty Average
  $VMReadIOPSAverage = $_.Group |
    where {$_.MetricId -eq "datastore.numberReadAveraged.average"} |
    Measure-Object -Property Value -Average |
    Select -ExpandProperty Average
  $VMWriteIOPSAverage = $_.Group |
    where {$_.MetricId -eq "datastore.numberWriteAveraged.average"} |
    Measure-Object -Property Value -Average |
    Select -ExpandProperty Average
  $_.Group | Group-Object -Property Instance | %{
    New-Object PSObject -Property @{
      VM = $vmName
      Host = $_.Group[0].Entity.Host.Name
      Datastore = $dsTab[$($_.Values[0])]
      Start = $start
      DSReadLatencyAvg = [math]::Round(($_.Group | 
          where {$_.MetricId -eq "datastore.totalReadLatency.average"} |
          Measure-Object -Property Value -Average |
          Select -ExpandProperty Average),2)
      DSWriteLatencyAvg = [math]::Round(($_.Group | 
          where {$_.MetricId -eq "datastore.totalWriteLatency.average"} |
          Measure-Object -Property Value -Average |
          Select -ExpandProperty Average),2)
      VMReadLatencyAvg = [math]::Round($VMReadLatency,2)
      VMWriteLatencyAvg = [math]::Round($VMWriteLatency,2)
      VMReadIOPSAvg = [math]::Round($VMReadIOPSAverage,2)
      VMWriteIOPSAvg = [math]::Round($VMWriteIOPSAverage,2)
    }
  }
} | Export-Csv c:\report.csv -NoTypeInformation -UseCulture

When I execute this script, for some VM I am able to find the stat "datastore.totalReadLatency.average","datastore.totalWriteLatency.average", but for some VM's I am not able to find the stat "datastore.totalReadLatency.average","datastore.totalWriteLatency.average"

Please let me know what is wrong I am doing or is there anything which needs to be done ( any update/Installation )

Reply
0 Kudos
12 Replies
scott28tt
VMware Employee
VMware Employee

You should expect a moderator to move your thread to the area for PowerCLI.

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership

Do you see values for these metrics under the Performance tab in the Web Client?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
snandy
Contributor
Contributor

I don't have any access to check the webclient. I can provide suggestions if there is any way to bring these stat values

Reply
0 Kudos
snandy
Contributor
Contributor

I am not sure which tag can solve this issue. Is it something to do with Vcenter end or from PowerCli end

Reply
0 Kudos
snandy
Contributor
Contributor

@LucD are you referring to this

snandy_0-1638961167824.png

 

Reply
0 Kudos
LucD
Leadership
Leadership

If your Statistics Level is not set to at least 3 for the Historical Intervals, then these metrics are only available in the Realtime interval


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
snandy
Contributor
Contributor

@LucD it is available

snandy_0-1638971281241.png

 

Reply
0 Kudos
LucD
Leadership
Leadership

So you do have access to the Web Client?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
snandy
Contributor
Contributor

@LucD Yes, I got Read-Only access for now.

Reply
0 Kudos
LucD
Leadership
Leadership

So did you check if you can see values for those metrics?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
snandy
Contributor
Contributor

@LucD In webclient I am able to see but not through PowerCli 

 

snandy_0-1639123878181.png

 

Reply
0 Kudos
LucD
Leadership
Leadership

But do you see any values?
Those metrics are always there in the options


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos