[Docker Plugin] add server hostname for each docker measurements (#1599)
* add server hostname for each docker measurements * update CHANGELOG * move feature to v1.1 * tweak docker_engine_host tag
This commit is contained in:
parent
50ef3282b6
commit
49ea4e9f39
|
@ -15,6 +15,7 @@
|
||||||
- [#1539](https://github.com/influxdata/telegraf/pull/1539): Added capability to send metrics through Http API for OpenTSDB.
|
- [#1539](https://github.com/influxdata/telegraf/pull/1539): Added capability to send metrics through Http API for OpenTSDB.
|
||||||
- [#1471](https://github.com/influxdata/telegraf/pull/1471): iptables input plugin.
|
- [#1471](https://github.com/influxdata/telegraf/pull/1471): iptables input plugin.
|
||||||
- [#1542](https://github.com/influxdata/telegraf/pull/1542): Add filestack webhook plugin.
|
- [#1542](https://github.com/influxdata/telegraf/pull/1542): Add filestack webhook plugin.
|
||||||
|
- [#1599](https://github.com/influxdata/telegraf/pull/1599): Add server hostname for each docker measurements.
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ type Docker struct {
|
||||||
PerDevice bool `toml:"perdevice"`
|
PerDevice bool `toml:"perdevice"`
|
||||||
Total bool `toml:"total"`
|
Total bool `toml:"total"`
|
||||||
|
|
||||||
client DockerClient
|
client DockerClient
|
||||||
|
engine_host string
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerClient interface, useful for testing
|
// DockerClient interface, useful for testing
|
||||||
|
@ -147,6 +148,7 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
d.engine_host = info.Name
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"n_cpus": info.NCPU,
|
"n_cpus": info.NCPU,
|
||||||
|
@ -159,11 +161,11 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
|
||||||
// Add metrics
|
// Add metrics
|
||||||
acc.AddFields("docker",
|
acc.AddFields("docker",
|
||||||
fields,
|
fields,
|
||||||
nil,
|
map[string]string{"engine_host": d.engine_host},
|
||||||
now)
|
now)
|
||||||
acc.AddFields("docker",
|
acc.AddFields("docker",
|
||||||
map[string]interface{}{"memory_total": info.MemTotal},
|
map[string]interface{}{"memory_total": info.MemTotal},
|
||||||
map[string]string{"unit": "bytes"},
|
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
|
||||||
now)
|
now)
|
||||||
// Get storage metrics
|
// Get storage metrics
|
||||||
for _, rawData := range info.DriverStatus {
|
for _, rawData := range info.DriverStatus {
|
||||||
|
@ -177,7 +179,7 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
|
||||||
// pool blocksize
|
// pool blocksize
|
||||||
acc.AddFields("docker",
|
acc.AddFields("docker",
|
||||||
map[string]interface{}{"pool_blocksize": value},
|
map[string]interface{}{"pool_blocksize": value},
|
||||||
map[string]string{"unit": "bytes"},
|
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
|
||||||
now)
|
now)
|
||||||
} else if strings.HasPrefix(name, "data_space_") {
|
} else if strings.HasPrefix(name, "data_space_") {
|
||||||
// data space
|
// data space
|
||||||
|
@ -192,13 +194,13 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
|
||||||
if len(dataFields) > 0 {
|
if len(dataFields) > 0 {
|
||||||
acc.AddFields("docker_data",
|
acc.AddFields("docker_data",
|
||||||
dataFields,
|
dataFields,
|
||||||
map[string]string{"unit": "bytes"},
|
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
|
||||||
now)
|
now)
|
||||||
}
|
}
|
||||||
if len(metadataFields) > 0 {
|
if len(metadataFields) > 0 {
|
||||||
acc.AddFields("docker_metadata",
|
acc.AddFields("docker_metadata",
|
||||||
metadataFields,
|
metadataFields,
|
||||||
map[string]string{"unit": "bytes"},
|
map[string]string{"unit": "bytes", "engine_host": d.engine_host},
|
||||||
now)
|
now)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -225,6 +227,7 @@ func (d *Docker) gatherContainer(
|
||||||
imageVersion = imageParts[1]
|
imageVersion = imageParts[1]
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
|
"engine_host": d.engine_host,
|
||||||
"container_name": cname,
|
"container_name": cname,
|
||||||
"container_image": imageName,
|
"container_image": imageName,
|
||||||
"container_version": imageVersion,
|
"container_version": imageVersion,
|
||||||
|
|
|
@ -400,7 +400,7 @@ func TestDockerGatherInfo(t *testing.T) {
|
||||||
"n_images": int(199),
|
"n_images": int(199),
|
||||||
"n_goroutines": int(39),
|
"n_goroutines": int(39),
|
||||||
},
|
},
|
||||||
map[string]string{},
|
map[string]string{"engine_host": "absol"},
|
||||||
)
|
)
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t,
|
acc.AssertContainsTaggedFields(t,
|
||||||
|
@ -411,7 +411,8 @@ func TestDockerGatherInfo(t *testing.T) {
|
||||||
"available": int64(36530000000),
|
"available": int64(36530000000),
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "bytes",
|
"unit": "bytes",
|
||||||
|
"engine_host": "absol",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
acc.AssertContainsTaggedFields(t,
|
acc.AssertContainsTaggedFields(t,
|
||||||
|
@ -425,6 +426,7 @@ func TestDockerGatherInfo(t *testing.T) {
|
||||||
"container_image": "quay.io/coreos/etcd",
|
"container_image": "quay.io/coreos/etcd",
|
||||||
"cpu": "cpu3",
|
"cpu": "cpu3",
|
||||||
"container_version": "v2.2.2",
|
"container_version": "v2.2.2",
|
||||||
|
"engine_host": "absol",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
acc.AssertContainsTaggedFields(t,
|
acc.AssertContainsTaggedFields(t,
|
||||||
|
@ -467,6 +469,7 @@ func TestDockerGatherInfo(t *testing.T) {
|
||||||
"container_id": "b7dfbb9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296e2173",
|
"container_id": "b7dfbb9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296e2173",
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
|
"engine_host": "absol",
|
||||||
"container_name": "etcd2",
|
"container_name": "etcd2",
|
||||||
"container_image": "quay.io/coreos/etcd",
|
"container_image": "quay.io/coreos/etcd",
|
||||||
"container_version": "v2.2.2",
|
"container_version": "v2.2.2",
|
||||||
|
|
Loading…
Reference in New Issue