def get_top10(): try: query, _, _, group, _, _, _ = parse_fields(request) except Exception as e: return jsonify(status="error", message=str(e)), 400 try: top10 = db.get_topn(query=query, group=group, limit=10) except Exception as e: return jsonify(status="error", message=str(e)), 500 for item in top10: for resource in item['resources']: resource['href'] = absolute_url('/alert/' + resource['id']) if top10: return jsonify(status="ok", total=len(top10), top10=top10) else: return jsonify( status="ok", message="not found", total=0, top10=[], )
def get_top10(): try: query, _, group, _, _ = parse_fields(request) except Exception as e: return jsonify(status="error", message=str(e)), 400 try: top10 = db.get_topn(query=query, group=group, limit=10) except Exception as e: return jsonify(status="error", message=str(e)), 500 for item in top10: for resource in item['resources']: resource['href'] = "%s/%s" % (request.base_url.replace('alerts/top10', 'alert'), resource['id']) if top10: return jsonify( status="ok", total=len(top10), top10=top10 ) else: return jsonify( status="ok", message="not found", total=0, top10=[], )
def get_top10(tenant): tenant = generateDBName(tenant) try: query, _, group, _, _, _ = parse_fields(request) except Exception as e: return jsonify(status="error", message=str(e)), 400 try: top10 = db.get_topn(tenant, query=query, group=group, limit=10) except Exception as e: return jsonify(status="error", message=str(e)), 500 for item in top10: for resource in item['resources']: resource['href'] = "%s/%s" % (request.base_url.replace('alerts/top10', 'alert'), resource['id']) if top10: return jsonify( status="ok", total=len(top10), top10=top10 ) else: return jsonify( status="ok", message="not found", total=0, top10=[], )