Modify Historical Statistics Level using PowerCli

I was recently approached by one of my performance engineers about increasing the historical statistic level for our environment. Adjusting this level increases or decreases the amount of vCenter performance counters that are saved over time for each of the performance intervals. We were asked to increase our level in order to expose additional metrics to their monitoring application. While this change is pretty straight forward using the vSphere client, organizations that need to make this change across a large number of vCenter instances may find scripting this change useful.

Interval vs. Level Dizziness

By default, all four of the statistics intervals (5 minutes, 30 minutes, 2 hours, 1 day) are set to statistics level 1. Also, note that due to the fact that the intervals get rolled up, you cannot set a longer interval to a statistics level greater than the previous one. For example, if the 5 minute interval is set to level 2, you cannot set the 30 minute interval to level 3.

Modifying the Historical Statistics Settings using the vSphere Client

  1. Select “Administrator->vCenter Server Settings”, and then select “Statistics”
  2. Select each of the Statistics Intervals and select “Edit”.image
  3. Select the appropriate statistics level. In the following example, the 5 minute statistical interval is being increased to level 2.


Ok, that is well and good, but remember, a good admin is a lazy admin. We rarely like to repeat anything more than once. You can use the following PowersCli script to programmatically make this change.

Known issue: If you recall, I mentioned the statistics LEVEL (1-4) could not be higher than the previous statistics INTERVAL. This exposes a slight issue with the script. If you attempt to run the script against an instance that is not currently set to the default LEVEL of 1, the script will fail. Or more specifically, if you attempt to set the value to something lower than the current setting, the script will fail because it attempts to set the first interval (5 minutes) to a lower value than is set at the next interval (30 minutes), and so on. This violates the rule.

Band-aid Solution: If you first run this script in reverse order (from 1 day to 5 minutes) setting the level to the default (level 1). Then you can re-run the script to set the appropriate level.

Hopefully that is clear. If not, I am happy to entertain questions.



Leave a Reply

Your email address will not be published. Required fields are marked *