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

journal reading: Timestamp too old errors #918

Closed
rfratto opened this issue Aug 19, 2019 · 0 comments · Fixed by #921
Closed

journal reading: Timestamp too old errors #918

rfratto opened this issue Aug 19, 2019 · 0 comments · Fixed by #921
Assignees
Labels
component/agent type/bug Somehing is not working as expected

Comments

@rfratto
Copy link
Member

rfratto commented Aug 19, 2019

Because the journal reader starts from the very beginning of the journal (i.e., not even the current boot, but the very first entry in the journal), promtail may end up sending extremely old logs to ingesters and getting errors back:

level=error ts=2019-08-19T18:59:05.693794932Z caller=client.go:185 component=client host=localhost:3100 msg="final error sending batch" status=400 error="server returned HTTP status 400 Bad Request (400): sample for 'logs' has timestamp too old: 1562712027507"

These errors will go away once the positions file is updated, but will still appear when a user uses journal reading in promtail for the first time.

To work around this, the journal config should be updated to support a new field called from that takes a relative timestamp:

- job_name: journal
  journal:
    # read entries no older than 6h 
    from: 6h 
    path: /var/log/journal
    labels:
      job: systemd-journal
  relabel_configs:
    - source_labels: ['__journal__systemd_unit']
      target_label: 'unit'

Implementation

With the from field present, the journal reader has to do the following:

  1. If a positions file is present:
  2. Get journal entry at cursor.
  3. If entry's date is older than the allowed time specified by from, use the from date to initialize the journal entry. Entries will be lost.
  4. If entry's date is newer than the allowed time specified by from, use the cursor as the start point. No entries will be lost.
  5. If no position file is present, just use the from date to initialize the journal reader. Old entries will not be imported into Loki.
@rfratto rfratto self-assigned this Aug 19, 2019
@chaudum chaudum added the type/bug Somehing is not working as expected label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/agent type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants