Skip to content

Commit

Permalink
Updated the MSSQL drive to use an Azure to provide flexibility of usi…
Browse files Browse the repository at this point in the history
…ng Azure Tokens instead of user pass
  • Loading branch information
Dkairu committed May 13, 2024
1 parent c56a15d commit c3a860a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
25 changes: 25 additions & 0 deletions examples/Azure-SQL-Managed-Instance-active-directory-tokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This custom integration uses flex to query Azure SQL for custom metrics. Notes are below.
#
# Azure Entra ID(formerly Active Directory) authentication uses temporary authentication tokens to authenticate and connect to your Azure SQL database.
# The Azure SQL database needs to be configured to use Entra ID admin service principal as a way to connect.
# You can authenticate using either fedauth=ActiveDirectoryServicePrincipal or fedauth=ActiveDirectoryApplication
# Which authenticates using an Azure Active Directory application client ID and client secret or certificate.
# The certifcate format should be clientcertpath=<path to certificate file>;password=<certificate password>
# Other options including using Azure Managed Identity or Active directory passwords are also available and are explained here https://github.com/denisenkom/go-mssqldb?tab=readme-ov-file#azure-active-directory-authentication
---
integrations:
- name: nri-flex
# interval: 30s
config:
name: AzureSQLDbFlex
apis:
- database: sqlserver
db_conn: server=azure.database.windows.net;user id=<clientId@tenantId>;password=<client secret>;database=master;fedauth=ActiveDirectoryServicePrincipal
logging:
open: true
custom_attributes: # applies to all queries
host: azure.database.windows.net
db_async: true # process queries async
db_queries:
- name: AzureSQLCustomLogSpace
run: DBCC SQLPERF(LOGSPACE);
File renamed without changes.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
Expand Down Expand Up @@ -77,6 +80,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/procfs v0.9.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0 h1:OYa9vmRX2XC5GXRAzeggG12sF/z5D9Ahtdm9EJ00WN4=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
Expand Down Expand Up @@ -274,6 +277,7 @@ github.com/parnurzeal/gorequest v0.2.15 h1:oPjDCsF5IkD4gUk6vIgsxYNaSgvAnIh1EJeRO
github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
2 changes: 1 addition & 1 deletion internal/inputs/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
_ "github.com/MonetDB/MonetDB-Go/src" //MonetDB
// _ "github.com/SAP/go-ase" //Sybase
_ "github.com/SAP/go-hdb/driver" //SAP HANA
_ "github.com/denisenkom/go-mssqldb" //mssql | sql-server
_ "github.com/denisenkom/go-mssqldb/azuread" //mssql | sql-server
_ "github.com/go-sql-driver/mysql" //mysql
_ "github.com/lib/pq" //postgres
_ "github.com/sijms/go-ora/v2" //Oracle
Expand Down
2 changes: 1 addition & 1 deletion internal/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const (
DefaultPingTimeout = 5000 // 5 seconds
DefaultHANA = "hdb"
DefaultPostgres = "postgres"
DefaultMSSQLServer = "sqlserver"
DefaultMSSQLServer = "azuresql"
DefaultMySQL = "mysql"
DefaultOracle = "oracle"
// DefaultSybase = "ase"
Expand Down

0 comments on commit c3a860a

Please sign in to comment.