Skip to content
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

[Bug / Feature request] Dockers api for container log download only accepts unix timestamps (int) for the 'since' parameter #41784

Open
derteufelqwe opened this issue Dec 12, 2020 · 1 comment
Labels
area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Comments

@derteufelqwe
Copy link

Description
Dockers container log download command has the option to specify from which timestamp beginning, it should show the logs, which supports unix timestamps with milliseconds, but the docker api only supports unix timestamps without milliseconds.

Explanation
An example line from docker logs --timestamps looks like this
2020-12-12T22:06:40.055209477Z [22:06:40 INFO]: Timings Reset. The timestamp in the beginning also displays microseconds (055209477).
Dockers command docker container logs --since supports unix timestamps with microseconds.
The docker engine on the other hand only supports unix timestamps without microseconds, as it only accepts an integer value, which can't store milliseconds or even microseconds. (https://docs.docker.com/engine/api/v1.41/#operation/ContainerLogs)
This results in sometimes inaccurate results.

Problems
You can't precisely download logs beginning from a certain timestamp through the api, because you cant send milliseconds to the docker api, which you would need to get correct results.

How to reproduce the problem
Start a container and execute docker logs --timestamps and convert the timestamp of the last log line to unix time (while doing so you will lose information about the microseconds of the log)
Then download the logs of that container using the api and set the 'since' parameter to the previously converted unix timestamp.
The first few lines will container log messages, which you have already gotten from the first docker logs command.

@thaJeztah thaJeztah added area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Jan 21, 2021
@fopinappb
Copy link

I was having the same issue but when I checked docker CLI, using the time string returned by the logs worked with the expected precision

docker logs -t --since '2021-04-19T10:03:24.080312522Z' d18d

checking the request made to dockerd

GET /v1.41/containers/d../logs?since=1618826604.080312522&stderr=1&stdout=1&tail=all&timestamps=1 HTTP/1.1

it seems documentation still mentions int but it supports float (and the required precision to tail a log in different calls)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

No branches or pull requests

3 participants