A vSphere administrator may need to collect metrics over an extended time period that are only available when increasing the statistic levels to 3 or 4. Running vCenter at statistic levels 3 or 4 for an extended time is highly discouraged by VMware due to the potential performance impact on the vpxd service. An alternative must be used to collect the required metrics over an extended period that will not cause potential interruption to vCenter. This KB provides an alternative way of persisting the real-time metrics without increasing statistic levels.
Broadcom Techdoc - Statistic Levels
When the statistics levels, level 3 or level 4 are used beyond the default value, it may cause one particular process, vpxd, to sustain memory growth, if it cannot save the statistics information to the database as quickly as required. If the usage limit of these statistics levels is not monitored closely, it may cause vpxd to grow out of memory and eventually crash.
Level 1
- Cluster Services (VMware Distributed Resource Scheduler) – all metrics
- CPU – cpuentitlement, totalmhz, usage (average), usagemhz
- Disk – capacity, maxTotalLatency, provisioned, unshared, usage (average), used
- Memory – consumed, mementitlement, overhead, swapinRate, swapoutRate, swapused, totalmb, usage (average), vmmemctl (balloon), totalbandwidth (DRAM or PMem)
- Network – usage (average), IPv6
- System – heartbeat, uptime
- Virtual Machine Operations – numChangeDS, numChangeHost, numChangeHostDS
Use for long-term performance monitoring when device statistics are not required.
Level 1 is the default Collection Level for all Collection Intervals.
Level 2
- Includes all level 1 metrics
- CPU – idle, reservedCapacity
- Disk – All metrics, excluding numberRead and numberWrite.
- Memory – All metrics, excluding memUsed, maximum and minimum rollup values, read or write latency (DRAM or PMem).
- Virtual Machine Operations – All metrics
Use for long-term performance monitoring when device statistics are not required but you want to monitor more than the basic statistics.
Level 3
- Includes all level 1 and level 2 metrics
- Metrics for all counters, excluding minimum and maximum rollup values.
- Device metrics
Use for short-term performance monitoring after encountering problems or when device statistics are required.
Level 4
- All metrics supported by the vCenter Server, including minimum and maximum rollup values.
Use for short-term performance monitoring after encountering problems or when device statistics are required.
vCenter Server
Esxi
Requirement to persist vSphere metrics over an extended period of time without increasing statistic levels.
NOTE: Given the amount of data that can be generated when collecting metrics, it can prove challenging when attempting to parse a csv file for pertinent information. SQLite can be used as a persistent database. The use of SQLite in this KB is provided as an "as is" guide to assist customers and is in no way supported by VMware.
NOTE: The csv file will be overwritten on each iteration of the script, but the SQLite database will be persistent and depending on how often the script runs and how many entities it queries and how many metrics are collected this file can grow exponentially. The size on this file on disk should be monitored closely.
To list all collected metrics:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS"
To list all collected metrics for a given day:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS where TIMESTAMP like '3/9/2025%'"
To list all collected for a given day and hour:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS where TIMESTAMP like '3/9/2025 9:%PM'"
To list all metrics for a specific VM and a given day/hour:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS where VM_NAME='TEST-VM' and TIMESTAMP like '3/9/2025 9:%PM'"
To list a specific metric for a VM with a given day/hour:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS where VM_NAME='TEST-VM' and METRIC_ID='disk.numberread.summation' and TIMESTAMP like '3/9/2025 9:%PM'"
To list a specific metric for a VM with a given day/hour and a value greater than 1000:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "select * from STATS where VM_NAME='TEST-VM' and METRIC_ID='disk.numberread.summation' and VALUE>='1000' and TIMESTAMP like '3/9/2025 9:%PM'"
To delete all data in the database:
C:\sqlite\sqlite3.exe -table C:\vSphere_Metrics\stats.db "delete from STATS"