-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix event time calculation on docker events #24318
Conversation
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks for the fix!
libbeat/common/docker/watcher.go
Outdated
@@ -276,7 +276,7 @@ func (w *watcher) watch() { | |||
select { | |||
case event := <-events: | |||
w.log.Debugf("Got a new docker event: %v", event) | |||
lastValidTimestamp = time.Unix(event.Time, event.TimeNano) | |||
lastValidTimestamp = time.Unix(0, event.TimeNano) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one 👍
Pinging @elastic/integrations (Team:Integrations) |
Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
(cherry picked from commit 8b673e6)
(cherry picked from commit 8b673e6)
(cherry picked from commit 8b673e6)
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