@@ -391,12 +391,13 @@ func (d *Docker) gatherContainer(
391
391
}
392
392
}
393
393
394
+ info , err := d .client .ContainerInspect (ctx , container .ID )
395
+ if err != nil {
396
+ return fmt .Errorf ("Error inspecting docker container: %s" , err .Error ())
397
+ }
398
+
394
399
// Add whitelisted environment variables to tags
395
400
if len (d .TagEnvironment ) > 0 {
396
- info , err := d .client .ContainerInspect (ctx , container .ID )
397
- if err != nil {
398
- return fmt .Errorf ("Error inspecting docker container: %s" , err .Error ())
399
- }
400
401
for _ , envvar := range info .Config .Env {
401
402
for _ , configvar := range d .TagEnvironment {
402
403
dock_env := strings .SplitN (envvar , "=" , 2 )
@@ -408,6 +409,14 @@ func (d *Docker) gatherContainer(
408
409
}
409
410
}
410
411
412
+ if info .State .Health != nil {
413
+ healthfields := map [string ]interface {}{
414
+ "health_status" : info .State .Health .Status ,
415
+ "failing_streak" : info .ContainerJSONBase .State .Health .FailingStreak ,
416
+ }
417
+ acc .AddFields ("docker_container_health" , healthfields , tags , time .Now ())
418
+ }
419
+
411
420
gatherContainerStats (v , acc , tags , container .ID , d .PerDevice , d .Total , daemonOSType )
412
421
413
422
return nil
0 commit comments