-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Server plugin only supports super user with AzureDB #5808
Comments
Would you be able to use the |
Yes, but unfortunately it did not turn out well. I started by excluding all queries (as far as I could determine by looking at the source). Config:
Result:
|
Note that if I connect as the super user I do not get the exception. |
There is one more query in your case: This is going to reveal how clueless I am about Windows, but what does this mean? Is it just reporting that the program exited with a non-zero status code?
|
Well, it is actually quite odd. PowerShell logs the error above. If I run the command from a normal command prompt there is no error logged. I'll do the additional tests from the command prompt. Note that the command prompt (and PowerShell) hangs, I expected them to run once and exit as I pass "-test"? Has that changed?
In summary it seems everything but the AzureDB query gives access denied. Too bad. |
Not exiting is probably the issue I fixed in #5631, in the meantime I thit it will help if you run with These results are all when running under the dbo account? |
Good, I'll use |
I looked at the Following the link I see:
Can you check to see if the dbo account has these permissions? |
As I recall VIEW SERVER STATE cannot be granted in Azure, it is only available to the super user. VIEW DATABASE STATE on the other hand can be granted and is granted to dbo. |
@erik-wramner Can you try out these user setup instructions from #6111?  CREATE USER [telegraf] WITH PASSWORD = N'mystrongpassword';
 GO
 GRANT VIEW DATABASE STATE TO [telegraf];
 GO
 ``` |
I'll upgrade to the latest version and try it out, but it will take some time. I'm on vacation so I don't have access to the environments right now. |
I actually needed one additional command:
With that and the latest nightly build (as of Today) it worked. I got some output and one error in the logs:
Not sure what caused the error, but there was no crash and some output with a normal user! Clearly a step forward. |
Actually I'm stupid. Excluding Schedulers (as was done in #6111) removes the error. |
Looking forward to implement this when it is released! |
@erik-wramner Could you please advise if this issue is fixed? I am getting error message when I use a non super user for Azure SQL DB. I am using the template from here: https://github.com/influxdata/community-templates/tree/master/azure_sql_db VIEW SERVER PERFORMANCE STATE permission was denied on object 'server', database 'master'. |
Well, it was working in 2019. Unfortunately we are no longer using this, but run custom SQL scripts from bash. That way we can get application-specific metrics as well. Perhaps the permission you mention is new? I had to exclude schedulers:
|
@erik-wramner Thank you for your reply. There are some new permissions we can grant on Azure SQL DB logical server. Refer link1, link2 Once I granted the telegraf access to these server roles, the plugin started to work as expected with neat dashboards |
Feature Request
Support running telegraf with SQL Database with another user than the super-user
Proposal:
Make the SQL Server plugin fail gracefully on queries it does not have access to or add config options for turning off queries that require the super user account and make it possible to use it as a regular user. Even the database owner account for a given database would be better than the super user!
Current behavior:
If the SQL Server plugin tries to gather metrics from a SQL Database with a user that is not the super user (dbo is not enough; this is the user that created the server and that has full rights to the entire system, all databases, everything) it fails. The log contains errors like:
2019-05-06T13:27:01Z E! [inputs.sqlserver]: Error in plugin: mssql: The user does not have permission to perform this action.
There are some metrics that can be collected as another user, but as the plugin fails when it tries to access the restricted views they cannot be used either.
Desired behavior:
Fail gracefully on the queries that the user does not have access to and output metrics for the queries that do work. Alternatively add a configuration option that disables all the queries that require the super user and run only the ones that work for a regular user. Also document the grants that are needed in order to use the plugin with SQL Database. Some of the queries work with dbo, but it is better to create a telegraf user and grant only the bare minimum rights.
Use case:
We cannot use telegraf for instrumenting SQL Database because the risk of putting the super user id and password in the telegraf configuration files are simply too high. We would very much like to use this, but you don't do monitoring by connecting with root/sysdba/sa. It is simply too dangerous.
The text was updated successfully, but these errors were encountered: