-
Is it possible to create a metric to get the size of a database table? I want to monitor the size over time. I would like to use the query:
Is this possible with this exporter? |
Beta Was this translation helpful? Give feedback.
Answered by
ihindegit
Jan 15, 2025
Replies: 1 comment 4 replies
-
hey @ihindegit, it's hard to suggest something since there is no context. Assuming you're talking about MSSQL, you might want to also have a look here: #514 The stored procedure might work as well, I haven't tested it. 👍 |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possibly something wrong with the definition? Below is my full metric.
type: gauge
help: 'Table size'
value_label: 'state'
values: [TotalSpaceKB]
query: SELECT SUM(a.total_pages) * 8 AS TotalSpaceKB
FROM sys.tables t
INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id
WHERE
t.NAME = 'MyTable'
GROUP BY
t.Name, s.Name, p.Rows
ORDER BY
TotalSpaceKB DESC