grafana-backup-tool icon indicating copy to clipboard operation
grafana-backup-tool copied to clipboard

Pretty JSON

Open sshaikh opened this issue 4 years ago • 4 comments

For those of us who prefer text/json output (for example to use with source control) it would be useful for JSON files be prettified (and perhaps sorted somehow?) when written to disk.

I'm not too familiar with Python but my work around right now is to apply the json.tool (module?) to each file via a bash script, but I presume that means this can be rolled into the backup tool itself.

sshaikh avatar Aug 17 '20 13:08 sshaikh

I've done just this in my own local copy of this tool. I should really fork the repo and do this properly as a pull request, but it was pretty simple if I remember correctly...

dfluff avatar Sep 03 '20 15:09 dfluff

As the Grafana API is pretty decent I've since settled on a pure bash version of 15 lines. This is still a great tool for those who do not have access to curl and jq.

sshaikh avatar Sep 03 '20 17:09 sshaikh

does the pretty_print option expect any python module to be present to work? i have it set to true in the conf file, and it doesn't create pretty_print output. using python 3.7 on a mac, did do 'pip install .' before running. not a big deal - could prettify with jq and not needed for post-processing, but would be nice for review.

{
  "general": {
    "debug": true,
    "verify_ssl": true,
    "backup_dir": "_OUTPUT_",
    "backup_file_format": "%Y%m%d%H%M",
    "pretty_print": true
  },

davecampbell avatar Dec 10 '20 00:12 davecampbell

The "pretty_print" option is working. May I humbly suggest adding it to the example config file and closing this issue?

pavilalopes avatar Jan 30 '24 13:01 pavilalopes