Skip to content

SQL Server - sqlAzureMIResourceStats missing sorting #8285

@Trovalo

Description

@Trovalo

System info:

Latest nightly build

Steps to reproduce:

Capture the data from SQL Azure Managed Instance using the query "sqlAzureMIResourceStats".

This is the text of the query:

IF SERVERPROPERTY('EngineEdition') <> 8 BEGIN /*not Azure Managed Instance*/
	DECLARE @ErrorMessage AS nvarchar(500) = 'Telegraf - Connection string Server:'+ @@SERVERNAME + ',Database:' + DB_NAME() +' is not an Azure Managed Instance. Check the database_type parameter in the telegraf configuration.';
	RAISERROR (@ErrorMessage,11,1)
	RETURN
END
SELECT TOP(1)
	 'sqlserver_azure_db_resource_stats' AS [measurement]
	,REPLACE(@@SERVERNAME,'\',':') AS [sql_instance]
	,cast([avg_cpu_percent] as float) as [avg_cpu_percent]
FROM
    sys.server_resource_stats;

The avg_cpu_percent has a constant (or almost constant value) due to the missing sorting in the query.
The fetched value is not the latest one, but the oldest in the table, in theory, the table keeps the last 1h of data, but in any case we are losing or shifting the data as of now.

the sorting must be added at the end.

ORDER BY
	[end_time] DESC;

@denzilribeiro can you confirm?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions