Skip to content

Container uptime can differ from docker ps statistics  #1607

Closed
@Mr-Right2

Description

@Mr-Right2

When I use the container_start_time_seconds metric to substract it from the current time, I expect this to be equal to the container uptime as can be obtained from running docker ps.

However, I've noticed that this is not the case. When I create (for example) the following alert:
(time() - container_start_time_seconds{image!="",id=~"^/docker.*",name="mongodb"} ) < 60

I receive alert from time to time that my container restarted. When I look at the output of docker ps, I see that the container did not crash or restart at all.

For example, the current output of docker ps:

CONTAINER ID    IMAGE                         COMMAND                  CREATED       STATUS        PORTS                                                              NAMES
b3bf5be016b3    nginx:1.9.9                   "nginx -g 'daemon off"   2 weeks ago   Up 2 weeks    80/tcp, 0.0.0.0:9000->9000/tcp, 443/tcp, 0.0.0.0:9100->9100/tcp    nginx-metrics
13e57876fb6a    google/cadvisor:v0.24.1       "/usr/bin/cadvisor -l"   2 weeks ago   Up 2 weeks    8080/tcp                                                           cadvisor
89640d57f4a0    prom/node-exporter:v0.13.0    "/bin/node_exporter"     2 weeks ago   Up 2 weeks    9100/tcp                                                           node-exporter
c5b90ebe790f    mongo:3.2.9                   "/entrypoint.sh mongo"   2 weeks ago   Up 2 weeks    127.0.0.1:27017->27017/tcp                                         mongodb

And the current value of time() - container_start_time_seconds for these containers:
containers

I'm using:
cAdvisor version v0.24.1
Docker version 1.12.1 (build 23cf638)
Docker-compose version 1.8.0 (build f3628c7)

I wonder if this is a known bug, or if it might be possible to use and include the container uptime information from the docker stats, e.g. the same information as shown by from sudo docker inspect --format='{{.State.StartedAt}}' cadvisor

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions