-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate metrics for non-numeric fields
Every report group (PV, VG, LV) had its own info metric where non-numeric fields like `pv_attr` were reported as a label. Every unique combination of labels produces a new time series. From https://prometheus.io/docs/practices/naming/#labels: > Remember that every unique combination of key-value label pairs > represents a new time series, which can dramatically increase the > amount of data stored. Do not use labels to store dimensions with high > cardinality (many different label values), such as user IDs, email > addresses, or other unbounded sets of values. With this change the labels on the info metrics are reduced to names (e.g. `pv_name` and `lv_full_name`). Everything else is moved to separate metrics. A command line flag, enabled by default, retains the labels on the info metric. Related to issue #31.
- Loading branch information
Showing
26 changed files
with
5,050 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
var defaultStringSlicePool = newStringSlicePool() | ||
|
||
type stringSlicePool struct { | ||
pool sync.Pool | ||
} | ||
|
||
func newStringSlicePool() *stringSlicePool { | ||
return &stringSlicePool{ | ||
pool: sync.Pool{ | ||
New: func() any { | ||
return []string(nil) | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// get returns an empty string slice. The caller has ownership of the slice | ||
// until the slice is put back into the pool. | ||
func (p *stringSlicePool) get() []string { | ||
return p.pool.Get().([]string)[:0] | ||
} | ||
|
||
func (p *stringSlicePool) put(s []string) { | ||
// All elements must be accessible. | ||
s = s[:cap(s)] | ||
|
||
// Remove references to values. | ||
clear(s) | ||
|
||
p.pool.Put(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"math/rand/v2" | ||
"slices" | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
func TestStringSlicePool(t *testing.T) { | ||
p := newStringSlicePool() | ||
|
||
for range 100 { | ||
s := p.get() | ||
|
||
if len(s) > 0 { | ||
t.Errorf("get() returned non-empty slice: %q", s) | ||
} | ||
|
||
count := rand.IntN(100) | ||
|
||
for i := range count { | ||
s = append(s, strconv.Itoa(i)) | ||
} | ||
|
||
switch rand.IntN(3) { | ||
case 1: | ||
s = s[:0] | ||
case 2: | ||
s = s[:count/2] | ||
} | ||
|
||
p.put(s) | ||
|
||
if idx := slices.IndexFunc(s[:count], func(value string) bool { | ||
return value != "" | ||
}); idx != -1 { | ||
t.Errorf("Slice was not cleared: %q", s[:count]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# HELP lvm_lv_info | ||
# TYPE lvm_lv_info gauge | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="[vpool0_vdata]",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="tHnHR1-bjg8-ycJX-eyhR-heEp-L4qs-S510dO",lv_vdo_compression_state="",lv_vdo_index_state="",lv_vdo_operating_mode="",lv_when_full=""} 1 | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="lv_data",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="5UyOrx-zG6u-w7cF-G2Ny-HmVd-0lsb-4J6lG2",lv_vdo_compression_state="",lv_vdo_index_state="",lv_vdo_operating_mode="",lv_when_full=""} 1 | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="lv_db_backup",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa",lv_vdo_compression_state="online",lv_vdo_index_state="online",lv_vdo_operating_mode="normal",lv_when_full=""} 1 | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="root",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="cqZnVQ-FUPG-btWz-3fff-cMX5-wViK-8MM3QY",lv_vdo_compression_state="",lv_vdo_index_state="",lv_vdo_operating_mode="",lv_when_full=""} 1 | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="swap",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="lGs7Tn-1Fyv-jMHN-aniN-r8qk-duEI-B9Xl9e",lv_vdo_compression_state="",lv_vdo_index_state="",lv_vdo_operating_mode="",lv_when_full=""} 1 | ||
lvm_lv_info{lv_active="",lv_allocation_policy="",lv_ancestors="",lv_attr="",lv_convert_lv="",lv_convert_lv_uuid="",lv_data_lv="",lv_data_lv_uuid="",lv_descendants="",lv_dm_path="",lv_full_ancestors="",lv_full_descendants="",lv_full_name="",lv_health_status="",lv_host="",lv_kernel_cache_policy="",lv_kernel_cache_settings="",lv_kernel_discards="",lv_kernel_metadata_format="",lv_kernel_read_ahead_bytes="",lv_layout="",lv_lockargs="",lv_metadata_lv="",lv_metadata_lv_uuid="",lv_mirror_log="",lv_mirror_log_uuid="",lv_modules="",lv_move_pv="",lv_move_pv_uuid="",lv_name="vpool0",lv_origin="",lv_origin_uuid="",lv_parent="",lv_path="",lv_permissions="",lv_pool_lv="",lv_pool_lv_uuid="",lv_raid_sync_action="",lv_raidintegritymode="",lv_role="",lv_tags="",lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF",lv_vdo_compression_state="online",lv_vdo_index_state="online",lv_vdo_operating_mode="normal",lv_when_full=""} 1 | ||
# HELP lvm_lv_vdo_compression_state For vdo pools, whether compression is running | ||
# TYPE lvm_lv_vdo_compression_state gauge | ||
lvm_lv_vdo_compression_state{lv_uuid="5UyOrx-zG6u-w7cF-G2Ny-HmVd-0lsb-4J6lG2",lv_vdo_compression_state=""} 1 | ||
lvm_lv_vdo_compression_state{lv_uuid="cqZnVQ-FUPG-btWz-3fff-cMX5-wViK-8MM3QY",lv_vdo_compression_state=""} 1 | ||
lvm_lv_vdo_compression_state{lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF",lv_vdo_compression_state="online"} 1 | ||
lvm_lv_vdo_compression_state{lv_uuid="lGs7Tn-1Fyv-jMHN-aniN-r8qk-duEI-B9Xl9e",lv_vdo_compression_state=""} 1 | ||
lvm_lv_vdo_compression_state{lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa",lv_vdo_compression_state="online"} 1 | ||
lvm_lv_vdo_compression_state{lv_uuid="tHnHR1-bjg8-ycJX-eyhR-heEp-L4qs-S510dO",lv_vdo_compression_state=""} 1 | ||
# HELP lvm_lv_vdo_index_state For vdo pools, state of index for deduplication | ||
# TYPE lvm_lv_vdo_index_state gauge | ||
lvm_lv_vdo_index_state{lv_uuid="5UyOrx-zG6u-w7cF-G2Ny-HmVd-0lsb-4J6lG2",lv_vdo_index_state=""} 1 | ||
lvm_lv_vdo_index_state{lv_uuid="cqZnVQ-FUPG-btWz-3fff-cMX5-wViK-8MM3QY",lv_vdo_index_state=""} 1 | ||
lvm_lv_vdo_index_state{lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF",lv_vdo_index_state="online"} 1 | ||
lvm_lv_vdo_index_state{lv_uuid="lGs7Tn-1Fyv-jMHN-aniN-r8qk-duEI-B9Xl9e",lv_vdo_index_state=""} 1 | ||
lvm_lv_vdo_index_state{lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa",lv_vdo_index_state="online"} 1 | ||
lvm_lv_vdo_index_state{lv_uuid="tHnHR1-bjg8-ycJX-eyhR-heEp-L4qs-S510dO",lv_vdo_index_state=""} 1 | ||
# HELP lvm_lv_vdo_operating_mode For vdo pools, its current operating mode | ||
# TYPE lvm_lv_vdo_operating_mode gauge | ||
lvm_lv_vdo_operating_mode{lv_uuid="5UyOrx-zG6u-w7cF-G2Ny-HmVd-0lsb-4J6lG2",lv_vdo_operating_mode=""} 1 | ||
lvm_lv_vdo_operating_mode{lv_uuid="cqZnVQ-FUPG-btWz-3fff-cMX5-wViK-8MM3QY",lv_vdo_operating_mode=""} 1 | ||
lvm_lv_vdo_operating_mode{lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF",lv_vdo_operating_mode="normal"} 1 | ||
lvm_lv_vdo_operating_mode{lv_uuid="lGs7Tn-1Fyv-jMHN-aniN-r8qk-duEI-B9Xl9e",lv_vdo_operating_mode=""} 1 | ||
lvm_lv_vdo_operating_mode{lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa",lv_vdo_operating_mode="normal"} 1 | ||
lvm_lv_vdo_operating_mode{lv_uuid="tHnHR1-bjg8-ycJX-eyhR-heEp-L4qs-S510dO",lv_vdo_operating_mode=""} 1 | ||
# HELP lvm_lv_vdo_saving_percent For vdo pools, percentage of saved space | ||
# TYPE lvm_lv_vdo_saving_percent gauge | ||
lvm_lv_vdo_saving_percent{lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF"} 55.37 | ||
lvm_lv_vdo_saving_percent{lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa"} 55.37 | ||
# HELP lvm_lv_vdo_used_size_bytes For vdo pools, currently used space | ||
# TYPE lvm_lv_vdo_used_size_bytes gauge | ||
lvm_lv_vdo_used_size_bytes{lv_uuid="dylifl-81AF-n2mG-kFKo-Ntxe-mnNQ-3eB7fF"} 2.78899963904e+12 | ||
lvm_lv_vdo_used_size_bytes{lv_uuid="r7Btja-nL3P-Co38-X2K4-DLWS-LMhT-LajcQa"} 2.78899963904e+12 | ||
# HELP lvm_unknown_field_count Fields reported by LVM not recognized by exporter | ||
# TYPE lvm_unknown_field_count gauge | ||
lvm_unknown_field_count{details="",group="lv"} 0 | ||
lvm_unknown_field_count{details="",group="pv"} 0 | ||
lvm_unknown_field_count{details="",group="vg"} 0 | ||
# HELP lvm_up Whether scrape was successful | ||
# TYPE lvm_up gauge | ||
lvm_up{status=""} 1 |
Oops, something went wrong.