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

lambda-promtail getUnixSecNsec does not handle nanoseconds with leading zeros #15763

Open
zephyap opened this issue Jan 15, 2025 · 1 comment

Comments

@zephyap
Copy link

zephyap commented Jan 15, 2025

Describe the bug
The getUnixSecNsec function in tools/lambda-promtail/s3.go does not properly parse timestamp strings where the number of nanoseconds is low i.e. there are leading zeros in the nanosecond part of the string

To Reproduce
Add the following test case to TestGetUnixSecNsec in tools/lambda-promtail/s3_test.go

{
	name: "timestamp_in_nanoseconds_single_digit",
	args: args{
		s: "1234567890000000009",
	},
	expectedSec:  1234567890,
	expectedNsec: 9,
	wantErr:      false,
},

Expected behavior
Above test case should pass, but instead it returns a value of 900000000 for nsec

Environment:
N/A

Screenshots, Promtail config, or terminal output
N/A

@zephyap
Copy link
Author

zephyap commented Jan 15, 2025

I ran into this when writing a custom parser, so I have a fix that I can contribute! But I wanted to check first if my understanding of the function's intended behaviour is correct

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

No branches or pull requests

1 participant