justwatchcom / sql_exporter

Flexible SQL Exporter for Prometheus.
MIT License
393 stars 108 forks source link

help needed: measure available disk space #87

Closed tgy closed 1 year ago

tgy commented 1 year ago

I'm working at a big French hospital which uses Microsoft SQL server to store patient data.

One of the most important things i need to monitor is available disk space. This is critical because if there is no available disk space, the system completely fails and data is lost.

I've been trying to use sys.dm_os_volume_stats which completely fails at returning the actual available/used/total space used by each volume (G:, C:, etc.)

I see many people use EXECUTE sys.xp_cmdshell 'wmic volume get name, freespace, capacity, label' to do this but it seems that this is outputing unstructured text.

Do you guys have any advice? How do you monitor and measure your disk space?

Thanks a lot for any help you can provide.

dewey commented 1 year ago

Hey, don't have any experience with MS SQL Server, but I saw that the https://github.com/free/sql_exporter exporter has metrics for that, maybe you can give that one a try?

https://sysdig.com/blog/monitor-sql-server-prometheus/

tgy commented 1 year ago

@dewey Thanks for your answer. First thing I did was actually checking these settings from the repo you mentioned. Sadly, they are not measure disk space there. Did I miss something?

dewey commented 1 year ago

Interesting, seems like the metric mentioned in the blog post isn't exported anymore. I'd probably look into a generic exporter for whatever platform you are using (Windows?) or if it's a managed database an exporter for that managed service.

I'd almost say that monitoring the disk space of the system the database is running on isn't really the responsibility of the database, especially as it's not always clear which disk should be monitored. The volume where logs go, the data volume, the replication file volume?

Maybe: https://github.com/prometheus-community/windows_exporter?

tgy commented 1 year ago

thanks a lot @dewey for your answers

indeed, it does not really make sense to check the available volume disk space from the DB

we might create a C# user function that does it though!

closing this issue now