Give access to results details in case of succeeded archive creation #385

Closed
opened 2021-01-16 15:30:00 +00:00 by fpoulain · 5 comments
Contributor

What I'm trying to do and why

I am monitoring borgmatics logs using icinga and a python script (small log parser).

In order to be reliable, I made use of borgmatic hooks.

I would like to get extra infos, like e.g. duration of the archive creation. It would be nice to get all ouput or the creation sumary in hooks variables.

Currently, only on_error hooks is getting extra infos (output, error).

Other notes / implementation ideas

I suggest making available:

  • configuration_filename
  • output
  • summary

It would be great if summary is parsed into variables:

  • archive_name
  • archive_fingerprint
  • start_time
  • end_time
  • duration
  • number_of_files
#### What I'm trying to do and why I am monitoring borgmatics logs using icinga and a python script (small log parser). In order to be reliable, I made use of borgmatic hooks. I would like to get extra infos, like e.g. duration of the archive creation. It would be nice to get all ouput or the creation sumary in hooks variables. Currently, only `on_error` hooks is getting extra infos (output, error). #### Other notes / implementation ideas I suggest making available: * configuration_filename * output * summary It would be great if summary is parsed into variables: * archive_name * archive_fingerprint * start_time * end_time * duration * number_of_files
Owner

Thank you for filing this. The output and summary are currently sent to the logging system (syslog or journalctl). Is the problem that it's just not convenient or reliable to parse them from there?

As for the duration of archive creation and similar data, have you considered running borgmatic with the --json flag? That of course won't make the data available to hooks, but it does return easily parseable info like archive duration.

Let me know your thoughts!

Thank you for filing this. The output and summary are currently sent to the logging system (`syslog` or `journalctl`). Is the problem that it's just not convenient or reliable to parse them from there? As for the duration of archive creation and similar data, have you considered running borgmatic with the `--json` flag? That of course won't make the data available to hooks, but it does return easily parseable info like archive duration. Let me know your thoughts!
Contributor

I'm using a small script which parses journalctl as per my needs after borgmatic completed the backup. It mainly filters on keywords like "Successful" plus a list of desired log level data like "WARNING" or "ERROR".

I'm running the script as "ExecStopPost" in the systemd service, but you can also start it via the "after_backup" hook from Borgmatic itself.

Another method I used previously was to write the log in parallel to a temporary file (with separate log level), but then I still wanted some post processing/filter so that I now simply use the journalctl.

I'm using a small script which parses journalctl as per my needs after borgmatic completed the backup. It mainly filters on keywords like "Successful" plus a list of desired log level data like "WARNING" or "ERROR". I'm running the script as "ExecStopPost" in the systemd service, but you can also start it via the "after_backup" hook from Borgmatic itself. Another method I used previously was to write the log in parallel to a temporary file (with separate log level), but then I still wanted some post processing/filter so that I now simply use the journalctl.
Author
Contributor

As for the duration of archive creation and similar data, have you considered running borgmatic with the --json flag? That of course won't make the data available to hooks, but it does return easily parseable info like archive duration.

Well, I see. Actually I didn't throught about calling borgmatic with the --json flag. It gives the expected result.

E.g. I can get many info using:

borgmatic --info --archive latest --json

And if I am only interested in durations I can get those with:

borgmatic --info --archive latest --json | jq '[.[] | .archives | last | .duration ]'

Currently it appears that it is ok to call borgmatic --info or borgmatic --list into a hook. Do you advise against it ?

> As for the duration of archive creation and similar data, have you considered running borgmatic with the `--json` flag? That of course won't make the data available to hooks, but it does return easily parseable info like archive duration. Well, I see. Actually I didn't throught about calling borgmatic with the `--json` flag. It gives the expected result. E.g. I can get many info using: ``` borgmatic --info --archive latest --json ``` And if I am only interested in durations I can get those with: ``` borgmatic --info --archive latest --json | jq '[.[] | .archives | last | .duration ]' ``` Currently it appears that it is ok to call `borgmatic --info` or `borgmatic --list` into a hook. Do you advise against it ?
Owner

I apologize for the super lengthy delay in getting back to this. I generally don't recommend calling borgmatic from borgmatic (especially because of the infinite loop risk), but in this case I don't see a better option given the current feature set.

Assuming this is still a relevant issue to you, how can/does your monitoring software consume information from the software it's monitoring? For instance, if borgmatic had a built-in feature to write some of the stats you're looking for to a JSON file (as in #617), would that be easier to monitor?

I apologize for the super lengthy delay in getting back to this. I generally don't recommend calling borgmatic from borgmatic (especially because of the infinite loop risk), but in this case I don't see a better option given the current feature set. Assuming this is still a relevant issue to you, how can/does your monitoring software consume information from the software it's monitoring? For instance, if borgmatic had a built-in feature to write some of the stats you're looking for to a JSON file (as in #617), would that be easier to monitor?
Owner

I'm closing this one for now due to inactivity, but I'd be happy to open it up again if you have further thoughts. Thank you!

I'm closing this one for now due to inactivity, but I'd be happy to open it up again if you have further thoughts. Thank you!
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#385
No description provided.