Microsoft says that DMV (ring buffers) doesn't work on SQL Server 2017, only 2019:
Sys.dm_os_ring_buffers DMV has been a key DMV used for monitoring SQL
Server by built-in tools as well as third party monitoring utilities.
When SQL Server 2017 was released on Linux, unfortunately this DMV did
not return correct CPU usage information by SQL Server ...
If you are open to using Powershell...
Assume the following table definition:
DROP TABLE IF EXISTS BillingData;
CREATE TABLE BillingData
(BillingId int, Feature varchar(13), Usage int, Measurement varchar(9), Cost int)
INSERT INTO BillingData
(BillingId, Feature, Usage, Measurement, Cost)
(1, 'Walks', 25, 'walks', 200....
So the features here I do not want in a CSV are quite obvious. The ---
lines and the output data at the bottom.
To remove the output at the bottom, omit the -p parameter.
sqlcmd -S databaseserver -U "sa" -d database -p -W -Q "set nocount on; SELECT x as data, count(*) as datacount FROM location WHERE x IS NOT NULL GROUP BY x" -s "," -o output.csv -r0