-
Notifications
You must be signed in to change notification settings - Fork 55
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(logfwd): support forwarding logs to Loki #267
Conversation
e4ce26c
to
8f820a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
7f4697c
to
91366c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly questions for my own understanding, and perhaps something you can find useful.
c891b95
to
3e47aa7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Left a whole bunch of comments -- they're all minor though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm @barrettj12, just some comments for your consideration.
71ce438
to
f56d4ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gentlemen, it looks like some of the lines have been blurred with this PR. I was optimistic that we'd have a nice and sweet PR since this was just implementing the Loki client, but instead this went back into the behavior that we have agreed to over the past few weeks and changed it, which unfortunately makes me ask questions about things that we had agreements on instead of it being a happy walk.
Would it be possible to do a bit less in this PR, and implement a simpler Loki client using the APIs that we had already settled on? I realize that's probably not great news from your end, so maybe have a look at these comments with a cup of tee and let me know what I got wrong?
- introduce loki.ClientArgs - remove loki testing patch functions
Just did a test pushing 2000 logs/sec at Pebble, with a fake Loki server always returning 429. It used about 10% of my laptop's CPU dealing with this, but the memory seemed to stay bounded at 0.1%. So I don't think we have an issue here with memory leaking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of very nitty comments, but looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel like we are finally at the end of this long road. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, Jordan. Thanks for your persistence.
- ClientArgs -> options *ClientOptions - rename N -> n - explicitly reallocate buffer when full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, final points on that same issue, and we should be good to go:
- inline checkBuffer - coerce to string w/o check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! There's still a minor related to the on going conversations, but per note below. Let's please address it in a future PR.
// resetBuffer drops all buffered logs (in the case of a successful send, or an | ||
// unrecoverable error). | ||
func (c *Client) resetBuffer() { | ||
c.entries = c.entries[:0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the same issue of entries not being released here.
I'll go ahead and merge this as we've been here for a bit :), but let's please fix this at the next opportunity.
Add a
loki.Client
type that encodes sends Pebble logs to Loki. This implements thelogstate.logClient
interface introduced in #256.There have also been some changes to the
logClient
interface. Semantically, clients shouldn't flush inside theWrite
method - the flush should be up to the gatherer. RenameWrite
toAddLog
for clarity, and add aNumBuffered
method to help the gatherer determine when to flush.QA steps
Deploy a Loki server for testing - this can be done with Juju. For convenience, deploy Grafana too, to view the logs.
Wait for Loki and Grafana to reach a stable state.
Create a simple logging service:
and a simple plan using this service:
[loki_ip]
is the unit/app IP address from the deployed Loki injuju status
.Run Pebble:
Get the admin password for Grafana using
and then visit
[grafana_ip]:3000
in a browser, and log in with usernameadmin
and the obtained password.If you go to the "Explore" tab and change the data source to Loki, you should be able to see logs forwarded from Pebble.
JUJU-4205