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

Loki: Log a crude lag metric for how far behind a client is. #3236

Merged
merged 2 commits into from
Jan 28, 2021

Conversation

slim-bean
Copy link
Collaborator

Log the difference in time between the most recently received log entry and the current time as a crude measure of how far behind a client instance is.

…ry and the current time as a crude measure of how far behind a promtail instance is.
for _, s := range req.Streams {
streamLabelsSize += int64(len(s.Labels))
for _, e := range s.Entries {
totalEntries++
entriesSize += int64(len(e.Line))
if e.Timestamp.After(mostRecentEntry) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just look at the last entry for each stream instead ?

Copy link
Contributor

@cyriltovena cyriltovena Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if len(s.Entries) > 0 {
  last := s.Entries[len(s.Entries)-1].Timestamp
  if last.Timestamp.After(mostRecentEntry) {
    mostRecentEntry = last
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if/when we support out of order the current implementation would handle that a little better but I agree this is a better optimization for our current constraints

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need 5324aca to fix the build from #3237

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slim-bean slim-bean merged commit 51952da into master Jan 28, 2021
@slim-bean slim-bean deleted the log-most-recent-lag branch January 28, 2021 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants