Add support for healthchecks "log" feature #628
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#628
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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
I do not know exactly when, but i recently noticed, that Healthchecks.io introduced a feature where you can send logging information to Healthchecks.io without signalling success or failure. It would be great to add this feature to borgbackup.
Other notes / implementation ideas
My Idea was, that if you use the logging feature you can decide if you want your logs pushed to Healthchecks or if you just want to log success/failure. And if the attached Message for success/failure is not used then a user could use it for a custom message. This is imo especially useful for users having multiple backup configurations / run per-application backups.
Environment
borgmatic version: 1.7.5
borgmatic installation method: yay
Borg version: borg 1.2.3
Python version: Python 3.10.9
operating system and version: Linux x86_64 6.1.4-zen2-1-zen
Is this issue taken or can I work on this issue?
Nobody is working on this right now, so feel free to jump in! I'm not exactly sure on the design of this ticket, so it may be worth discussing your plans here before jumping into writing code. That may prevent some back and forth on an eventual pull request.
FYI, I think this is the Healthchecks feature mentioned in this ticket: https://healthchecks.io/docs/http_api/#log-uuid
Hey @Soumik_Dutta.. Just checking in. Have you had a chance to look into this? Let me know if there's anything I can do to help.
Hello,
Yes, I looked into the docs as you provided https://healthchecks.io/docs/http_api/#log-uuid, and I think the steps to implement will be :
borgmatic/hooks/monitor.py
addlog
to:borgmatic/hooks/healthchecks.py
addlog
level to:if
conditionborgmatic/config/schema.yaml
:So, now it has basic support for sending
payload
without signalling success or failure.However to trigger this, we have to add the snippet to
/home/sm/Public/Sock/borgmatic/borgmatic/commands/borgmatic.py
:I have tested the code with the above changes, and the logs are getting successfully logged in Healthcheck
I have few questions about this:
log
level for other services mentioned here?Your proposed approach looks great! Thanks for taking the time to detail it. To answer your questions:
Given the requirements of the ticket, my suggestion is to send the logs regardless of whether an error was encountered or not. So that could mean moving your
dispatch.call_hooks()
call to before theif not encountered_error:
check. (You'd probably need atry
/except
there as well.) We can always get into the details in the pull request.That would be great, yes. You can look at the existing tests in
unit/commands/test_borgmatic.py
for inspiration. They should hopefully be straight-forward to add. But if not, I'd be happy to help.It would be good to make sure that the other monitoring hooks do something when they receive the
LOG
state. But they don't have to implement actual logging. For instance, it would be totally fine if when they receive aLOG
state, they immediately return since logging may not be implemented for those hooks.Let me know if any other questions come up as you work on this. I really appreciate the effort!
Implemented in #645! This will be part of the next release.
Just released in borgmatic 1.7.9!