Browse Source

Add metrics for btrfs commit statistics (#3010)

Signed-off-by: Maarten van den Berg <maarten@channable.com>
pull/3073/head
Maarten van den Berg 4 months ago committed by GitHub
parent
commit
e8aa4de7c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      collector/btrfs_linux.go
  2. 8
      collector/btrfs_linux_test.go
  3. 16
      collector/fixtures/e2e-64k-page-output.txt
  4. 16
      collector/fixtures/e2e-output.txt
  5. 8
      collector/fixtures/sys.ttar

24
collector/btrfs_linux.go

@ -275,6 +275,30 @@ func (c *btrfsCollector) getMetrics(s *btrfs.Stats, ioctlStats *btrfsIoctlFsStat
metricType: prometheus.GaugeValue,
value: float64(s.Allocation.GlobalRsvSize),
},
{
name: "commits_total",
desc: "The total number of commits that have occurred.",
metricType: prometheus.CounterValue,
value: float64(s.CommitStats.Commits),
},
{
name: "last_commit_seconds",
desc: "Duration of the most recent commit, in seconds.",
metricType: prometheus.GaugeValue,
value: float64(s.CommitStats.LastCommitMs) / 1000,
},
{
name: "max_commit_seconds",
desc: "Duration of the slowest commit, in seconds.",
metricType: prometheus.GaugeValue,
value: float64(s.CommitStats.MaxCommitMs) / 1000,
},
{
name: "commit_seconds_total",
desc: "Sum of the duration of all commits, in seconds.",
metricType: prometheus.CounterValue,
value: float64(s.CommitStats.TotalCommitMs) / 1000,
},
}
// Information about data, metadata and system data.

8
collector/btrfs_linux_test.go

