I've seen posts from people saying they see no results returned from sys.dm_os_performance_counters. For me it's a bit different. See below.
Instance 1:
+-------------------------------------+-----------------------+---------------+------------+
| object_name | counter_name | instance_name | cntr_value |
+-------------------------------------+-----------------------+---------------+------------+
| MSSQL$TRAINING:Workload Group Stats | CPU usage % | internal | 0 |
| MSSQL$TRAINING:Workload Group Stats | CPU usage % base | internal | 0 |
| MSSQL$TRAINING:Resource Pool Stats | CPU usage % | internal | 0 |
| MSSQL$TRAINING:Resource Pool Stats | CPU usage % base | internal | 0 |
| MSSQL$TRAINING:Resource Pool Stats | CPU usage target % | internal | 0 |
| MSSQL$TRAINING:Query Store | Query Store CPU usage | _Total | 0 |
+-------------------------------------+-----------------------+---------------+------------+
@@Version: Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) - 15.0.4312.2 (X64) Apr 1 2023 12:10:46 Copyright (C) 2019 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)
Instance 2:
+--------------------------------+-----------------------+---------------+------------+
| object_name | counter_name | instance_name | cntr_value |
+--------------------------------+-----------------------+---------------+------------+
| SQLServer:Workload Group Stats | CPU usage % | default | 1177 |
| SQLServer:Workload Group Stats | CPU usage % base | default | 4044 |
| SQLServer:Workload Group Stats | CPU usage % | internal | 50 |
| SQLServer:Workload Group Stats | CPU usage % base | internal | 4044 |
| SQLServer:Resource Pool Stats | CPU usage % | default | 1177 |
| SQLServer:Resource Pool Stats | CPU usage % base | default | 4044 |
| SQLServer:Resource Pool Stats | CPU usage target % | default | 0 |
| SQLServer:Resource Pool Stats | CPU usage % | internal | 50 |
| SQLServer:Resource Pool Stats | CPU usage % base | internal | 4044 |
| SQLServer:Resource Pool Stats | CPU usage target % | internal | 0 |
| SQLServer:Query Store | Query Store CPU usage | _Total | 0 |
+--------------------------------+-----------------------+---------------+------------+
@@Version: Microsoft SQL Server 2016 (SP3-GDR) (KB5021129) - 13.0.6430.49 (X64) Jan 22 2023 17:38:22 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
How can I change it so instance 1 returns populated values like instance 2?
Query:
SELECT RTRIM(LTRIM(object_name)) AS [object_name], RTRIM(LTRIM(counter_name)) AS counter_name, RTRIM(LTRIM(instance_name)) AS instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name like '%CPU usage%'
error 3409, Reinstall sqlctr.ini for this instance, and ensure that the instance login account has correct registry permissions
. This denotes that performance counters were not enabled."SELECT COUNT(*) FROM sys.dm_os_performance_counters;
. In my case, rows are returned.