JSON backup report: a bit more human readable?

Hi there,
I would like to suggest to make the JSON backup report which could be sent to healthchecks.io and others a bit more human readable:

  • “start_time”: 1580837217, → Convert from Epoch to local date and time of the backup client
  • “end_time”: 1580837222, → Convert from Epoch to local date and time of the backup client
  • “total_file_size”: 245660 , → convert from bytes zu KB, MB, GB, TB, … accordingly
  • “new_file_size”: 47, → convert from bytes zu KB, MB, GB, TB, … accordingly

Thanks for considering this suggestion.

1 Like

This will make the report harder to parse by programs, which is more likely the use case I think.

1 Like

Regarding a machine to machine communication, I fully agree with your view.
Regarding a machine to human communication, well think about an ordinary end user which will hardly know Epoch etc… Think about the use cases with healthchecks.io where the backup report is visible for end users. So perhaps would it be possible to add these conversions (Epoch -->local time and size conversion to kB, MB, GB …) as options in the report template or allow additional variables and functions in report.tmpl as it is suggested here: Report templating formatted variables/additional variables

Making the output human-readable for that specific case puts the conversion burden on everyone else who needs the data in machine-readable form, which is what JSON is for. If you need the data in a different format, nothing prevents the output from being post-processed into whatever format you like before sending it elsewhere.

That said, there is a case to be made for timestamps to be ISO 8601 because that format includes time zone information that epoch time lacks.

If I can offer @gchen a suggestion: Replace whatever handles the {{.key}} tags in the template with a call to one of the Golang implementations of jq. That will provide a lot of leeway to manipulate the output without having to resort to an external program. Since jq’s syntax to extract the value of a single field matches what’s already there (.key), this wouldn’t be a breaking change.

2 Likes

Yes, this would be one solution. Another possibility would be to allow functions, time conversions, arithmetic etc. in the Go template, as this guy mentioned it here: Report templating formatted variables/additional variables