panhvr
Contributor
Contributor

This operation is restricted by the administrator Error when running get-stats command

Jump to solution

I have a script which use to gather performance report for monthly -but after the upgrade of VC The script fails with below error

Get-Stat        This operation is restricted by the administrator - 'vpxd.stats.maxQueryMetrics'. Contact your system administrator.

I tried following the KB -https://kb.vmware.com/kb/2107096‌  but I dont see performances service webclient

Please advise

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Since you're using the API, and not the Web Client, you will only need to change the value in the vCenter Advanced Settings.

That can be done with

Note that the -1 value disables the limit altogether.

The default value is 64.

Get-AdvancedSetting -Entity YourvCenter -Name config.vpxd.stats.MaxQueryMetrics |

Set-AdvancedSetting -Value -1


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership

Since you're using the API, and not the Web Client, you will only need to change the value in the vCenter Advanced Settings.

That can be done with

Note that the -1 value disables the limit altogether.

The default value is 64.

Get-AdvancedSetting -Entity YourvCenter -Name config.vpxd.stats.MaxQueryMetrics |

Set-AdvancedSetting -Value -1


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

View solution in original post

0 Kudos
panhvr
Contributor
Contributor

Thanks Luc D

Does this setting impacts loading of inventory and performance chart in the VC ?

Regards

0 Kudos
LucD
Leadership
Leadership

No afaik, for the Web Client charts you have to update the XML file.


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

0 Kudos
panhvr
Contributor
Contributor

Hello LucD

I modified the value to  metric reported in vpxd logs of the VC when it failed

Like

Get-AdvancedSetting -Entity VCNAME -Name config.vpxd.stats.MaxQueryMetrics | Set-AdvancedSetting -Value 200

Which run successfully on all the VC now .But unfortunately when I run get-stat command it dosnt show any result.

Below is the part of script from which I used to gather stats for cluster monthly . 

$clusters = Get-Cluster

foreach($cluster in $clusters)

{

Get-Cluster -Name $cluster | Get-Stat -start (get-date).AddDays(-40) -Finish (Get-Date).AddDays(-10) -MaxSamples 10000 -stat cpu.usage.average | Measure-Object -Property value -Average -Maximum -Minimum | select Average 

Get-Cluster -Name $cluster | Get-Stat -start (get-date).AddDays(-40) -Finish (Get-Date).AddDays(-10) -MaxSamples 10000 -stat mem.usage.average | Measure-Object -Property value -Average -Maximum -Minimum | select Average

}

Did the upgrade of environment from 5.5 to 6 taken out all my old data ?

0 Kudos
ephillips3
Contributor
Contributor

I am having a similar problem,  After a Vcenter 6 upgrade i get the

Get-Stat : 12/19/2016 9:18:22 AMGet-Stat   This operation is

restricted by the administrator - 'vpxd.stats.maxQueryMetrics'. Contact your

system administrator.

I have followed the KB and LucD fix for the PowerCLI.  After these i Can get Stats on smaller clusters of say 34- host but not the larger one over 5 or 6 host.  I have reached out to Vmware Support and they pointed me back to this thread.  so what is the difference when running the following code on cluster or number of objects that would return the error.

Code snippet something like this.

foreach($cluster in $clusters){

  $statcpu = Get-Stat -Entity ($cluster)-start $starttime -Finish $finishtime -MaxSamples 10000 -stat cpu.usage.average

  $statmem = Get-Stat -Entity ($cluster)-start $starttime -Finish $finishtime -MaxSamples 10000 -stat mem.usage.average

  $cpu = $statcpu | Measure-Object -Property value -Average -Maximum -Minimum

  $mem = $statmem | Measure-Object -Property value -Average -Maximum -Minimum

}

Cluster with 10 hosts & 186 VM I get the error

Cluster with 4 host & 39 vm I get data and no error

Ernie

0 Kudos
LucD
Leadership
Leadership

Did you already check the vpxd log for error messages around the time you ran the failing Get-Stat?

Perhaps these could help.


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

0 Kudos
ephillips3
Contributor
Contributor

I see this in the vpxd.log and will update vmware support

016-12-19T09:48:51.000-05:00 error vpxd[7FF08366C700] [Originator@6876 sub=MoPerfManager opID=795e4f41] The query size of 186 metrics exceeded the vpxd.stats.maxQueryMetrics limit of 64 metrics. Dropping.

The settings from the KB and the setting of the parameter for MaxQuerMetrics in Powercli have been set and the error still shows.

PowerCLI C:\> Get-AdvancedSetting -Entity Vcenter -Name config.vpxd.s

tats.MaxQueryMetrics | Set-AdvancedSetting -Value -1

Name                 Value                Type                 Description

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

config.vpxd.stats... -1                   VIServer

0 Kudos
LucD
Leadership
Leadership

These adavnced settings are case sensitive, did you specify config.vpxd.stats.maxQueryMetrics or config.vpxd.stats.MaxQueryMetrics?

Do a Get-AdvancedSetting, or check via the Web Client, to see if you might have the two present.


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

0 Kudos
ephillips3
Contributor
Contributor

Checking I see config.vpxd.stats.MaxQueryMetric with upper case and only see the one in the Advanced Settings

PowerCLI C:\> Get-AdvancedSetting -Entity vcenter | fl

Uid         : /VIServer=domain\ephillips3@vcenter:443/AdvancedS

              etting=VIServerSetting-config.vpxd.stats.MaxQueryMetrics/

Value       : -1

Description :

Type        : VIServer

Entity      : vcenter

Id          : VIServerSetting-config.vpxd.stats.MaxQueryMetrics

Name        : config.vpxd.stats.MaxQueryMetrics

Client      : VMware.VimAutomation.ViCore.Impl.V1.VimClient

pastedImage_2.png

The KB indicates a lowercase m for config.vpxd.stats.maxQueryMetrics but when i run with lower case this sets the upper case object .

PowerCLI C:\> Get-AdvancedSetting -Entity vcenter -Name config.vpxd.s

tats.maxQueryMetrics | Set-AdvancedSetting -Value -1

Perform operation?

Modifying advanced setting 'config.vpxd.stats.MaxQueryMetrics'.

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help

(default is "Y"):y

Name                 Value                Type                 Description

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

config.vpxd.stats... -1                   VIServer

and this does not create e new key with a lowercase value. I created the key via the web Client for config.vpxd.stats.maxQueryMetrics lower case and this resolved the issue.  The command further up in the thread indicates the uppercase and setting via powercli does not appear to set the proper Key. 

Thank you for you help LucD.

0 Kudos