77)
88from app .helpers .utils import get_app_data
99
10+
1011class AppMemoryUsageView (Resource ):
1112 @jwt_required
1213 def post (self , project_id , app_id ):
@@ -31,7 +32,14 @@ def post(self, project_id, app_id):
3132 except Exception as error :
3233 return dict (status = 'fail' , message = str (error )), 500
3334
34- new_data = json .loads (prom_memory_data )
35+ if not prom_memory_data :
36+ return dict (status = 'fail' , message = "Failed to connect to prometheus" ), 500
37+
38+ try :
39+ new_data = json .loads (prom_memory_data )
40+ except Exception as error :
41+ return dict (status = 'fail' , message = str (prom_memory_data )), 500
42+
3543 final_data_list = []
3644
3745 try :
@@ -70,7 +78,14 @@ def post(self, project_id, app_id):
7078 except Exception as error :
7179 return dict (status = 'fail' , message = str (error )), 500
7280
73- new_data = json .loads (prom_cpu_data )
81+ if not prom_cpu_data :
82+ return dict (status = 'fail' , message = "Failed to connect to prometheus" ), 500
83+
84+ try :
85+ new_data = json .loads (prom_cpu_data )
86+ except Exception as error :
87+ return dict (status = 'fail' , message = str (prom_cpu_data )), 500
88+
7489 final_data_list = []
7590
7691 try :
@@ -109,7 +124,14 @@ def post(self, project_id, app_id):
109124 except Exception as error :
110125 return dict (status = 'fail' , message = str (error )), 500
111126
112- new_data = json .loads (prom_net_data )
127+ if not prom_net_data :
128+ return dict (status = 'fail' , message = "Failed to connect to prometheus" ), 500
129+
130+ try :
131+ new_data = json .loads (prom_net_data )
132+ except Exception as error :
133+ return dict (status = 'fail' , message = str (prom_net_data )), 500
134+
113135 final_data_list = []
114136
115137 try :
0 commit comments