newrelic/nri-mssql

nri-mssql custom query returns error but does not show on info level logs

Closed this issue · 4 comments

Hi,

When adding custom queries to the mssql integration and for some reason there is an error with the query or an error in SQL, in this case it was that the sql user does not have access to the table in the database to execute the query, SQL returns and error, but in the NewRelic logs there is no error shown at all but the data does not land up in NewRelic. This makes it difficult to see if something did go wrong, until you change the log level to debug, and then you see the error in the NewRelic logs.

Description

SQL user account that NewRelic agent uses to execute custom queries does not have rights on the database and this causes an error, but the error does not display in the NewRelic logs until debug on the logs are enabled.

Expected Behavior

All ERRORS from NewRelic related agents (msssql integration) should show up on the logs when logs are set on the appropriate level. When set to INFO all error, warn and info messages should show up in this log.

Troubleshooting or [NR Diag]

Log Line:
time="2023-10-18T11:13:55+02:00" level=debug msg="Integration stderr (not parsed)." component=integrations.runner.Runner integration_name=nri-mssql line="[ERR] Could not execute custom query: mssql: The SELECT permission was denied on the object 'xxxx', database 'xxxx', schema 'xxxx'." runner_uid=xxxx server=xxxx

Note that this was on debug logging, when placed on info level logging this error does not show up and no error shows in the logs.

Steps to Reproduce

  1. Create a custom query for a table the new relic agent does not have permissions to
  2. Save the file and restart the agent
  3. Agent should try and execute the SQL query but without the correct privileges it should fail and NOT produce an error message when INFO logging is active.

Your Environment

NewRelic Infrastructure Agent 1.47.2
NRI-MSSQL agent 2.8.7

For Maintainers Only or Hero Triaging this bug

Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):

I believe that the issue is related to the parser used by the agent to understand if it is an error or not.

Moving all integration to leverage logrus is a big effort, it would be way easier to change the behavior of the agent

I opened the discussion with the caos team.

The infra-agent team created a task in order to solve this issue. Once that is completed (no ETA yet) updating the agent will be enough to solve it.

Thanks for rising the issue!

Work has been completed on this issue.