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 Plugin] add server hostname for each docker measurements #1599

Merged
merged 5 commits into from
Sep 6, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tweak docker_engine_host tag
  • Loading branch information
aaronjheng committed Sep 6, 2016
commit e2e075b3453e578a1f64638727a9f5b65648a502
16 changes: 8 additions & 8 deletions plugins/inputs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Docker struct {
Total bool `toml:"total"`

client DockerClient
server_name string
engine_host string
}

// DockerClient interface, useful for testing
Expand Down Expand Up @@ -148,7 +148,7 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
if err != nil {
return err
}
d.server_name = info.Name
d.engine_host = info.Name

fields := map[string]interface{}{
"n_cpus": info.NCPU,
Expand All @@ -161,11 +161,11 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
// Add metrics
acc.AddFields("docker",
fields,
map[string]string{"server_name": d.server_name},
map[string]string{"engine_host": d.engine_host},
now)
acc.AddFields("docker",
map[string]interface{}{"memory_total": info.MemTotal},
map[string]string{"unit": "bytes", "server_name": d.server_name},
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
now)
// Get storage metrics
for _, rawData := range info.DriverStatus {
Expand All @@ -179,7 +179,7 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
// pool blocksize
acc.AddFields("docker",
map[string]interface{}{"pool_blocksize": value},
map[string]string{"unit": "bytes", "server_name": d.server_name},
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
now)
} else if strings.HasPrefix(name, "data_space_") {
// data space
Expand All @@ -194,13 +194,13 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
if len(dataFields) > 0 {
acc.AddFields("docker_data",
dataFields,
map[string]string{"unit": "bytes", "server_name": d.server_name},
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
now)
}
if len(metadataFields) > 0 {
acc.AddFields("docker_metadata",
metadataFields,
map[string]string{"unit": "bytes", "server_name": d.server_name},
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
now)
}
return nil
Expand All @@ -227,7 +227,7 @@ func (d *Docker) gatherContainer(
imageVersion = imageParts[1]
}
tags := map[string]string{
"server_name": d.server_name,
"engine_host": d.engine_host,
"container_name": cname,
"container_image": imageName,
"container_version": imageVersion,
Expand Down
8 changes: 4 additions & 4 deletions plugins/inputs/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func TestDockerGatherInfo(t *testing.T) {
"n_images": int(199),
"n_goroutines": int(39),
},
map[string]string{"server_name": "absol"},
map[string]string{"engine_host": "absol"},
)

acc.AssertContainsTaggedFields(t,
Expand All @@ -412,7 +412,7 @@ func TestDockerGatherInfo(t *testing.T) {
},
map[string]string{
"unit": "bytes",
"server_name": "absol",
"engine_host": "absol",
},
)
acc.AssertContainsTaggedFields(t,
Expand All @@ -426,7 +426,7 @@ func TestDockerGatherInfo(t *testing.T) {
"container_image": "quay.io/coreos/etcd",
"cpu": "cpu3",
"container_version": "v2.2.2",
"server_name": "absol",
"engine_host": "absol",
},
)
acc.AssertContainsTaggedFields(t,
Expand Down Expand Up @@ -469,7 +469,7 @@ func TestDockerGatherInfo(t *testing.T) {
"container_id": "b7dfbb9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296e2173",
},
map[string]string{
"server_name": "absol",
"engine_host": "absol",
"container_name": "etcd2",
"container_image": "quay.io/coreos/etcd",
"container_version": "v2.2.2",
Expand Down