Cherry-pick #24318 to 7.x: Fix event time calculation on docker events #24320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #24318 to 7.x branch. Original message:
What does this PR do?
This PR fixes how
lastValidTimestamp
is calculated based on the event's time we get from docker API.Docker events are reported like:
time
andtimeNano
report the same timestamp but with different accuracy.In this, we should only use
Time
orTimeNano
but not together, otherwise it will result in a timestamp points to the future which will lead to not valid restarts of the watcher atbeats/libbeat/common/docker/watcher.go
Line 267 in ce0b159
--since
flag will point to the future making it unable to catch any events from that time on.Why is it important?
To be able to recover from restarts like when
docker
daemon is getting restarted.How to manually test this PR
NOTE: verify that log's path is valid on your system. If not check if
/var/lib/docker/containers/*/*${data.container.id}*.log
is the valid path.2. run a dummy container:
docker run --restart=always --name test42 -d busybox sh -c "while true; do $(echo date); sleep 1; done"
3. Verify logs flow in ES
3. Restart the docker daemon with
sudo systemctl restart docker
4. Verify that logs keep flowing in ES after the restart
Logs