@ -27,6 +27,10 @@ var expectedBtrfsMetrics = [][]btrfsMetric{
{
{name: "info", value: 1, extraLabel: []string{"label"}, extraLabelValue: []string{"fixture"}},
{name: "global_rsv_size_bytes", value: 1.6777216e+07},
{name: "commits_total", value: 258051, metricType: 1},
{name: "last_commit_seconds", value: 1.0},
{name: "max_commit_seconds", value: 51.462},
{name: "commit_seconds_total", value: 47836.090, metricType: 1},
{name: "reserved_bytes", value: 0, extraLabel: []string{"block_group_type"}, extraLabelValue: []string{"data"}},
{name: "used_bytes", value: 8.08189952e+08, extraLabel: []string{"block_group_type", "mode"}, extraLabelValue: []string{"data", "raid0"}},
{name: "size_bytes", value: 2.147483648e+09, extraLabel: []string{"block_group_type", "mode"}, extraLabelValue: []string{"data", "raid0"}},
@ -45,6 +49,10 @@ var expectedBtrfsMetrics = [][]btrfsMetric{
{
{name: "info", value: 1, extraLabel: []string{"label"}, extraLabelValue: []string{""}},
{name: "global_rsv_size_bytes", value: 1.6777216e+07},
{name: "commits_total", value: 0, metricType: 1},
{name: "last_commit_seconds", value: 0},
{name: "max_commit_seconds", value: 0},
{name: "commit_seconds_total", value: 0, metricType: 1},
{name: "reserved_bytes", value: 0, extraLabel: []string{"block_group_type"}, extraLabelValue: []string{"data"}},
{name: "used_bytes", value: 0, extraLabel: []string{"block_group_type", "mode"}, extraLabelValue: []string{"data", "raid5"}},
{name: "size_bytes", value: 6.44087808e+08, extraLabel: []string{"block_group_type", "mode"}, extraLabelValue: []string{"data", "raid5"}},

16
collector/fixtures/e2e-64k-page-output.txt

@ -161,6 +161,14 @@ node_btrfs_allocation_ratio{block_group_type="metadata",mode="raid1",uuid="0abb2
node_btrfs_allocation_ratio{block_group_type="metadata",mode="raid6",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 2
node_btrfs_allocation_ratio{block_group_type="system",mode="raid1",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 2
node_btrfs_allocation_ratio{block_group_type="system",mode="raid6",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 2
# HELP node_btrfs_commit_seconds_total Sum of the duration of all commits, in seconds.
# TYPE node_btrfs_commit_seconds_total counter
node_btrfs_commit_seconds_total{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 47836.09
node_btrfs_commit_seconds_total{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_commits_total The total number of commits that have occurred.
# TYPE node_btrfs_commits_total counter
node_btrfs_commits_total{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 258051
node_btrfs_commits_total{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_device_size_bytes Size of a device that is part of the filesystem.
# TYPE node_btrfs_device_size_bytes gauge
node_btrfs_device_size_bytes{device="loop22",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1.073741824e+10
@ -177,6 +185,14 @@ node_btrfs_global_rsv_size_bytes{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1.
# TYPE node_btrfs_info gauge
node_btrfs_info{label="",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1
node_btrfs_info{label="fixture",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 1
# HELP node_btrfs_last_commit_seconds Duration of the most recent commit, in seconds.
# TYPE node_btrfs_last_commit_seconds gauge
node_btrfs_last_commit_seconds{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 1
node_btrfs_last_commit_seconds{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_max_commit_seconds Duration of the slowest commit, in seconds.
# TYPE node_btrfs_max_commit_seconds gauge
node_btrfs_max_commit_seconds{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 51.462
node_btrfs_max_commit_seconds{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_reserved_bytes Amount of space reserved for a data type
# TYPE node_btrfs_reserved_bytes gauge
node_btrfs_reserved_bytes{block_group_type="data",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 0

16
collector/fixtures/e2e-output.txt

@ -161,6 +161,14 @@ node_btrfs_allocation_ratio{block_group_type="metadata",mode="raid1",uuid="0abb2
node_btrfs_allocation_ratio{block_group_type="metadata",mode="raid6",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 2
node_btrfs_allocation_ratio{block_group_type="system",mode="raid1",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 2
node_btrfs_allocation_ratio{block_group_type="system",mode="raid6",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 2
# HELP node_btrfs_commit_seconds_total Sum of the duration of all commits, in seconds.
# TYPE node_btrfs_commit_seconds_total counter
node_btrfs_commit_seconds_total{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 47836.09
node_btrfs_commit_seconds_total{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_commits_total The total number of commits that have occurred.
# TYPE node_btrfs_commits_total counter
node_btrfs_commits_total{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 258051
node_btrfs_commits_total{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_device_size_bytes Size of a device that is part of the filesystem.
# TYPE node_btrfs_device_size_bytes gauge
node_btrfs_device_size_bytes{device="loop22",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1.073741824e+10
@ -177,6 +185,14 @@ node_btrfs_global_rsv_size_bytes{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1.
# TYPE node_btrfs_info gauge
node_btrfs_info{label="",uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 1
node_btrfs_info{label="fixture",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 1
# HELP node_btrfs_last_commit_seconds Duration of the most recent commit, in seconds.
# TYPE node_btrfs_last_commit_seconds gauge
node_btrfs_last_commit_seconds{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 1
node_btrfs_last_commit_seconds{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_max_commit_seconds Duration of the slowest commit, in seconds.
# TYPE node_btrfs_max_commit_seconds gauge
node_btrfs_max_commit_seconds{uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 51.462
node_btrfs_max_commit_seconds{uuid="7f07c59f-6136-449c-ab87-e1cf2328731b"} 0
# HELP node_btrfs_reserved_bytes Amount of space reserved for a data type
# TYPE node_btrfs_reserved_bytes gauge
node_btrfs_reserved_bytes{block_group_type="data",uuid="0abb23a9-579b-43e6-ad30-227ef47fcb9d"} 0

8
collector/fixtures/sys.ttar

@ -4489,6 +4489,14 @@ Lines: 1
4096
Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/fs/btrfs/0abb23a9-579b-43e6-ad30-227ef47fcb9d/commit_stats
Lines: 4
commits 258051
last_commit_ms 1000
max_commit_ms 51462
total_commit_ms 47836090EOF
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/fs/btrfs/0abb23a9-579b-43e6-ad30-227ef47fcb9d/devices
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Loading…
Cancel
Save