Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Input Plugin Measure Thin Pool Minimum Free Space #6084

Merged
merged 10 commits into from
Jul 15, 2019
Merged
5 changes: 5 additions & 0 deletions plugins/inputs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
map[string]interface{}{"pool_blocksize": value},
tags,
now)
} else if name == "thin_pool_minimum_free_space" {
acc.AddFields("docker_thin_pool",
map[string]interface{}{"minimum_free_space": value},
tags,
now)
} else if strings.HasPrefix(name, "data_space_") {
// data space
fieldName := strings.TrimPrefix(name, "data_space_")
Expand Down
50 changes: 50 additions & 0 deletions plugins/inputs/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,29 @@ func TestDockerGatherInfo(t *testing.T) {
},
)

acc.AssertContainsTaggedFields(t,
"docker",
map[string]interface{}{
"memory_total": int64(3840757760),
},
map[string]string{
"engine_host": "absol",
"server_version": "17.09.0-ce",
},
)

acc.AssertContainsTaggedFields(t,
"docker",
map[string]interface{}{
"pool_blocksize": int64(65540),
},
map[string]string{
"engine_host": "absol",
"server_version": "17.09.0-ce",
"unit": "bytes",
},
)

acc.AssertContainsTaggedFields(t,
"docker_data",
map[string]interface{}{
Expand All @@ -710,11 +733,38 @@ func TestDockerGatherInfo(t *testing.T) {
"available": int64(36530000000),
},
map[string]string{
"engine_host": "absol",
"server_version": "17.09.0-ce",
"unit": "bytes",
},
)

acc.AssertContainsTaggedFields(t,
"docker_metadata",
map[string]interface{}{
"used": int64(20970000),
"total": int64(2146999999),
"available": int64(2126999999),
},
map[string]string{
"engine_host": "absol",
"server_version": "17.09.0-ce",
"unit": "bytes",
},
)

acc.AssertContainsTaggedFields(t,
"docker_thin_pool",
map[string]interface{}{
"minimum_free_space": int64(10740000000),
},
map[string]string{
"engine_host": "absol",
"server_version": "17.09.0-ce",
"unit": "bytes",
},
)

acc.AssertContainsTaggedFields(t,
"docker_container_cpu",
map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/docker/docker_testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var info = types.Info{
HTTPSProxy: "",
Labels: []string{},
MemoryLimit: false,
DriverStatus: [][2]string{{"Pool Name", "docker-8:1-1182287-pool"}, {"Pool Blocksize", "65.54 kB"}, {"Backing Filesystem", "extfs"}, {"Data file", "/dev/loop0"}, {"Metadata file", "/dev/loop1"}, {"Data Space Used", "17.3 GB"}, {"Data Space Total", "107.4 GB"}, {"Data Space Available", "36.53 GB"}, {"Metadata Space Used", "20.97 MB"}, {"Metadata Space Total", "2.147 GB"}, {"Metadata Space Available", "2.127 GB"}, {"Udev Sync Supported", "true"}, {"Deferred Removal Enabled", "false"}, {"Data loop file", "/var/lib/docker/devicemapper/devicemapper/data"}, {"Metadata loop file", "/var/lib/docker/devicemapper/devicemapper/metadata"}, {"Library Version", "1.02.115 (2016-01-25)"}},
DriverStatus: [][2]string{{"Pool Name", "docker-8:1-1182287-pool"}, {"Pool Blocksize", "65.54 kB"}, {"Backing Filesystem", "extfs"}, {"Data file", "/dev/loop0"}, {"Metadata file", "/dev/loop1"}, {"Data Space Used", "17.3 GB"}, {"Data Space Total", "107.4 GB"}, {"Data Space Available", "36.53 GB"}, {"Metadata Space Used", "20.97 MB"}, {"Metadata Space Total", "2.147 GB"}, {"Metadata Space Available", "2.127 GB"}, {"Udev Sync Supported", "true"}, {"Deferred Removal Enabled", "false"}, {"Data loop file", "/var/lib/docker/devicemapper/devicemapper/data"}, {"Metadata loop file", "/var/lib/docker/devicemapper/devicemapper/metadata"}, {"Library Version", "1.02.115 (2016-01-25)"}, {"Thin Pool Minimum Free Space", "10.74GB"}},
NFd: 19,
HTTPProxy: "",
Driver: "devicemapper",
Expand Down