Add container_id field to docker_container_status metrics (#6019)

This commit is contained in:
masuyama-ascade 2019-06-22 04:20:35 +09:00 committed by Daniel Nelson
parent 587dd149f3
commit e6d71bdb65
3 changed files with 31 additions and 3 deletions

View File

@ -273,6 +273,7 @@ status if configured.
- container_status
- container_version
- fields:
- container_id
- oomkilled (boolean)
- pid (integer)
- exitcode (integer)

View File

@ -466,6 +466,7 @@ func (d *Docker) gatherContainerInspect(
"oomkilled": info.State.OOMKilled,
"pid": info.State.Pid,
"exitcode": info.State.ExitCode,
"container_id": container.ID,
}
finished, err := time.Parse(time.RFC3339, info.State.FinishedAt)

View File

@ -756,6 +756,32 @@ func TestDockerGatherInfo(t *testing.T) {
"container_status": "running",
},
)
acc.AssertContainsTaggedFields(t,
"docker_container_status",
map[string]interface{}{
"container_id": "b7dfbb9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296e2173",
"exitcode": int(0),
"oomkilled": false,
"pid": int(1234),
"started_at": int64(1528955333266176036),
//"finished_at": float64(0),
},
map[string]string{
"engine_host": "absol",
"container_name": "etcd2",
"container_image": "quay.io:4443/coreos/etcd",
"container_version": "v2.2.2",
"ENVVAR1": "loremipsum",
"ENVVAR2": "dolorsitamet",
"ENVVAR3": "=ubuntu:10.04",
"ENVVAR7": "ENVVAR8=ENVVAR9",
"label1": "test_value_1",
"label2": "test_value_2",
"server_version": "17.09.0-ce",
"container_status": "running",
},
)
}
func TestDockerGatherSwarmInfo(t *testing.T) {