Loki hook not sending logs #1152
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#1152
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
Using Borgmatic 2.0.8, I’m trying to send logs to my Loki instance, as I was able to do in version 2.0.7
Steps to reproduce
I have made a simple configuration file for testing
Actual behavior
Expected behavior
The hooks appear to be called, but no logs are received in Loki, like it was in 2.0.7 with the exact same configuration.
Other notes / implementation ideas
borgmatic version
2.0.8
borgmatic installation method
pip
Borg version
1.4.1
Python version
3.13.5
Database version (if applicable)
No response
Operating system and version
Debian 13
Thanks for filing this. The only change to the Loki hook itself in borgmatic 2.0.8 is that it now adds a user agent header to all outgoing Loki requests. I suppose it's possible there was some other logging change in 2.0.8 outside of the Loki hook that could impact this, although I'm not seeing anything obvious. In any case, have you tried invoking borgmatic with
--monitoring-verbosity 2to see if that changes anything?Also, if you have easy access to borgmatic's installed source on your machine, you could try modifying the Loki hook to remove the user agent header temporarily to see if that changes the behavior. You'll find that at
borgmatic/hooks/monitoring/loki.py, and you can try commenting out this line:I don’t see any difference when using
--monitoring-verbosity 2. I also tried removing the User-Agent, but it didn’t make much difference.The strange thing is that the last POST hitting my reverse proxy in front of Loki was when I tested with Borgmatic 2.0.7:
It seems like Borgmatic 2.0.8 isn’t sending any POST requests at all, I'll try to add some more verbose on my reverse proxy tomorrow.
Really interesting that it appears not to be sending requests at all. Yeah, if you could confirm that on your reverse proxy, that would be a good idea. Also, is that log you posted complete? Are there any log entries after
/root/test.yaml: https://loki.fqdn:443 "POST /loki/api/v1/push HTTP/1.1" 204 0or does it just end there? And how does this compare to the logs when running borgmatic 2.0.7? Do they get further?I've dug a bit deeper and I was wrong about the reverse proxy (the request is actually going through).
I added a tcpdump to inspect the traffic and noticed something strange in 2.0.8: the values field is empty (with or without the Borgmatic User-Agent).
2.0.8
2.0.7
I managed to send logs by playing around with self.root['streams'][0]['values'] = [] but I don’t fully understand how it works.
If I add
request_body = self.to_request()before flushing values it works !Excellent detective work! I think what's going on is that as part of the user agent change, I naively moved
self.to_request()to after the values are emptied out. Which means no values get sent now.Okay, a fix for this is implemented in main and will be part of the release! Thanks again.
Released in borgmatic 2.0.9!