diff --git a/grafana_backup/create_alert_rule.py b/grafana_backup/create_alert_rule.py index 9a3fcde5..7b13a288 100644 --- a/grafana_backup/create_alert_rule.py +++ b/grafana_backup/create_alert_rule.py @@ -31,7 +31,7 @@ def main(args, settings, file_path): uid = alert_rule['uid'] get_response= get_alert_rule(uid, grafana_url, http_get_headers, verify_ssl, client_cert, debug) status_code=get_response[0] - print("Got a code: {0}", status_code) + print("Got a code: {0}".format(status_code)) if status_code == 404: http_post_headers['x-disable-provenance']='*' result = create_alert_rule(json.dumps(alert_rule), grafana_url, http_post_headers, verify_ssl, client_cert, debug) diff --git a/grafana_backup/dashboardApi.py b/grafana_backup/dashboardApi.py index 8fbdaf89..2afc9b73 100755 --- a/grafana_backup/dashboardApi.py +++ b/grafana_backup/dashboardApi.py @@ -515,7 +515,10 @@ def send_grafana_get(url, http_get_headers, verify_ssl, client_cert, debug): verify=verify_ssl, cert=client_cert) if debug: log_response(r) - return (r.status_code, r.json()) + if not r.ok: + return (r.status_code, '{}') + else: + return (r.status_code, r.json()) def send_grafana_post(url, json_payload, http_post_headers, verify_ssl=False, client_cert=None, debug=True):