Fixing the Stats Primary Election alert on the vSAN ESA Cluster is an article that explains how to fix the error “Stats Primary Election” detected by the vSAN Skyline Health on a vSAN ESA cluster.
Detecting the Issue
When you access the vCenter Server through vSphere Client, you can see an alert like shown in the following figure:
On the “All Issues” page, we can see when this alert was triggered:
Executing the vSAN Skyline Health, we can confirm this behavior. Look that we have 1 unhealthy component:
The unhealthy component name is “Stats primary election”. Click on “Troubleshooting” to get more details:
For instance, the ESXi host “vhost-1008.lab.local” is the CMMDS master for this cluster. However, its “Stats Primary” was not detected and due to this this alert was triggered:
Under this page, there are some technical suggestions to fix this issue. If you executed all these steps and did not fix the issue, we will show a way that we found to fix this issue:
Fixing the Issue
Note: After following the below steps, all the vSAN Performance Data will be deleted. It means that all vSAN Performance charts and related data will be deleted!
Firstly, access the vCenter Server by SSH. After that, access the RVC console and get details of the vSAN Performance Service:
/localhost/DC-LAB.LOCAL/computers/CL-vSAN-ESA> vsan.perf.stats_object_info .
As we can see in the following figure, we can see all the details of the vSAN Performance Service. Grab the vSAN Object UUID and the Owner host for this object (we’ll need both information to fix this issue):
Access the owner host by SSH (in this case, for instance, the owner host for the vSAN Performance Service object is vhost-1008.lab.local) and delete its vSAN object by typing the following command:
*** BE CAREFUL OF USING THIS COMMAND. CONFIRM THE OBJECT’S UUID BEFORE APPLYING THE COMMAND ***
/usr/lib/vmware/osfs/bin/objtool delete -u 68ef0b66-7f34-65a8-c0d6-005056b2c1ad -f
Change the UUID value “68ef0b66-7f34-65a8-c0d6-005056b2c1ad” for your UUID value!
Next, from vCenter Server RVC, disable the vSAN Performance Service (it’s normal to receive a task result error):
/localhost/DC-LAB.LOCAL/computers/CL-vSAN-ESA> vsan.perf.stats_object_delete .
/opt/vmware/rvc/lib/rvc/lib/vsanhealth.rb:108: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
Deleting vSAN Stats DB object, which will stop vSAN Performance Service ...
Task: Disable vSAN performance service
New progress: 1%
Task result: error
Confirm if the vSAN Performance Service was disabled – The following behavior is expected when this service is disabled:
/localhost/DC-LAB.LOCAL/computers/CL-vSAN-ESA> vsan.perf.stats_object_info .
/opt/vmware/rvc/lib/rvc/lib/vsanhealth.rb:108: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
Directory Name: unknown
vSAN Object UUID: (Not found)
SPBM Profile: None
vSAN Policy:
From vCenter Server RVC, enable the vSAN Performance Service:
/localhost/DC-LAB.LOCAL/computers/CL-vSAN-ESA> vsan.perf.stats_object_create .
/opt/vmware/rvc/lib/rvc/lib/vsanhealth.rb:108: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
Creating vSAN Stats DB object, which will enable vSAN Performance Service ...
Task: Enable vSAN performance service
New progress: 1%
Task result: success
Running the vSAN Skyline Health to validate the Cluster’s Health
After fixing the issue, we can run the vSAN Skyline Health just to confirm the cluster’s health:
As we can see, the issue has been fixed successfully 🙂