Removing part of JSON from amreport output
From MyWiki
Amreport has a block describing failure of amdump, which is causing grief to Logstash. We believe that the reason is some possibly hard coded limits on string length and the array size and some limitations on what characters can be present in strings.
"failure_details" : [ " /-- ie1-i-amdbkp-01 /IE1-P-NAS-02/BACKUP_U1 lev 0 FAILED [dump (28470) /bin/tar returned 2]", " sendbackup: start [ie1-i-amdbkp-01:/IE1-P-NAS-02/BACKUP_U1 level 0]", " sendbackup: info BACKUP=/bin/tar", " sendbackup: info RECOVER_CMD=/bin/tar -xpGf - ...", " sendbackup: info end", " ? /bin/tar: ./FROM_ALTERWAY_MIGRATION_DAY/www_prod/coffret2008/japon/302: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./FROM_ALTERWAY_MIGRATION_DAY/www_prod/coffret2008/thumb: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/allemagne/100: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/grand: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/japon/100: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/japon/302: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/thumb: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./FROM_ALTERWAY_MIGRATION_DAY/www_prod/coffret2008/japon/302/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./FROM_ALTERWAY_MIGRATION_DAY/www_prod/coffret2008/thumb/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/allemagne/100/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/grand/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/japon/100/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/japon/302/: Warning: Cannot savedir: Too many levels of symbolic links", " ? /bin/tar: ./all_servers_u1/www_test/coffret2008/thumb/: Warning: Cannot savedir: Too many levels of symbolic links", " | Total bytes written: 793013391360 (739GiB, 53MiB/s)", " ? /bin/tar: Exiting with failure status due to previous errors", " Look in the '/var/log/amanda/log.error/ie1-i-amdbkp-01._IE1-P-NAS-02_BACKUP_U1.0.20141107032043.errout' file for full error messages", " \\--------" ]
The below Python code removes it:
#!/usr/bin/python # # Script: /etc/amanda/amrmfailuredetails.py # # Filters out 'failure_details' array from amreport JSON output # import sys import json data = json.loads(sys.stdin.read()) try: data.pop(u'failure_details') except KeyError: pass json.dump(data,sys.stdout,indent=2)
Pipe the amreport output through and here you go
$ amreport --format=json, <amanda_profile_name> | /etc/amanda/amrmfailuredetails.py