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

feat: Support configuring behavior of loki.source.syslog setting the year of an incoming timestamp #2755

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

dehaansa
Copy link
Contributor

@dehaansa dehaansa commented Feb 19, 2025

PR Description

Add a new configuration setting to the loki.source.syslog configuration rfc3164_default_to_current_year that allows users to set the year of an incoming timestamp to the current year in local time. The existing behavior is to leave the year at 0 (this behavior comes from promtail).

This PR also moves any remaining promtail code for syslog into Alloy, as promtail is now officially deprecated as of Loki 3.4.

Which issue(s) this PR fixes

Fixes #2287

Notes to the Reviewer

This is currently pointing to the develop branch of go-syslog, we may want to wait for a release before merging this.

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

Copy link
Contributor

github-actions bot commented Feb 19, 2025

@dehaansa
Copy link
Contributor Author

It appears this is a breaking change to the go-syslog library, and as otel's syslog receiver depends on that library as well as loki, there are build issues to work out, this may have to wait to be merged until it's released & otel integrates & releases with it.

@Nachtfalkeaw
Copy link

Imagine the Situation where a remote system Stores its logs until loki.source.syslog is available after an outage and then sends its old logs from december 2024-12-31 23:00 to alloy which is in 2025-01-01 01:00. This will results in wrong year? Or Log to far in Future?

another Situation maybe could be time Zone shifts, right?

Don't know a solution right now and this is a rare Situation i think.

@dehaansa
Copy link
Contributor Author

dehaansa commented Feb 19, 2025

Imagine the Situation where a remote system Stores its logs until loki.source.syslog is available after an outage and then sends its old logs from december 2024-12-31 23:00 to alloy which is in 2025-01-01 01:00. This will results in wrong year? Or Log to far in Future?

another Situation maybe could be time Zone shifts, right?

Don't know a solution right now and this is a rare Situation i think.

That's correct. It's a hard problem to solve, but we could add a different year behavior to the go-syslog machine to use current year, but then if the resulting timestamp is nearly a year in the future, reduce the year by 1. There's definitely no perfect solution to the problem of not having a precise enough timestamp.

Edit: went to look at implementing a YearOperator from go-syslog and it doesn't have the ability to modify a specific message's parsing. We would need to put this behavior directly into Alloy after using the syslog parser instead, which should be fine. At that point we wouldn't need the changes to go-syslog at all. 🙃

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Feb 24, 2025
@clayton-cornell
Copy link
Contributor

Docs look OK

}
}

if b == '<' {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this pulled from somewhere or maybe documented as a magic number? An example of what the stream would look like may help here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied straight from promtail, but I'll add some comments.

@dehaansa dehaansa requested a review from mattdurham February 26, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Docs Squad label across all Grafana Labs repos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loki.source.syslog rfc3164 - timestamp not parsed
4 participants