From fa103875a0223cce0b5dd4e42a916daaefcd541e Mon Sep 17 00:00:00 2001 From: DexterZhang Date: Thu, 4 Jun 2020 18:05:50 +0800 Subject: [PATCH] feat(vmselect): add tmp block dir size metrics `vm_tmp_blocks_files_size_total` (#527) * feat(vmselect): add tmp block dir size metrics `vm_tmp_blocks_files_size_total` * refactor(vmselect): use free space instead of used space in tmp block file metrics * fix: add `bytes` suffix to tmp dir free space metric --- app/vmselect/netstorage/tmp_blocks_file.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/vmselect/netstorage/tmp_blocks_file.go b/app/vmselect/netstorage/tmp_blocks_file.go index 7a278898f..947870023 100644 --- a/app/vmselect/netstorage/tmp_blocks_file.go +++ b/app/vmselect/netstorage/tmp_blocks_file.go @@ -85,7 +85,12 @@ func (addr tmpBlockAddr) String() string { return fmt.Sprintf("offset %d, size %d", addr.offset, addr.size) } -var tmpBlocksFilesCreated = metrics.NewCounter(`vm_tmp_blocks_files_created_total`) +var ( + tmpBlocksFilesCreated = metrics.NewCounter(`vm_tmp_blocks_files_created_total`) + _ = metrics.NewGauge(`vm_tmp_blocks_files_directory_free_bytes`, func() float64 { + return float64(fs.MustGetFreeSpace(tmpBlocksDir)) + }) +) // WriteBlockData writes b to tbf. //