Support for mTLS in Loki Hook #1289
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 project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
borgmatic-collective/borgmatic#1289
Loading…
Add table
Add a link
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'd like to do and why
Grafana Loki does not come with any included authentication layer (doc) and relies on reverse proxies, effectively suggesting the use of basic auth, which can be used today in Borgmatic by doing things like this in URL :
https://{loki_user}:{loki_password}@{loki_url}/loki/api/v1/pushIf we want to go further we could use mTLS instead. In this setup, the client must present a certificate and a private key to the reverse proxy to be authorized.
Currently, Borgmatic's Loki hook does not provide a way to pass these TLS credentials, making it impossible to send logs to a Loki instance protected by mTLS.
Other notes / implementation ideas
I have tested a local modification of
hooks/monitoring/loki.pythat implements this feature using the cert parameter of the requests library. It works as expected in my mTLS environment.I'm providing this file, just for checking.
I haven't opened a PR (yet ?) because I'm not sure about the best way to implement this. It might make more sense to implement this at another level rather than just for my specific Loki use case.
Feature: support for mTLS in Loki Hookto Support for mTLS in Loki HookThanks for filing this. I had a look at your changes, and the general approach makes sense to me. I do think they make sense to do at this level, rather than, say, in some sort of generalized way that's not specific to the Loki hook. I will say that I'm not wild about the existing design of
Loki_log_bufferinsofar as it's a little OOPier than I'd like, but that well predates any of your changes. (And if it bothers me enough, I can always refactor after.) So if you're up to do a PR for this, that would be great.Couple of minor points of pre-feedback though:
schema.yamlchanges to, which I assume you've already done separately.tls_optionsjusttls, as everything in the schema is an option!Also be aware of #1199, a related feature!
PR is up. Renamed
tls_optionstotlsand updated cert filenames options too.Docs are updated, I'll leave the versioning to you.
Implemented in main (by @maxhamon) and will be part of the next release. Thanks again!
Released in borgmatic 2.1.5!