Error from Service control monitoring about the querying sql queue sizes

Here is the error thrown from the Service control monitoring service and the logs size grow more than 1 GB each day. Recently the metrics is enabled to true () for monitoring the service and after this change this error is thrown continuously.

23:59:58.7927|71|Error|ServiceControl.Transports.SqlServer.QueueLengthProvider|Error querying sql queue sizes.
System.Data.SqlClient.SqlException (0x80131904): The server principal "XXX" is not able to access the database "YYY" under the current security context.

Service control , monitoring services run under network security whereas endpoint queues run under MSA account. I found another post related to service control queueing size error which may be related to this error. https://github.com/Particular/ServiceControl/issues/1846

Nservicebus 7.2.x is used for the endpoints and latest service control version is deployed. Please assist in resolving this error.

This seems like a permission issue. Ensure that the Windows service is configured to use the correct credentials.

Hi Ramon,

Why the error is thrown from monitoring service as it is not able to handle the queue size? what is the root cause of this error? Please assist.

23:59:58.7927|71|Error|ServiceControl.Transports.SqlServer.QueueLengthProvider|Error querying sql queue sizes.

The cause is mentioned on the 2nd line:

System.Data.SqlClient.SqlException (0x80131904): The server principal “XXX” is not able to access the database “YYY” under the current security context.

This seems like a permission issue. Ensure that the Windows service is configured to use the correct credentials.