使用 Telegraf 和 Influx 监控 Azure SQL 数据库
Monitoring Azure SQL db with Telegraf and Influx
我们正在采用更好的机制来监控我们的环境,我们开始设置 Influx + Telegraf + Grafana。
我们将 Azure Monitor 连接到 Grafana,我们可以在那里看到很多细节,但我们想更深入地了解我们的 SQL 是如何使用的。
我已按照此处描述的步骤进行操作 - https://github.com/influxdata/telegraf/blob/release-1.14/plugins/inputs/sqlserver/README.md。
但是脚本失败,下一个结果:
Securable class 'server' not supported in this version of SQL Server.
尝试使用我们的管理员帐户连接到 SQL 服务器,该帐户具有所有权限并且 logstash 显示下一个结果:
E! [inputs.sqlserver] Error in plugin: Script VolumeSpace failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script AzureDBPerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script DatabaseIO failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script AzureDBPerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script ServerProperties failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script WaitStatsCategorized failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script Cpu failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script PerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script MemoryClerk failed: Login error: mssql: Login failed for user 'xxx_user'.
在 GitHub 中找不到与此相关的任何问题。有什么我想念的吗?
有人成功连接这两项服务吗?
如果还没有,您将需要在数据库级别授予视图定义。 (没有 ANY 关键字)
GRANT VIEW DEFINITION TO user_name
参考:SQL服务器权限
根据 Microsoft SQL 服务器插件 ID:inputs.sqlserver Telegraf 0.10.1+ 基于 AAD 的身份验证仅支持 Azure SQL 数据库和 Azure SQL 托管实例(但不适用于 SQL 服务器),如此处所述。
servers = [
"Server=<Azure_SQL_Server_Name>.database.windows.net;Port=1433;Database=<Azure_SQL_Database_Name>;app name=telegraf;log=1;",
]
auth_method = "AAD"
可用的其他 Azure AD 身份验证选项有 Active Directory Universal Authentication for SQL Server Management Studio connections including Multi-Factor Authentication and Conditional Access。
注意:我们 telegraf v1.19.1 [2021-07-07] released this 8 hours ago and among its other bugfixes, this seems to be addressed: #9388 inputs.sqlserver
需要指定身份验证方法
But from earlier discussion on github for telegraf release 1.10.3,
this works without crashing when connected as the super user (the one
who created the whole server). It still fails when connecting as a
less privileged user.
GitHub 中报告的其他问题:
我能够通过为 Influx Azure 安装模板仪表板来实施监控 SQL 监控 - https://github.com/influxdata/community-templates/tree/master/azure_sql_db.
安装模板后,我进入 Influx UI 数据菜单和 Telegraf
选项卡。
在那里,我已经复制了配置并使用了正确的格式化连接字符串,一切都开始工作了。
YOUR_USER
- 管理员用户
YOUR_PASSWORd
- 管理员用户密码
这是我的连接字符串模板:
Server={YOUR_DB_LINK};Port=1433;Database={YOUR_DATABASE};User Id={YOUR_USER};Password={YOUR_PASSWORD};app name=telegraf;log=1;Initial Catalog=demo;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30
我的 Telegraf 配置:
[[outputs.influxdb_v2]]
urls = ["${INFLUX_URI}"]
token = "${INFLUX_TOKEN}"
organization = "{YOUR_ORG}"
bucket = "AzureSQLDB"
namepass = ["sql*"]
[[inputs.sqlserver]]
servers = ["$AZURE_SQL_CONNECTION_STRING",]
query_version = 2
database_type = "AzureSQLDB"
include_query = ["AzureSQLDBResourceStats","AzureSQLDBWaitStats","AzureSQLDBDatabaseIO","AzureSQLDBMemoryClerks","AzureSQLDBPerformanceCounters","SQLServerPerformanceCounters"]
我们正在采用更好的机制来监控我们的环境,我们开始设置 Influx + Telegraf + Grafana。
我们将 Azure Monitor 连接到 Grafana,我们可以在那里看到很多细节,但我们想更深入地了解我们的 SQL 是如何使用的。
我已按照此处描述的步骤进行操作 - https://github.com/influxdata/telegraf/blob/release-1.14/plugins/inputs/sqlserver/README.md。
但是脚本失败,下一个结果:
Securable class 'server' not supported in this version of SQL Server.
尝试使用我们的管理员帐户连接到 SQL 服务器,该帐户具有所有权限并且 logstash 显示下一个结果:
E! [inputs.sqlserver] Error in plugin: Script VolumeSpace failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script AzureDBPerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script DatabaseIO failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script AzureDBPerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script ServerProperties failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script WaitStatsCategorized failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script Cpu failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script PerformanceCounters failed: Login error: mssql: Login failed for user 'xxx_user'.
E! [inputs.sqlserver] Error in plugin: Script MemoryClerk failed: Login error: mssql: Login failed for user 'xxx_user'.
在 GitHub 中找不到与此相关的任何问题。有什么我想念的吗?
有人成功连接这两项服务吗?
如果还没有,您将需要在数据库级别授予视图定义。 (没有 ANY 关键字)
GRANT VIEW DEFINITION TO user_name
参考:SQL服务器权限
根据 Microsoft SQL 服务器插件 ID:inputs.sqlserver Telegraf 0.10.1+ 基于 AAD 的身份验证仅支持 Azure SQL 数据库和 Azure SQL 托管实例(但不适用于 SQL 服务器),如此处所述。
servers = [
"Server=<Azure_SQL_Server_Name>.database.windows.net;Port=1433;Database=<Azure_SQL_Database_Name>;app name=telegraf;log=1;",
]
auth_method = "AAD"
可用的其他 Azure AD 身份验证选项有 Active Directory Universal Authentication for SQL Server Management Studio connections including Multi-Factor Authentication and Conditional Access。
注意:我们 telegraf v1.19.1 [2021-07-07] released this 8 hours ago and among its other bugfixes, this seems to be addressed: #9388 inputs.sqlserver
需要指定身份验证方法
But from earlier discussion on github for telegraf release 1.10.3, this works without crashing when connected as the super user (the one who created the whole server). It still fails when connecting as a less privileged user.
GitHub 中报告的其他问题:
我能够通过为 Influx Azure 安装模板仪表板来实施监控 SQL 监控 - https://github.com/influxdata/community-templates/tree/master/azure_sql_db.
安装模板后,我进入 Influx UI 数据菜单和 Telegraf
选项卡。
在那里,我已经复制了配置并使用了正确的格式化连接字符串,一切都开始工作了。
YOUR_USER
- 管理员用户
YOUR_PASSWORd
- 管理员用户密码
这是我的连接字符串模板:
Server={YOUR_DB_LINK};Port=1433;Database={YOUR_DATABASE};User Id={YOUR_USER};Password={YOUR_PASSWORD};app name=telegraf;log=1;Initial Catalog=demo;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30
我的 Telegraf 配置:
[[outputs.influxdb_v2]]
urls = ["${INFLUX_URI}"]
token = "${INFLUX_TOKEN}"
organization = "{YOUR_ORG}"
bucket = "AzureSQLDB"
namepass = ["sql*"]
[[inputs.sqlserver]]
servers = ["$AZURE_SQL_CONNECTION_STRING",]
query_version = 2
database_type = "AzureSQLDB"
include_query = ["AzureSQLDBResourceStats","AzureSQLDBWaitStats","AzureSQLDBDatabaseIO","AzureSQLDBMemoryClerks","AzureSQLDBPerformanceCounters","SQLServerPerformanceCounters"]