windows_exporter icon indicating copy to clipboard operation
windows_exporter copied to clipboard

how to run custom (adminstartive or ad hoc )T-SQL queries on mssql database by using windows exporter?

Open javad87 opened this issue 3 years ago • 3 comments
trafficstars

I want to find a list of useres loged in and are active in different Databases, or would like to run Adminstrative microsft sql queries to get specific information about Databses and Tables on the trageted server, or finding which user running expensive queries on the datbase server....How can I do it with mssql module of windows_exporter? in metrics list there is no such things at least I could not find it...

I guess for specific query it needs log in user and connection strig with driver (odbc) to first to connect to DB on port 1433, how can I do it if it is possible with mssql module?

tnx;

javad87 avatar Apr 17 '22 09:04 javad87

The mssql collector doesn't use SQL queries for metric collection, nor does it provide the ability to run arbitrary SQL commands.

At present, the best way to implement this would be to run a custom Powershell/SQL script that outputs metric information for the textfile collector to consume.

breed808 avatar May 12 '22 10:05 breed808

The mssql collector doesn't use SQL queries for metric collection, nor does it provide the ability to run arbitrary SQL commands.

At present, the best way to implement this would be to run a custom Powershell/SQL script that outputs metric information for the textfile collector to consume.

Thanks for reply breed:-)

So, as I understood for finding "expensive T-SQL queries exceuting by differnet users" It is not possible to get it from 'mssql' collector, and have to write a spicific Powershell script( and connecting to MSSQL DB engine) and collecting information into textfile and then using endpoint for prometheus.... How can I do it? is there any examples I can use them...I'm not administrator guy and taught prometheus are battery included type of monitoring tools with already existing exporters it is easy to use and implement, now wondering why there is no exporter to find expensive T-SQL query or executing adminstrative SQL queries to get metrics form DB; exists out there on the interent!!

Best Regards;

javad87 avatar May 14 '22 06:05 javad87

@javad87 you might want to look into https://github.com/free/sql_exporter, https://github.com/justwatchcom/sql_exporter, or https://github.com/chop-dbhi/prometheus-sql. They appear to support running arbitrary SQL commands, which is outside the scope of the OS-level metrics offered bywindows_exporter.

breed808 avatar May 18 '22 08:05 breed808

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

github-actions[bot] avatar Nov 25 '23 02:11 github-actions[bot]