-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 container uptime_ns may be negative #6615
Comments
I just noticed that while the positive values increase over time, the negative values remain the same over time. |
Can you run |
Here it is, i ran it inside the container that is running
|
You can see that most of the negative figures i gave in the first post are still the same in the |
Let's check what docker has to say about the container, can you run this curl command to grab the raw source data? Make sure to substitute a container_id that is reporting the negative uptime:
|
Here is the
And the {
"Id": "1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10",
"Created": "2019-09-04T14:46:56.32347611Z",
"Path": "/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 6071,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-11-06T16:00:05.099844819Z",
"FinishedAt": "2019-11-06T16:00:04.624365805Z",
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2019-11-07T08:34:10.45579616+08:00",
"End": "2019-11-07T08:34:10.689659949+08:00",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2019-11-07T08:37:30.69951039+08:00",
"End": "2019-11-07T08:37:30.969858721+08:00",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2019-11-07T08:40:50.988528916+08:00",
"End": "2019-11-07T08:40:51.242986708+08:00",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2019-11-07T08:44:11.261928719+08:00",
"End": "2019-11-07T08:44:11.530576021+08:00",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2019-11-07T08:47:31.537824342+08:00",
"End": "2019-11-07T08:47:31.787807519+08:00",
"ExitCode": 0,
"Output": ""
}
]
}
},
"Image": "sha256:bffed2f1e11ca465e82ccfab6731c64477e4c0ecc5788180be5e8387548f31ec",
"ResolvConfPath": "/var/lib/docker/containers/1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10/hostname",
"HostsPath": "/var/lib/docker/containers/1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10/hosts",
"LogPath": "/var/lib/docker/containers/1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10/1543aca673015b79ce6cb16e27c5aad6ca33699bbc4949738fa93ef5c2a86d10-json.log",
"Name": "/plex",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/etc/timezone:/etc/timezone:ro",
"/home/groebroeck/opt/appdata/plex:/config:rw",
"/mnt/nas:/data:rw",
"71351a260157765e5442e62d30e33d452cf0ac6d8703fbe593666994eaf404d6:/transcode:rw"
],
"ContainerIDFile": "",
"LogConfig": { "Type": "json-file", "Config": {} },
"NetworkMode": "host",
"PortBindings": {},
"RestartPolicy": { "Name": "unless-stopped", "MaximumRetryCount": 0 },
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [0, 0],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/b4fac527b2f082d88f169254223e5c85685586ab2e23e5ea293b985a16732d49-init/diff:/var/lib/docker/overlay2/3e7aabe3fe8e5d46729d3cfb59351798ab5703913446364557ab294a41c4ac77/diff:/var/lib/docker/overlay2/bccddc92fa08e9d3b17ad328026c0948deb7782f7964422454cf4ea34d0d9cd5/diff:/var/lib/docker/overlay2/cfb47db39b48f7b342fcd11dd50692080a9398fb15c561514f5ae894439dafed/diff:/var/lib/docker/overlay2/f8c8f4e267ab1145284bc2ba4424725a4c8bd70f402922c8cd71ad839331d4cb/diff:/var/lib/docker/overlay2/bcc8552066124f332ea4bc4c87eaa3d2ead9509621935ec83ad98a7714d73a5e/diff:/var/lib/docker/overlay2/6aa48e5f4699d4136bc15b2958b576813acc97a245c27a2c147f80f47dadc5ff/diff:/var/lib/docker/overlay2/d78c3cb14ec6a848245ec2269028b210d69feeac87c6c7a8fbb253fce2f47cb4/diff",
"MergedDir": "/var/lib/docker/overlay2/b4fac527b2f082d88f169254223e5c85685586ab2e23e5ea293b985a16732d49/merged",
"UpperDir": "/var/lib/docker/overlay2/b4fac527b2f082d88f169254223e5c85685586ab2e23e5ea293b985a16732d49/diff",
"WorkDir": "/var/lib/docker/overlay2/b4fac527b2f082d88f169254223e5c85685586ab2e23e5ea293b985a16732d49/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/etc/timezone",
"Destination": "/etc/timezone",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "71351a260157765e5442e62d30e33d452cf0ac6d8703fbe593666994eaf404d6",
"Source": "/var/lib/docker/volumes/71351a260157765e5442e62d30e33d452cf0ac6d8703fbe593666994eaf404d6/_data",
"Destination": "/transcode",
"Driver": "local",
"Mode": "rw",
"RW": true,
"Propagation": ""
},
{
"Type": "bind",
"Source": "/home/groebroeck/opt/appdata/plex",
"Destination": "/config",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/mnt/nas",
"Destination": "/data",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "leon",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"1900/udp": {},
"3005/tcp": {},
"32400/tcp": {},
"32410/udp": {},
"32412/udp": {},
"32413/udp": {},
"32414/udp": {},
"32469/tcp": {},
"8324/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PLEX_UID=1000",
"PLEX_GID=1000",
"affinity:container==e1e46acb3a2c771cf22f9ef5aea9efebed89590555ef9d56abbc84ce4a3bd1a8",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm",
"LANG=C.UTF-8",
"LC_ALL=C.UTF-8",
"CHANGE_CONFIG_DIR_OWNERSHIP=true",
"HOME=/config"
],
"Cmd": null,
"Healthcheck": {
"Test": ["CMD-SHELL", "/healthcheck.sh || exit 1"],
"Interval": 200000000000,
"Timeout": 100000000000
},
"Image": "plexinc/pms-docker:plexpass",
"Volumes": {
"/config": {},
"/data": {},
"/etc/timezone": {},
"/transcode": {}
},
"WorkingDir": "",
"Entrypoint": ["/init"],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "dafa1d2ee5a7083fff798b61d800fe605106b43553ec905c8cfcbedff22fc20a",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "lsio",
"com.docker.compose.service": "plex",
"com.docker.compose.version": "1.23.2",
"com.ouroboros.enable": "True"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "8231c2a79edddd7a73db75cf46634e4301538e50cdcfb02abcc911e0e6221158",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "39807ac7201d7f0ea1d100f05602cb28b7083d1bef12a9b48bfd23a25975d56c",
"EndpointID": "b3d8b744be22feca2800f562e00ea04cb8b28334b54d3f3c076d071ea8f000a7",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
|
I think I know the issue. The values we are using for uptime are:
Normally, I see this for a running container. In the code we check if the FinishedAt is this particular value and if so we ignore it and instead use the current time when calculating the time difference.
It looks like if we
For the fix I think we just need to ignore the FinishedAt time when the container is not exited. |
Relevant telegraf.conf:
System info:
Telegraf v1.12.4 running inside Docker on Ubuntu 19.04
Steps to reproduce:
Expected behavior:
docker_container_status
.uptime_ns
should be positive.Actual behavior:
For some containers,
docker_container_status
.uptime_ns
is negative.Additional info:
I have 23 containers running, and 7 of them have a negative uptime.
Here is a list of the uptimes extracted from Chronograf:
The text was updated successfully, but these errors were encountered: