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

There is no ability to use MachineOptions (WithYear) with nontransparent/octetcounting parsers #21

Open
dehaansa opened this issue Dec 31, 2024 · 2 comments · May be fixed by #23
Open
Assignees

Comments

@dehaansa
Copy link

dehaansa commented Dec 31, 2024

This library is used in grafana/loki and then that code is used within grafana/alloy as well, and a user encountered an issue with the default 0'd out year with a RFC3164 message grafana/alloy#2287 . I went to go update the loki code to use the WithYear/CurrentYear option but that code uses the nontransparent & octetcounting parsers, rather than the rfc3164 & rfc5424 parsers.

I would propose updating the parsers to support these options. I think an ideal world would unify the With to no longer have separate ParserOption & MachineOption function types, but at least support for WithYear in the other parsers would unblock these changes.

@leodido leodido self-assigned this Jan 25, 2025
@leodido
Copy link
Owner

leodido commented Jan 25, 2025

Hi @dehaansa, let me see if I understood correctly.

The problem grafana/alloy is facing is not being able to parse syslog messages (using either octet-counting or non-transparent framing) using a WithYear(CurrentYear{}) option strategy.

You folks need something like this but for non-transparent & octet counting parsers... Correct?

p := NewParser(WithYear(CurrentYear{}))

@dehaansa
Copy link
Author

dehaansa commented Jan 26, 2025

Hi @dehaansa, let me see if I understood correctly.

The problem grafana/alloy is facing is not being able to parse syslog messages (using either octet-counting or non-transparent framing) using a WithYear(CurrentYear{}) option strategy.

You folks need something like this but for non-transparent & octet counting parsers... Correct?

go-syslog/rfc3164/example_test.go

Line 41 in 46afcec

p := NewParser(WithYear(CurrentYear{}))

Yup, that's exactly right. When I wrap up some other tasks I intend to come back and implement it, if no one else takes a look at it first. Thanks.

EDIT: Just saw that you opened a PR! Looks right, will validate next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants