Skip to content

Commit bea0adb

Browse files
authored
Merge pull request google#1437 from micahhausler/inodes-metric
Add inodes to /metrics endpoint
2 parents cd360d6 + a9bb292 commit bea0adb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

metrics/prometheus.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,26 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc) *PrometheusCo
228228
},
229229
}
230230
},
231+
}, {
232+
name: "container_fs_inodes_free",
233+
help: "Number of available Inodes",
234+
valueType: prometheus.GaugeValue,
235+
extraLabels: []string{"device"},
236+
getValues: func(s *info.ContainerStats) metricValues {
237+
return fsValues(s.Filesystem, func(fs *info.FsStats) float64 {
238+
return float64(fs.InodesFree)
239+
})
240+
},
241+
}, {
242+
name: "container_fs_inodes_total",
243+
help: "Number of Inodes",
244+
valueType: prometheus.GaugeValue,
245+
extraLabels: []string{"device"},
246+
getValues: func(s *info.ContainerStats) metricValues {
247+
return fsValues(s.Filesystem, func(fs *info.FsStats) float64 {
248+
return float64(fs.Inodes)
249+
})
250+
},
231251
}, {
232252
name: "container_fs_limit_bytes",
233253
help: "Number of bytes that can be consumed by the container on this filesystem.",

metrics/prometheus_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ func (p testSubcontainersInfoProvider) SubcontainersInfo(string, *info.Container
130130
Filesystem: []info.FsStats{
131131
{
132132
Device: "sda1",
133+
InodesFree: 524288,
134+
Inodes: 2097152,
133135
Limit: 22,
134136
Usage: 23,
135137
ReadsCompleted: 24,
@@ -146,6 +148,8 @@ func (p testSubcontainersInfoProvider) SubcontainersInfo(string, *info.Container
146148
},
147149
{
148150
Device: "sda2",
151+
InodesFree: 262144,
152+
Inodes: 2097152,
149153
Limit: 37,
150154
Usage: 38,
151155
ReadsCompleted: 39,

metrics/testdata/prometheus_metrics

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ container_cpu_usage_seconds_total{container_env_foo_env="prod",container_label_f
2222
# HELP container_cpu_user_seconds_total Cumulative user cpu time consumed in seconds.
2323
# TYPE container_cpu_user_seconds_total counter
2424
container_cpu_user_seconds_total{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 6e-09
25+
# HELP container_fs_inodes_free Number of available Inodes
26+
# TYPE container_fs_inodes_free gauge
27+
container_fs_inodes_free{container_env_foo_env="prod",container_label_foo_label="bar",device="sda1",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 524288
28+
container_fs_inodes_free{container_env_foo_env="prod",container_label_foo_label="bar",device="sda2",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 262144
29+
# HELP container_fs_inodes_total Number of Inodes
30+
# TYPE container_fs_inodes_total gauge
31+
container_fs_inodes_total{container_env_foo_env="prod",container_label_foo_label="bar",device="sda1",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 2.097152e+06
32+
container_fs_inodes_total{container_env_foo_env="prod",container_label_foo_label="bar",device="sda2",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 2.097152e+06
2533
# HELP container_fs_io_current Number of I/Os currently in progress
2634
# TYPE container_fs_io_current gauge
2735
container_fs_io_current{container_env_foo_env="prod",container_label_foo_label="bar",device="sda1",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 42

0 commit comments

Comments
 (0)