How to use put_metric_data method in localstack

Best Python code snippet using localstack_python

pgcm.py

Source:pgcm.py Github

copy

Full Screen

...700 logger.info("-------------------------------------")701 cloudwatch = boto3.client('cloudwatch')702 # Put Counter custom metrics703 logger_debug.debug("starting cloudwatch.put_metric_data.result_percent_towards_wraparound")704 cloudwatch.put_metric_data(705 MetricData=[706 {707 'MetricName': 'Xid_Percent_Towards_Wraparound',708 'Dimensions': [709 {710 'Name': 'DBInstanceIdentifier',711 'Value': rds_config.metric_name712 },713 ],714 'Unit': 'Percent',715 'Value': result_percent_towards_wraparound[0][0]716 },717 ],718 Namespace='PG Counter Metrics'719 )720 logger_debug.debug("starting cloudwatch.put_metric_data.queries_canceled_due_to_lock_timeout")721 cloudwatch.put_metric_data(722 MetricData=[723 {724 'MetricName': 'queries_canceled_due_to_lock_timeouts',725 'Dimensions': [726 {727 'Name': 'DBInstanceIdentifier',728 'Value': rds_config.metric_name729 },730 ],731 'Unit': 'Count',732 'Value': result_queries_canceled_due_to_lock_timeouts[0][0]733 },734 ],735 Namespace='PG Counter Metrics'736 )737 logger_debug.debug("starting cloudwatch.put_metric_data.queries_canceled_due_to_lock_deadlocks")738 cloudwatch.put_metric_data(739 MetricData=[740 {741 'MetricName': 'queries_canceled_due_to_lock_deadlocks',742 'Dimensions': [743 {744 'Name': 'DBInstanceIdentifier',745 'Value': rds_config.metric_name746 },747 ],748 'Unit': 'Count',749 'Value': result_queries_canceled_due_to_lock_deadlocks[0][0]750 },751 ],752 Namespace='PG Counter Metrics'753 )754 logger_debug.debug("starting cloudwatch.put_metric_data.idle_in_transaction_sessions")755 cloudwatch.put_metric_data(756 MetricData=[757 {758 'MetricName': 'idle_in_transaction_sessions',759 'Dimensions': [760 {761 'Name': 'DBInstanceIdentifier',762 'Value': rds_config.metric_name763 },764 ],765 'Unit': 'Count',766 'Value': result_idle_in_transaction_sessions[0][0]767 },768 ],769 Namespace='PG Counter Metrics'770 )771 logger_debug.debug("starting cloudwatch.put_metric_data.idle_sessions")772 cloudwatch.put_metric_data(773 MetricData=[774 {775 'MetricName': 'idle_sessions',776 'Dimensions': [777 {778 'Name': 'DBInstanceIdentifier',779 'Value': rds_config.metric_name780 },781 ],782 'Unit': 'Count',783 'Value': result_idle_sessions[0][0]784 },785 ],786 Namespace='PG Counter Metrics'787 )788 logger_debug.debug("starting cloudwatch.put_metric_data.idle_in_transaction_aborted_sessions")789 cloudwatch.put_metric_data(790 MetricData=[791 {792 'MetricName': 'idle_in_transaction_aborted_sessions',793 'Dimensions': [794 {795 'Name': 'DBInstanceIdentifier',796 'Value': rds_config.metric_name797 },798 ],799 'Unit': 'Count',800 'Value': result_idle_in_transaction_aborted_sessions[0][0]801 },802 ],803 Namespace='PG Counter Metrics'804 )805 logger_debug.debug("starting cloudwatch.put_metric_data.active_sessions")806 cloudwatch.put_metric_data(807 MetricData=[808 {809 'MetricName': 'active_sessions',810 'Dimensions': [811 {812 'Name': 'DBInstanceIdentifier',813 'Value': rds_config.metric_name814 },815 ],816 'Unit': 'Count',817 'Value': result_active_sessions[0][0]818 },819 ],820 Namespace='PG Counter Metrics'821 )822 logger_debug.debug("starting cloudwatch.put_metric_data.Inactive_replication_slot")823 cloudwatch.put_metric_data(824 MetricData=[825 {826 'MetricName': 'Inactive_replication_slot',827 'Dimensions': [828 {829 'Name': 'DBInstanceIdentifier',830 'Value': rds_config.metric_name831 },832 ],833 'Unit': 'Count',834 'Value': result_Inactive_replication_slot[0][0]835 },836 ],837 Namespace='PG Counter Metrics'838 )839 logger_debug.debug("starting cloudwatch.put_metric_data.invalid_indexes")840 cloudwatch.put_metric_data(841 MetricData=[842 {843 'MetricName': 'invalid_indexes',844 'Dimensions': [845 {846 'Name': 'DBInstanceIdentifier',847 'Value': rds_config.metric_name848 },849 ],850 'Unit': 'Count',851 'Value': result_invalid_indexes[0][0]852 },853 ],854 Namespace='PG Counter Metrics'855 )856 logger_debug.debug("starting cloudwatch.put_metric_data.deadlocks")857 cloudwatch.put_metric_data(858 MetricData=[859 {860 'MetricName': 'deadlocks',861 'Dimensions': [862 {863 'Name': 'DBInstanceIdentifier',864 'Value': rds_config.metric_name865 },866 ],867 'Unit': 'Count',868 'Value': result_deadlocks[0][0]869 },870 ],871 Namespace='PG Counter Metrics'872 )873 logger_debug.debug("starting cloudwatch.put_metric_data.total_connections")874 cloudwatch.put_metric_data(875 MetricData=[876 {877 'MetricName': 'total_connections',878 'Dimensions': [879 {880 'Name': 'DBInstanceIdentifier',881 'Value': rds_config.metric_name882 },883 ],884 'Unit': 'Count',885 'Value': result_total_connections[0][0]886 },887 ],888 Namespace='PG Counter Metrics'889 )890 logger_debug.debug("starting cloudwatch.put_metric_data.max_connections")891 cloudwatch.put_metric_data(892 MetricData=[893 {894 'MetricName': 'max_connections',895 'Dimensions': [896 {897 'Name': 'DBInstanceIdentifier',898 'Value': rds_config.metric_name899 },900 ],901 'Unit': 'Count',902 'Value': result_max_connections[0][0]903 },904 ],905 Namespace='PG Counter Metrics'906 )907 logger_debug.debug("starting cloudwatch.put_metric_data.connections_utilization")908 cloudwatch.put_metric_data(909 MetricData=[910 {911 'MetricName': 'connections_utilization',912 'Dimensions': [913 {914 'Name': 'DBInstanceIdentifier',915 'Value': rds_config.metric_name916 },917 ],918 'Unit': 'Percent',919 'Value': result_connections_utilization920 },921 ],922 Namespace='PG Counter Metrics'923 )924 logger_debug.debug("starting cloudwatch.put_metric_data.autovacuum_freeze_max_age")925 cloudwatch.put_metric_data(926 MetricData=[927 {928 'MetricName': 'autovacuum_freeze_max_age',929 'Dimensions': [930 {931 'Name': 'DBInstanceIdentifier',932 'Value': rds_config.metric_name933 },934 ],935 'Unit': 'Count',936 'Value': result_autovacuum_freeze_max_age[0][0]937 },938 ],939 Namespace='PG Counter Metrics'940 )941 logger_debug.debug("starting cloudwatch.put_metric_data.oldest_xid")942 cloudwatch.put_metric_data(943 MetricData=[944 {945 'MetricName': 'oldest_xid',946 'Dimensions': [947 {948 'Name': 'DBInstanceIdentifier',949 'Value': rds_config.metric_name950 },951 ],952 'Unit': 'Count',953 'Value': result_oldest_xid[0][0]954 },955 ],956 Namespace='PG Counter Metrics'957 )958 logger_debug.debug("starting cloudwatch.put_metric_data.percent_towards_emergency_autovacuum")959 cloudwatch.put_metric_data(960 MetricData=[961 {962 'MetricName': 'percent_towards_emergency_autovacuum',963 'Dimensions': [964 {965 'Name': 'DBInstanceIdentifier',966 'Value': rds_config.metric_name967 },968 ],969 'Unit': 'Percent',970 'Value': result_percent_towards_emergency_autovacuum971 },972 ],973 Namespace='PG Counter Metrics'974 )975 logger_debug.debug("starting cloudwatch.put_metric_data.autovacuum_count_per_min")976 cloudwatch.put_metric_data(977 MetricData=[978 {979 'MetricName': 'autovacuum_count_per_min',980 'Dimensions': [981 {982 'Name': 'DBInstanceIdentifier',983 'Value': rds_config.metric_name984 },985 ],986 'Unit': 'Count',987 'Value': result_autovacuum_count_per_min[0][0]988 },989 ],990 Namespace='PG Counter Metrics'991 )992 logger_debug.debug("starting cloudwatch.put_metric_data.autovacuum_count_per_hour")993 cloudwatch.put_metric_data(994 MetricData=[995 {996 'MetricName': 'autovacuum_count_per_hour',997 'Dimensions': [998 {999 'Name': 'DBInstanceIdentifier',1000 'Value': rds_config.metric_name1001 },1002 ],1003 'Unit': 'Count',1004 'Value': result_autovacuum_count_per_hour[0][0]1005 },1006 ],1007 Namespace='PG Counter Metrics'1008 )1009 logger_debug.debug("starting cloudwatch.put_metric_data.autovacuum_count_per_day")1010 cloudwatch.put_metric_data(1011 MetricData=[1012 {1013 'MetricName': 'autovacuum_count_per_day',1014 'Dimensions': [1015 {1016 'Name': 'DBInstanceIdentifier',1017 'Value': rds_config.metric_name1018 },1019 ],1020 'Unit': 'Count',1021 'Value': result_autovacuum_count_per_day[0][0]1022 },1023 ],1024 Namespace='PG Counter Metrics'1025 )1026 logger_debug.debug("starting cloudwatch.put_metric_data.autoanalyze_count_per_min")1027 cloudwatch.put_metric_data(1028 MetricData=[1029 {1030 'MetricName': 'autoanalyze_count_per_min',1031 'Dimensions': [1032 {1033 'Name': 'DBInstanceIdentifier',1034 'Value': rds_config.metric_name1035 },1036 ],1037 'Unit': 'Count',1038 'Value': result_autoanalyze_count_per_min[0][0]1039 },1040 ],1041 Namespace='PG Counter Metrics'1042 )1043 logger_debug.debug("starting cloudwatch.put_metric_data.autoanalyze_count_per_hour")1044 cloudwatch.put_metric_data(1045 MetricData=[1046 {1047 'MetricName': 'autoanalyze_count_per_hour',1048 'Dimensions': [1049 {1050 'Name': 'DBInstanceIdentifier',1051 'Value': rds_config.metric_name1052 },1053 ],1054 'Unit': 'Count',1055 'Value': result_autoanalyze_count_per_hour[0][0]1056 },1057 ],1058 Namespace='PG Counter Metrics'1059 )1060 logger_debug.debug("starting cloudwatch.put_metric_data.autoanalyze_count_per_day")1061 cloudwatch.put_metric_data(1062 MetricData=[1063 {1064 'MetricName': 'autoanalyze_count_per_day',1065 'Dimensions': [1066 {1067 'Name': 'DBInstanceIdentifier',1068 'Value': rds_config.metric_name1069 },1070 ],1071 'Unit': 'Count',1072 'Value': result_autoanalyze_count_per_day[0][0]1073 },1074 ],1075 Namespace='PG Counter Metrics'1076 )1077 logger_debug.debug("starting cloudwatch.put_metric_data.total_DB_size_in_GB")1078 cloudwatch.put_metric_data(1079 MetricData=[1080 {1081 'MetricName': 'total_DB_size_in_GB',1082 'Dimensions': [1083 {1084 'Name': 'DBInstanceIdentifier',1085 'Value': rds_config.metric_name1086 },1087 ],1088 'Unit': 'Gigabits',1089 'Value': result_total_DB_size_in_GB[0][0]1090 },1091 ],1092 Namespace='PG Counter Metrics'1093 )1094 logger_debug.debug("starting cloudwatch.put_metric_data.Active_replication_slot")1095 cloudwatch.put_metric_data(1096 MetricData=[1097 {1098 'MetricName': 'Active_replication_slot',1099 'Dimensions': [1100 {1101 'Name': 'DBInstanceIdentifier',1102 'Value': rds_config.metric_name1103 },1104 ],1105 'Unit': 'Count',1106 'Value': result_Active_replication_slot[0][0]1107 },1108 ],1109 Namespace='PG Counter Metrics'1110 )1111 logger_debug.debug("starting cloudwatch.put_metric_data.blocked_sessions")1112 cloudwatch.put_metric_data(1113 MetricData=[1114 {1115 'MetricName': 'blocked_sessions',1116 'Dimensions': [1117 {1118 'Name': 'DBInstanceIdentifier',1119 'Value': rds_config.metric_name1120 },1121 ],1122 'Unit': 'Count',1123 'Value': result_blocked_sessions[0][0]1124 },1125 ],1126 Namespace='PG Counter Metrics'1127 )1128 logger_debug.debug("starting cloudwatch.put_metric_data.wait_event")1129 for k in json_result_wait_event:1130 wait_event=k1131 wait_event_sample=json_result_wait_event[k]1132 #logger.info(wait_event)1133 cloudwatch.put_metric_data(1134 MetricData=[1135 {1136 'MetricName': "wait_event_"+wait_event ,1137 'Dimensions': [1138 {1139 'Name': 'DBInstanceIdentifier',1140 'Value': rds_config.metric_name1141 },1142 ],1143 'Unit': 'Count',1144 'Value': wait_event_sample1145 },1146 ],1147 Namespace='PG Counter Metrics'1148 )1149 if len(schema_list) == 0:1150 pass1151 else: 1152 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_autovacuum_count")1153 for k in json_result_table_stat_autovacuum_count:1154 Table_Name=k1155 autovacuum_count=json_result_table_stat_autovacuum_count[k]1156 #logger.info(Table_Name)1157 cloudwatch.put_metric_data(1158 MetricData=[1159 {1160 'MetricName': "table_stat_autovacuum_count_"+Table_Name ,1161 'Dimensions': [1162 {1163 'Name': 'DBInstanceIdentifier',1164 'Value': rds_config.metric_name1165 },1166 ],1167 'Unit': 'Count',1168 'Value': autovacuum_count1169 },1170 ],1171 Namespace='PG Counter Metrics'1172 )1173 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_autoanalyze_count")1174 for k in json_result_table_stat_autoanalyze_count:1175 Table_Name=k1176 autoanalyze_count=json_result_table_stat_autoanalyze_count[k]1177 #logger.info(Table_Name)1178 cloudwatch.put_metric_data(1179 MetricData=[1180 {1181 'MetricName': "table_stat_autoanalyze_count_"+Table_Name ,1182 'Dimensions': [1183 {1184 'Name': 'DBInstanceIdentifier',1185 'Value': rds_config.metric_name1186 },1187 ],1188 'Unit': 'Count',1189 'Value': autoanalyze_count1190 },1191 ],1192 Namespace='PG Counter Metrics'1193 )1194 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_dead_tup")1195 for k in json_result_table_stat_n_dead_tup:1196 Table_Name=k1197 n_dead_tup=json_result_table_stat_n_dead_tup[k]1198 #logger.info(Table_Name)1199 cloudwatch.put_metric_data(1200 MetricData=[1201 {1202 'MetricName': "table_stat_n_dead_tup_"+Table_Name ,1203 'Dimensions': [1204 {1205 'Name': 'DBInstanceIdentifier',1206 'Value': rds_config.metric_name1207 },1208 ],1209 'Unit': 'Count',1210 'Value': n_dead_tup1211 },1212 ],1213 Namespace='PG Counter Metrics'1214 )1215 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_live_tup")1216 for k in json_result_table_stat_n_live_tup:1217 Table_Name=k1218 n_live_tup=json_result_table_stat_n_live_tup[k]1219 #logger.info(Table_Name)1220 cloudwatch.put_metric_data(1221 MetricData=[1222 {1223 'MetricName': "table_stat_n_live_tup_"+Table_Name ,1224 'Dimensions': [1225 {1226 'Name': 'DBInstanceIdentifier',1227 'Value': rds_config.metric_name1228 },1229 ],1230 'Unit': 'Count',1231 'Value': n_live_tup1232 },1233 ],1234 Namespace='PG Counter Metrics'1235 )1236 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_dead_tup_percent")1237 for k in json_result_table_stat_dead_tup_percent:1238 Table_Name=k1239 dead_tup_percent=json_result_table_stat_dead_tup_percent[k]1240 #logger.info(Table_Name)1241 cloudwatch.put_metric_data(1242 MetricData=[1243 {1244 'MetricName': "table_stat_dead_tup_percent_"+Table_Name ,1245 'Dimensions': [1246 {1247 'Name': 'DBInstanceIdentifier',1248 'Value': rds_config.metric_name1249 },1250 ],1251 'Unit': 'Percent',1252 'Value': dead_tup_percent1253 },1254 ],1255 Namespace='PG Counter Metrics'1256 )1257 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_total_fts_scan")1258 for k in json_result_table_stat_total_fts_scan:1259 Table_Name=k1260 total_fts_scan=json_result_table_stat_total_fts_scan[k]1261 #logger.info(Table_Name)1262 cloudwatch.put_metric_data(1263 MetricData=[1264 {1265 'MetricName': "table_stat_total_fts_scan_"+Table_Name ,1266 'Dimensions': [1267 {1268 'Name': 'DBInstanceIdentifier',1269 'Value': rds_config.metric_name1270 },1271 ],1272 'Unit': 'Count',1273 'Value': total_fts_scan1274 },1275 ],1276 Namespace='PG Counter Metrics'1277 )1278 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_total_idx_scan")1279 for k in json_result_table_stat_total_idx_scan:1280 Table_Name=k1281 total_idx_scan=json_result_table_stat_total_idx_scan[k]1282 #logger.info(Table_Name)1283 cloudwatch.put_metric_data(1284 MetricData=[1285 {1286 'MetricName': "table_stat_total_idx_scan_"+Table_Name ,1287 'Dimensions': [1288 {1289 'Name': 'DBInstanceIdentifier',1290 'Value': rds_config.metric_name1291 },1292 ],1293 'Unit': 'Count',1294 'Value': total_idx_scan1295 },1296 ],1297 Namespace='PG Counter Metrics'1298 )1299 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_tup_ins")1300 for k in json_result_table_stat_n_tup_ins:1301 Table_Name=k1302 n_tup_ins=json_result_table_stat_n_tup_ins[k]1303 #logger.info(Table_Name)1304 cloudwatch.put_metric_data(1305 MetricData=[1306 {1307 'MetricName': "table_stat_n_tup_ins_"+Table_Name ,1308 'Dimensions': [1309 {1310 'Name': 'DBInstanceIdentifier',1311 'Value': rds_config.metric_name1312 },1313 ],1314 'Unit': 'Count',1315 'Value': n_tup_ins1316 },1317 ],1318 Namespace='PG Counter Metrics'1319 )1320 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_tup_upd")1321 for k in json_result_table_stat_n_tup_upd:1322 Table_Name=k1323 n_tup_upd=json_result_table_stat_n_tup_upd[k]1324 #logger.info(Table_Name)1325 cloudwatch.put_metric_data(1326 MetricData=[1327 {1328 'MetricName': "table_stat_n_tup_upd_"+Table_Name ,1329 'Dimensions': [1330 {1331 'Name': 'DBInstanceIdentifier',1332 'Value': rds_config.metric_name1333 },1334 ],1335 'Unit': 'Count',1336 'Value': n_tup_upd1337 },1338 ],1339 Namespace='PG Counter Metrics'1340 )1341 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_tup_del")1342 for k in json_result_table_stat_n_tup_del:1343 Table_Name=k1344 n_tup_del=json_result_table_stat_n_tup_del[k]1345 #logger.info(Table_Name)1346 cloudwatch.put_metric_data(1347 MetricData=[1348 {1349 'MetricName': "table_stat_n_tup_del_"+Table_Name ,1350 'Dimensions': [1351 {1352 'Name': 'DBInstanceIdentifier',1353 'Value': rds_config.metric_name1354 },1355 ],1356 'Unit': 'Count',1357 'Value': n_tup_del1358 },1359 ],1360 Namespace='PG Counter Metrics'1361 )1362 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_mod_since_analyze")1363 for k in json_result_table_stat_n_mod_since_analyze:1364 Table_Name=k1365 n_mod_since_analyze=json_result_table_stat_n_mod_since_analyze[k]1366 #logger.info(Table_Name)1367 cloudwatch.put_metric_data(1368 MetricData=[1369 {1370 'MetricName': "table_stat_n_mod_since_analyze_"+Table_Name ,1371 'Dimensions': [1372 {1373 'Name': 'DBInstanceIdentifier',1374 'Value': rds_config.metric_name1375 },1376 ],1377 'Unit': 'Count',1378 'Value': n_mod_since_analyze1379 },1380 ],1381 Namespace='PG Counter Metrics'1382 )1383 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_n_tup_hot_upd")1384 for k in json_result_table_stat_n_tup_hot_upd:1385 Table_Name=k1386 n_tup_hot_upd=json_result_table_stat_n_tup_hot_upd[k]1387 #logger.info(Table_Name)1388 cloudwatch.put_metric_data(1389 MetricData=[1390 {1391 'MetricName': "table_stat_n_tup_hot_upd_"+Table_Name ,1392 'Dimensions': [1393 {1394 'Name': 'DBInstanceIdentifier',1395 'Value': rds_config.metric_name1396 },1397 ],1398 'Unit': 'Count',1399 'Value': n_tup_hot_upd1400 },1401 ],1402 Namespace='PG Counter Metrics'1403 )1404 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_tup_ins_precent")1405 for k in json_result_table_stat_tup_ins_precent:1406 Table_Name=k1407 tup_ins_precent=json_result_table_stat_tup_ins_precent[k]1408 #logger.info(Table_Name)1409 cloudwatch.put_metric_data(1410 MetricData=[1411 {1412 'MetricName': "table_stat_tup_ins_precent_"+Table_Name ,1413 'Dimensions': [1414 {1415 'Name': 'DBInstanceIdentifier',1416 'Value': rds_config.metric_name1417 },1418 ],1419 'Unit': 'Percent',1420 'Value': tup_ins_precent1421 },1422 ],1423 Namespace='PG Counter Metrics'1424 )1425 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_tup_upd_precent")1426 for k in json_result_table_stat_tup_upd_precent:1427 Table_Name=k1428 tup_upd_precent=json_result_table_stat_tup_upd_precent[k]1429 #logger.info(Table_Name)1430 cloudwatch.put_metric_data(1431 MetricData=[1432 {1433 'MetricName': "table_stat_tup_upd_precent_"+Table_Name ,1434 'Dimensions': [1435 {1436 'Name': 'DBInstanceIdentifier',1437 'Value': rds_config.metric_name1438 },1439 ],1440 'Unit': 'Percent',1441 'Value': tup_upd_precent1442 },1443 ],1444 Namespace='PG Counter Metrics'1445 )1446 logger_debug.debug("starting cloudwatch.put_metric_data.table_stat_tup_del_precent")1447 for k in json_result_table_stat_tup_del_precent:1448 Table_Name=k1449 tup_del_precent=json_result_table_stat_tup_del_precent[k]1450 #logger.info(Table_Name)1451 cloudwatch.put_metric_data(1452 MetricData=[1453 {1454 'MetricName': "table_stat_tup_del_precent_"+Table_Name ,1455 'Dimensions': [1456 {1457 'Name': 'DBInstanceIdentifier',1458 'Value': rds_config.metric_name1459 },1460 ],1461 'Unit': 'Percent',1462 'Value': tup_del_precent1463 },1464 ],1465 Namespace='PG Counter Metrics'1466 )1467 logger_debug.debug("starting cloudwatch.put_metric_data.oldest_open_transaction")1468 cloudwatch.put_metric_data(1469 MetricData=[1470 {1471 'MetricName': 'oldest_open_transaction',1472 'Dimensions': [1473 {1474 'Name': 'DBInstanceIdentifier',1475 'Value': rds_config.metric_name1476 },1477 ],1478 'Unit': 'Seconds',1479 'Value': result_oldest_open_transaction[0][0]1480 },1481 ],1482 Namespace='PG Counter Metrics'1483 )1484 logger_debug.debug("starting cloudwatch.put_metric_data.n_tables_eligible_for_autovacuum")1485 cloudwatch.put_metric_data(1486 MetricData=[1487 {1488 'MetricName': 'n_tables_eligible_for_autovacuum',1489 'Dimensions': [1490 {1491 'Name': 'DBInstanceIdentifier',1492 'Value': rds_config.metric_name1493 },1494 ],1495 'Unit': 'Count',1496 'Value': result_n_tables_eligible_for_autovacuum[0][0]1497 },1498 ],1499 Namespace='PG Counter Metrics'1500 )1501 logger_debug.debug("starting cloudwatch.put_metric_data.not_granted_lock")1502 cloudwatch.put_metric_data(1503 MetricData=[1504 {1505 'MetricName': 'not_granted_lock',1506 'Dimensions': [1507 {1508 'Name': 'DBInstanceIdentifier',1509 'Value': rds_config.metric_name1510 },1511 ],1512 'Unit': 'Count',1513 'Value': result_not_granted_lock[0][0]1514 },1515 ],1516 Namespace='PG Counter Metrics'1517 )1518 logger_debug.debug("starting cloudwatch.put_metric_data.lock_mode")1519 for k in json_result_lock_mode:1520 lock_mode=k1521 lock_mode_sample=json_result_lock_mode[k]1522 #logger.info(lock_mode)1523 cloudwatch.put_metric_data(1524 MetricData=[1525 {1526 'MetricName': "lock_mode_"+lock_mode ,1527 'Dimensions': [1528 {1529 'Name': 'DBInstanceIdentifier',1530 'Value': rds_config.metric_name1531 },1532 ],1533 'Unit': 'Count',1534 'Value': lock_mode_sample1535 },1536 ],1537 Namespace='PG Counter Metrics'1538 )1539 logger_debug.debug("starting cloudwatch.put_metric_data.lock_type")1540 for k in json_result_lock_type:1541 lock_type=k1542 lock_type_sample=json_result_lock_type[k]1543 #logger.info(lock_type)1544 cloudwatch.put_metric_data(1545 MetricData=[1546 {1547 'MetricName': "lock_type_"+lock_type ,1548 'Dimensions': [1549 {1550 'Name': 'DBInstanceIdentifier',1551 'Value': rds_config.metric_name1552 },1553 ],1554 'Unit': 'Count',1555 'Value': lock_type_sample1556 },1557 ],1558 Namespace='PG Counter Metrics'1559 )1560 logger_debug.debug("starting cloudwatch.put_metric_data.xact_commit")1561 cloudwatch.put_metric_data(1562 MetricData=[1563 {1564 'MetricName': 'xact_commit',1565 'Dimensions': [1566 {1567 'Name': 'DBInstanceIdentifier',1568 'Value': rds_config.metric_name1569 },1570 ],1571 'Unit': 'Count',1572 'Value': result_xact_commit[0][0]1573 },1574 ],1575 Namespace='PG Counter Metrics'1576 )1577 logger_debug.debug("starting cloudwatch.put_metric_data.xact_rollback")1578 cloudwatch.put_metric_data(1579 MetricData=[1580 {1581 'MetricName': 'xact_rollback',1582 'Dimensions': [1583 {1584 'Name': 'DBInstanceIdentifier',1585 'Value': rds_config.metric_name1586 },1587 ],1588 'Unit': 'Count',1589 'Value': result_xact_rollback[0][0]1590 },1591 ],1592 Namespace='PG Counter Metrics'1593 )1594 logger_debug.debug("starting cloudwatch.put_metric_data.xact_commit_ratio")1595 cloudwatch.put_metric_data(1596 MetricData=[1597 {1598 'MetricName': 'xact_commit_ratio',1599 'Dimensions': [1600 {1601 'Name': 'DBInstanceIdentifier',1602 'Value': rds_config.metric_name1603 },1604 ],1605 'Unit': 'Percent',1606 'Value': result_xact_commit_ratio[0][0]1607 },1608 ],1609 Namespace='PG Counter Metrics'1610 )1611 logger_debug.debug("starting cloudwatch.put_metric_data.tup_returned")1612 cloudwatch.put_metric_data(1613 MetricData=[1614 {1615 'MetricName': 'tup_returned',1616 'Dimensions': [1617 {1618 'Name': 'DBInstanceIdentifier',1619 'Value': rds_config.metric_name1620 },1621 ],1622 'Unit': 'Count',1623 'Value': result_tup_returned[0][0]1624 },1625 ],1626 Namespace='PG Counter Metrics'1627 )1628 logger_debug.debug("starting cloudwatch.put_metric_data.tup_fetched")1629 cloudwatch.put_metric_data(1630 MetricData=[1631 {1632 'MetricName': 'tup_fetched',1633 'Dimensions': [1634 {1635 'Name': 'DBInstanceIdentifier',1636 'Value': rds_config.metric_name1637 },1638 ],1639 'Unit': 'Count',1640 'Value': result_tup_fetched[0][0]1641 },1642 ],1643 Namespace='PG Counter Metrics'1644 )1645 logger_debug.debug("starting cloudwatch.put_metric_data.tup_deleted")1646 cloudwatch.put_metric_data(1647 MetricData=[1648 {1649 'MetricName': 'tup_deleted',1650 'Dimensions': [1651 {1652 'Name': 'DBInstanceIdentifier',1653 'Value': rds_config.metric_name1654 },1655 ],1656 'Unit': 'Count',1657 'Value': result_tup_deleted[0][0]1658 },1659 ],1660 Namespace='PG Counter Metrics'1661 )1662 logger_debug.debug("starting cloudwatch.put_metric_data.tup_updated")1663 cloudwatch.put_metric_data(1664 MetricData=[1665 {1666 'MetricName': 'tup_updated',1667 'Dimensions': [1668 {1669 'Name': 'DBInstanceIdentifier',1670 'Value': rds_config.metric_name1671 },1672 ],1673 'Unit': 'Count',1674 'Value': result_tup_updated[0][0]1675 },1676 ],1677 Namespace='PG Counter Metrics'1678 )1679 logger_debug.debug("starting cloudwatch.put_metric_data.tup_inserted")1680 cloudwatch.put_metric_data(1681 MetricData=[1682 {1683 'MetricName': 'tup_inserted',1684 'Dimensions': [1685 {1686 'Name': 'DBInstanceIdentifier',1687 'Value': rds_config.metric_name1688 },1689 ],1690 'Unit': 'Count',1691 'Value': result_tup_inserted[0][0]1692 },1693 ],1694 Namespace='PG Counter Metrics'1695 )1696 logger_debug.debug("starting cloudwatch.put_metric_data.checkpoints_requested")1697 cloudwatch.put_metric_data(1698 MetricData=[1699 {1700 'MetricName': 'checkpoints_requested',1701 'Dimensions': [1702 {1703 'Name': 'DBInstanceIdentifier',1704 'Value': rds_config.metric_name1705 },1706 ],1707 'Unit': 'Count',1708 'Value': result_checkpoints_requested[0][0]1709 },1710 ],1711 Namespace='PG Counter Metrics'1712 )1713 logger_debug.debug("starting cloudwatch.put_metric_data.checkpoints_timed")1714 cloudwatch.put_metric_data(1715 MetricData=[1716 {1717 'MetricName': 'checkpoints_timed',1718 'Dimensions': [1719 {1720 'Name': 'DBInstanceIdentifier',1721 'Value': rds_config.metric_name1722 },1723 ],1724 'Unit': 'Count',1725 'Value': result_checkpoints_timed[0][0]1726 },1727 ],1728 Namespace='PG Counter Metrics'1729 )1730 logger_debug.debug("starting cloudwatch.put_metric_data.Oldest_Replication_Slot_Lag_gb_behind")1731 cloudwatch.put_metric_data(1732 MetricData=[1733 {1734 'MetricName': 'Oldest_Replication_Slot_Lag_gb_behind',1735 'Dimensions': [1736 {1737 'Name': 'DBInstanceIdentifier',1738 'Value': rds_config.metric_name1739 },1740 ],1741 'Unit': 'Gigabits',1742 'Value': result_Oldest_Replication_Slot_Lag_gb_behind[0][0]1743 },1744 ],1745 Namespace='PG Counter Metrics'1746 )1747 logger_debug.debug("starting cloudwatch.put_metric_data.oldest_open_idl_in_transaction")1748 cloudwatch.put_metric_data(1749 MetricData=[1750 {1751 'MetricName': 'oldest_open_idl_in_transaction',1752 'Dimensions': [1753 {1754 'Name': 'DBInstanceIdentifier',1755 'Value': rds_config.metric_name1756 },1757 ],1758 'Unit': 'Seconds',1759 'Value': result_oldest_open_idl_in_transaction[0][0]1760 },1761 ],1762 Namespace='PG Counter Metrics'1763 )1764 logger_debug.debug("starting cloudwatch.put_metric_data.Oldest_Replication_Slot_Lag_gb_behind_per_slot")1765 if result_count_replication_slots[0][0] > 0:1766 for k in json_result_Oldest_Replication_Slot_Lag_gb_behind_per_slot:1767 slot_name=k1768 oldest_replication_slot_lag_gb_behind=json_result_Oldest_Replication_Slot_Lag_gb_behind_per_slot[k]1769 cloudwatch.put_metric_data(1770 MetricData=[1771 {1772 'MetricName': "Oldest_Replication_Slot_Lag_gb_behind_"+slot_name ,1773 'Dimensions': [1774 {1775 'Name': 'DBInstanceIdentifier',1776 'Value': rds_config.metric_name1777 },1778 ],1779 'Unit': 'Gigabits',1780 'Value': oldest_replication_slot_lag_gb_behind1781 },1782 ],1783 Namespace='PG Counter Metrics'1784 )1785 else:1786 pass1787 if result_pg_stat_statements_extension[0][0] == 0:1788 logger_debug.debug("---------> pg_stat_statements extension is not enabled")1789 pass1790 else:1791 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_calls")1792 for k in json_result_pg_stat_statements_calls:1793 queryid=k1794 calls=json_result_pg_stat_statements_calls[k]1795 cloudwatch.put_metric_data(1796 MetricData=[1797 {1798 'MetricName': "pg_stat_statements_calls_queryid_"+str(queryid) ,1799 'Dimensions': [1800 {1801 'Name': 'DBInstanceIdentifier',1802 'Value': rds_config.metric_name1803 },1804 ],1805 'Unit': 'Count',1806 'Value': calls1807 },1808 ],1809 Namespace='PG Counter Metrics'1810 )1811 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_total_time_msec")1812 for k in json_result_pg_stat_statements_total_time_msec:1813 queryid=k1814 total_time_msec=json_result_pg_stat_statements_total_time_msec[k]1815 cloudwatch.put_metric_data(1816 MetricData=[1817 {1818 'MetricName': "pg_stat_statements_total_time_msec_queryid_"+str(queryid) ,1819 'Dimensions': [1820 {1821 'Name': 'DBInstanceIdentifier',1822 'Value': rds_config.metric_name1823 },1824 ],1825 'Unit': 'Milliseconds',1826 'Value': total_time_msec1827 },1828 ],1829 Namespace='PG Counter Metrics'1830 )1831 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_min_time_msec")1832 for k in json_result_pg_stat_statements_min_time_msec:1833 queryid=k1834 min_time_msec=json_result_pg_stat_statements_min_time_msec[k]1835 cloudwatch.put_metric_data(1836 MetricData=[1837 {1838 'MetricName': "pg_stat_statements_min_time_msec_queryid_"+str(queryid) ,1839 'Dimensions': [1840 {1841 'Name': 'DBInstanceIdentifier',1842 'Value': rds_config.metric_name1843 },1844 ],1845 'Unit': 'Milliseconds',1846 'Value': min_time_msec1847 },1848 ],1849 Namespace='PG Counter Metrics'1850 )1851 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_max_time_msec")1852 for k in json_result_pg_stat_statements_max_time_msec:1853 queryid=k1854 max_time_msec=json_result_pg_stat_statements_max_time_msec[k]1855 cloudwatch.put_metric_data(1856 MetricData=[1857 {1858 'MetricName': "pg_stat_statements_max_time_msec_queryid_"+str(queryid) ,1859 'Dimensions': [1860 {1861 'Name': 'DBInstanceIdentifier',1862 'Value': rds_config.metric_name1863 },1864 ],1865 'Unit': 'Milliseconds',1866 'Value': max_time_msec1867 },1868 ],1869 Namespace='PG Counter Metrics'1870 )1871 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_avg_time_msec")1872 for k in json_result_pg_stat_statements_avg_time_msec:1873 queryid=k1874 avg_time_msec=json_result_pg_stat_statements_avg_time_msec[k]1875 cloudwatch.put_metric_data(1876 MetricData=[1877 {1878 'MetricName': "pg_stat_statements_avg_time_msec_queryid_"+str(queryid) ,1879 'Dimensions': [1880 {1881 'Name': 'DBInstanceIdentifier',1882 'Value': rds_config.metric_name1883 },1884 ],1885 'Unit': 'Milliseconds',1886 'Value': avg_time_msec1887 },1888 ],1889 Namespace='PG Counter Metrics'1890 )1891 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_stddev_time_msec")1892 for k in json_result_pg_stat_statements_stddev_time_msec:1893 queryid=k1894 stddev_time_msec=json_result_pg_stat_statements_stddev_time_msec[k]1895 cloudwatch.put_metric_data(1896 MetricData=[1897 {1898 'MetricName': "pg_stat_statements_stddev_time_msec_queryid_"+str(queryid) ,1899 'Dimensions': [1900 {1901 'Name': 'DBInstanceIdentifier',1902 'Value': rds_config.metric_name1903 },1904 ],1905 'Unit': 'Milliseconds',1906 'Value': stddev_time_msec1907 },1908 ],1909 Namespace='PG Counter Metrics'1910 )1911 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_rows_per_exec")1912 for k in json_result_pg_stat_statements_rows_per_exec:1913 queryid=k1914 rows_per_exec=json_result_pg_stat_statements_rows_per_exec[k]1915 cloudwatch.put_metric_data(1916 MetricData=[1917 {1918 'MetricName': "pg_stat_statements_rows_per_exec_queryid_"+str(queryid) ,1919 'Dimensions': [1920 {1921 'Name': 'DBInstanceIdentifier',1922 'Value': rds_config.metric_name1923 },1924 ],1925 'Unit': 'Count',1926 'Value': rows_per_exec1927 },1928 ],1929 Namespace='PG Counter Metrics'1930 )1931 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_rows")1932 for k in json_result_pg_stat_statements_rows:1933 queryid=k1934 rows=json_result_pg_stat_statements_rows[k]1935 cloudwatch.put_metric_data(1936 MetricData=[1937 {1938 'MetricName': "pg_stat_statements_rows_queryid_"+str(queryid) ,1939 'Dimensions': [1940 {1941 'Name': 'DBInstanceIdentifier',1942 'Value': rds_config.metric_name1943 },1944 ],1945 'Unit': 'Count',1946 'Value': rows1947 },1948 ],1949 Namespace='PG Counter Metrics'1950 )1951 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_db_time_percent")1952 for k in json_result_pg_stat_statements_db_time_percent:1953 queryid=k1954 db_time_percent=json_result_pg_stat_statements_db_time_percent[k]1955 cloudwatch.put_metric_data(1956 MetricData=[1957 {1958 'MetricName': "pg_stat_statements_db_time_percent_queryid_"+str(queryid) ,1959 'Dimensions': [1960 {1961 'Name': 'DBInstanceIdentifier',1962 'Value': rds_config.metric_name1963 },1964 ],1965 'Unit': 'Percent',1966 'Value': db_time_percent1967 },1968 ],1969 Namespace='PG Counter Metrics'1970 )1971 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_shared_blks_hit")1972 for k in json_result_pg_stat_statements_shared_blks_hit:1973 queryid=k1974 shared_blks_hit=json_result_pg_stat_statements_shared_blks_hit[k]1975 cloudwatch.put_metric_data(1976 MetricData=[1977 {1978 'MetricName': "pg_stat_statements_shared_blks_hit_queryid_"+str(queryid) ,1979 'Dimensions': [1980 {1981 'Name': 'DBInstanceIdentifier',1982 'Value': rds_config.metric_name1983 },1984 ],1985 'Unit': 'Count',1986 'Value': shared_blks_hit1987 },1988 ],1989 Namespace='PG Counter Metrics'1990 )1991 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_shared_blks_read")1992 for k in json_result_pg_stat_statements_shared_blks_read:1993 queryid=k1994 shared_blks_read=json_result_pg_stat_statements_shared_blks_read[k]1995 cloudwatch.put_metric_data(1996 MetricData=[1997 {1998 'MetricName': "pg_stat_statements_shared_blks_read_queryid_"+str(queryid) ,1999 'Dimensions': [2000 {2001 'Name': 'DBInstanceIdentifier',2002 'Value': rds_config.metric_name2003 },2004 ],2005 'Unit': 'Count',2006 'Value': shared_blks_read2007 },2008 ],2009 Namespace='PG Counter Metrics'2010 )2011 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_shared_blks_dirtied")2012 for k in json_result_pg_stat_statements_shared_blks_dirtied:2013 queryid=k2014 shared_blks_dirtied=json_result_pg_stat_statements_shared_blks_dirtied[k]2015 cloudwatch.put_metric_data(2016 MetricData=[2017 {2018 'MetricName': "pg_stat_statements_shared_blks_dirtied_queryid_"+str(queryid) ,2019 'Dimensions': [2020 {2021 'Name': 'DBInstanceIdentifier',2022 'Value': rds_config.metric_name2023 },2024 ],2025 'Unit': 'Count',2026 'Value': shared_blks_dirtied2027 },2028 ],2029 Namespace='PG Counter Metrics'2030 )2031 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_shared_blks_written")2032 for k in json_result_pg_stat_statements_shared_blks_written:2033 queryid=k2034 shared_blks_written=json_result_pg_stat_statements_shared_blks_written[k]2035 cloudwatch.put_metric_data(2036 MetricData=[2037 {2038 'MetricName': "pg_stat_statements_shared_blks_written_queryid_"+str(queryid) ,2039 'Dimensions': [2040 {2041 'Name': 'DBInstanceIdentifier',2042 'Value': rds_config.metric_name2043 },2044 ],2045 'Unit': 'Count',2046 'Value': shared_blks_written2047 },2048 ],2049 Namespace='PG Counter Metrics'2050 )2051 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_local_blks_hit")2052 for k in json_result_pg_stat_statements_local_blks_hit:2053 queryid=k2054 local_blks_hit=json_result_pg_stat_statements_local_blks_hit[k]2055 cloudwatch.put_metric_data(2056 MetricData=[2057 {2058 'MetricName': "pg_stat_statements_local_blks_hit_queryid_"+str(queryid) ,2059 'Dimensions': [2060 {2061 'Name': 'DBInstanceIdentifier',2062 'Value': rds_config.metric_name2063 },2064 ],2065 'Unit': 'Count',2066 'Value': local_blks_hit2067 },2068 ],2069 Namespace='PG Counter Metrics'2070 )2071 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_local_blks_read")2072 for k in json_result_pg_stat_statements_local_blks_read:2073 queryid=k2074 local_blks_read=json_result_pg_stat_statements_local_blks_read[k]2075 cloudwatch.put_metric_data(2076 MetricData=[2077 {2078 'MetricName': "pg_stat_statements_local_blks_read_queryid_"+str(queryid) ,2079 'Dimensions': [2080 {2081 'Name': 'DBInstanceIdentifier',2082 'Value': rds_config.metric_name2083 },2084 ],2085 'Unit': 'Count',2086 'Value': local_blks_read2087 },2088 ],2089 Namespace='PG Counter Metrics'2090 )2091 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_local_blks_dirtied")2092 for k in json_result_pg_stat_statements_local_blks_dirtied:2093 queryid=k2094 local_blks_dirtied=json_result_pg_stat_statements_local_blks_dirtied[k]2095 cloudwatch.put_metric_data(2096 MetricData=[2097 {2098 'MetricName': "pg_stat_statements_local_blks_dirtied_queryid_"+str(queryid) ,2099 'Dimensions': [2100 {2101 'Name': 'DBInstanceIdentifier',2102 'Value': rds_config.metric_name2103 },2104 ],2105 'Unit': 'Count',2106 'Value': local_blks_dirtied2107 },2108 ],2109 Namespace='PG Counter Metrics'2110 )2111 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_local_blks_written")2112 for k in json_result_pg_stat_statements_local_blks_written:2113 queryid=k2114 local_blks_written=json_result_pg_stat_statements_local_blks_written[k]2115 cloudwatch.put_metric_data(2116 MetricData=[2117 {2118 'MetricName': "pg_stat_statements_local_blks_written_queryid_"+str(queryid) ,2119 'Dimensions': [2120 {2121 'Name': 'DBInstanceIdentifier',2122 'Value': rds_config.metric_name2123 },2124 ],2125 'Unit': 'Count',2126 'Value': local_blks_written2127 },2128 ],2129 Namespace='PG Counter Metrics'2130 )2131 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_temp_blks_read")2132 for k in json_result_pg_stat_statements_temp_blks_read:2133 queryid=k2134 temp_blks_read=json_result_pg_stat_statements_temp_blks_read[k]2135 cloudwatch.put_metric_data(2136 MetricData=[2137 {2138 'MetricName': "pg_stat_statements_temp_blks_read_queryid_"+str(queryid) ,2139 'Dimensions': [2140 {2141 'Name': 'DBInstanceIdentifier',2142 'Value': rds_config.metric_name2143 },2144 ],2145 'Unit': 'Count',2146 'Value': temp_blks_read2147 },2148 ],2149 Namespace='PG Counter Metrics'2150 )2151 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_temp_blks_written")2152 for k in json_result_pg_stat_statements_temp_blks_written:2153 queryid=k2154 temp_blks_written=json_result_pg_stat_statements_temp_blks_written[k]2155 cloudwatch.put_metric_data(2156 MetricData=[2157 {2158 'MetricName': "pg_stat_statements_temp_blks_written_queryid_"+str(queryid) ,2159 'Dimensions': [2160 {2161 'Name': 'DBInstanceIdentifier',2162 'Value': rds_config.metric_name2163 },2164 ],2165 'Unit': 'Count',2166 'Value': temp_blks_written2167 },2168 ],2169 Namespace='PG Counter Metrics'2170 )2171 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_blk_read_time_msec")2172 for k in json_result_pg_stat_statements_blk_read_time_msec:2173 queryid=k2174 blk_read_time_msec=json_result_pg_stat_statements_blk_read_time_msec[k]2175 cloudwatch.put_metric_data(2176 MetricData=[2177 {2178 'MetricName': "pg_stat_statements_blk_read_time_msec_queryid_"+str(queryid) ,2179 'Dimensions': [2180 {2181 'Name': 'DBInstanceIdentifier',2182 'Value': rds_config.metric_name2183 },2184 ],2185 'Unit': 'Milliseconds',2186 'Value': blk_read_time_msec2187 },2188 ],2189 Namespace='PG Counter Metrics'2190 )2191 logger_debug.debug("starting cloudwatch.put_metric_data.pg_stat_statements_blk_write_time_msec")2192 for k in json_result_pg_stat_statements_blk_write_time_msec:2193 queryid=k2194 blk_write_time_msec=json_result_pg_stat_statements_blk_write_time_msec[k]2195 cloudwatch.put_metric_data(2196 MetricData=[2197 {2198 'MetricName': "pg_stat_statements_blk_write_time_msec_queryid_"+str(queryid) ,2199 'Dimensions': [2200 {2201 'Name': 'DBInstanceIdentifier',2202 'Value': rds_config.metric_name2203 },2204 ],2205 'Unit': 'Milliseconds',2206 'Value': blk_write_time_msec2207 },2208 ],2209 Namespace='PG Counter Metrics'2210 )2211 logger_debug.debug("starting cloudwatch.put_metric_data.db_load_cpu")2212 cloudwatch.put_metric_data(2213 MetricData=[2214 {2215 'MetricName': 'db_load_cpu',2216 'Dimensions': [2217 {2218 'Name': 'DBInstanceIdentifier',2219 'Value': rds_config.metric_name2220 },2221 ],2222 'Unit': 'Count',2223 'Value': result_db_load_cpu[0][0]2224 },2225 ],2226 Namespace='PG Counter Metrics'2227 )2228 logger_debug.debug("starting cloudwatch.put_metric_data.db_load_none_cpu")2229 cloudwatch.put_metric_data(2230 MetricData=[2231 {2232 'MetricName': 'db_load_none_cpu',2233 'Dimensions': [2234 {2235 'Name': 'DBInstanceIdentifier',2236 'Value': rds_config.metric_name2237 },2238 ],2239 'Unit': 'Count',2240 'Value': result_db_load_none_cpu[0][0]2241 },2242 ],2243 Namespace='PG Counter Metrics'2244 )2245 logger_debug.debug("starting cloudwatch.put_metric_data.bgwriter_buffers_clean")2246 cloudwatch.put_metric_data(2247 MetricData=[2248 {2249 'MetricName': 'bgwriter_buffers_clean',2250 'Dimensions': [2251 {2252 'Name': 'DBInstanceIdentifier',2253 'Value': rds_config.metric_name2254 },2255 ],2256 'Unit': 'Count',2257 'Value': result_bgwriter_buffers_clean[0][0]2258 },2259 ],2260 Namespace='PG Counter Metrics'2261 )2262 logger_debug.debug("starting cloudwatch.put_metric_data.bgwriter_buffers_backend")2263 cloudwatch.put_metric_data(2264 MetricData=[2265 {2266 'MetricName': 'bgwriter_buffers_backend',2267 'Dimensions': [2268 {2269 'Name': 'DBInstanceIdentifier',2270 'Value': rds_config.metric_name2271 },2272 ],2273 'Unit': 'Count',2274 'Value': result_bgwriter_buffers_backend[0][0]2275 },2276 ],2277 Namespace='PG Counter Metrics'2278 )2279 logger_debug.debug("starting cloudwatch.put_metric_data.bgwriter_maxwritten_clean")2280 cloudwatch.put_metric_data(2281 MetricData=[2282 {2283 'MetricName': 'bgwriter_maxwritten_clean',2284 'Dimensions': [2285 {2286 'Name': 'DBInstanceIdentifier',2287 'Value': rds_config.metric_name2288 },2289 ],2290 'Unit': 'Count',2291 'Value': result_bgwriter_maxwritten_clean[0][0]2292 },2293 ],2294 Namespace='PG Counter Metrics'2295 )2296 logger_debug.debug("starting cloudwatch.put_metric_data.oldest_mxid")2297 cloudwatch.put_metric_data(2298 MetricData=[2299 {2300 'MetricName': 'oldest_mxid',2301 'Dimensions': [2302 {2303 'Name': 'DBInstanceIdentifier',2304 'Value': rds_config.metric_name2305 },2306 ],2307 'Unit': 'Count',2308 'Value': result_oldest_mxid[0][0]2309 },2310 ],2311 Namespace='PG Counter Metrics'2312 )2313 logger_debug.debug("starting cloudwatch.put_metric_data.autovacuum_multixact_freeze_max_age")2314 cloudwatch.put_metric_data(2315 MetricData=[2316 {2317 'MetricName': 'autovacuum_multixact_freeze_max_age',2318 'Dimensions': [2319 {2320 'Name': 'DBInstanceIdentifier',2321 'Value': rds_config.metric_name2322 },2323 ],2324 'Unit': 'Count',2325 'Value': result_autovacuum_multixact_freeze_max_age[0][0]2326 },2327 ],2328 Namespace='PG Counter Metrics'2329 )2330 except (Exception) as error:2331 logger.error(error)2332 putErrorMetric()2333 return None2334 finally:2335 if conn is not None:2336 conn.close()2337 logger.info("SUCCESS: PG Counter Metrics") 2338 return "SUCCESS: PG Counter Metrics"2339 2340def executeSQL(connection, sqlString, bindHash={}, supress=False):2341 """2342 A wrapper for SQL execution, handling exceptions, and managing2343 return values for non-select statements.2344 The supress flag allows us to prevent chatty error logs for specific2345 queries that we know may fail without us needing to worry about it.2346 We still return False, though, so that we can detect the error.2347 """2348 isSelect = False2349 if sqlString.upper().find("SELECT") == 0:2350 isSelect = True2351 success = True2352 #statement_timeout in millisecond2353 #It only applies to current session2354 timeout = 10000;2355 timeoutString = "SET statement_timeout = " + str(timeout)2356 results = []2357 try:2358 cursor = connection.cursor()2359 cursor.execute(timeoutString)2360 cursor.execute(sqlString, bindHash)2361 try: 2362 if isSelect:2363 results = cursor.fetchall()2364 except:2365 results = None2366 except (Exception) as error:2367 logger.error("ERROR: Unexpected error: Could not submit request: " + sqlString)2368 logger.error("ERROR Message: " + str(error))2369 success = False2370 finally:2371 connection.commit()2372 cursor.close()2373 if not success:2374 return False2375 elif isSelect:2376 return results2377 else:2378 return None2379def putErrorMetric():2380 # Create CloudWatch client2381 cloudwatch = boto3.client('cloudwatch')2382 # Put custom metrics2383 cloudwatch.put_metric_data(2384 MetricData=[2385 {2386 'MetricName': 'PG_Counter_Metrics_Error_Count',2387 'Dimensions': [2388 {2389 'Name': 'DBInstanceIdentifier',2390 'Value': rds_config.metric_name2391 },2392 ],2393 'Unit': 'None',2394 'Value': 12395 },2396 ],2397 Namespace='PG Counter Metrics'...

Full Screen

Full Screen

cloudwatch_logger.py

Source:cloudwatch_logger.py Github

copy

Full Screen

...17 experiment_id,18 latest_hosted_model_id,19 latest_hosted_model_score20 ):21 self.cw_client.put_metric_data(22 Namespace=experiment_id,23 MetricData=[24 {25 "MetricName": "latest_hosted_model_id_continuous",26 "Timestamp": time.time(),27 "Value": int(latest_hosted_model_id.split('-')[-1])28 }29 ]30 )31 self.cw_client.put_metric_data(32 Namespace=experiment_id,33 MetricData=[34 {35 "MetricName": "latest_hosted_model_score_continuous",36 "Timestamp": time.time(),37 "Value": float(latest_hosted_model_score)38 }39 ]40 )41 42 def publish_latest_training_information(43 self,44 experiment_id,45 latest_trained_model_id,46 latest_trained_model_score47 ):48 self.cw_client.put_metric_data(49 Namespace=experiment_id,50 MetricData=[51 {52 "MetricName": "latest_trained_model_id_continuous",53 "Timestamp": time.time(),54 "Value": int(latest_trained_model_id.split('-')[-1])55 }56 ]57 )58 self.cw_client.put_metric_data(59 Namespace=experiment_id,60 MetricData=[61 {62 "MetricName": "latest_trained_model_score_continuous",63 "Timestamp": time.time(),64 "Value": float(latest_trained_model_score)65 }66 ]67 )68 69 def publish_newly_trained_model_eval_information(70 self,71 experiment_id,72 new_trained_model_id,73 new_trained_model_score74 ):75 self.cw_client.put_metric_data(76 Namespace=experiment_id,77 MetricData=[78 {79 "MetricName": "newly_trained_model_id",80 "Timestamp": time.time(),81 "Value": int(new_trained_model_id.split('-')[-1])82 }83 ]84 )85 self.cw_client.put_metric_data(86 Namespace=experiment_id,87 MetricData=[88 {89 "MetricName": "newly_trained_model_score",90 "Timestamp": time.time(),91 "Value": float(new_trained_model_score)92 }93 ]94 )95 96 def publish_rewards_for_simulation(97 self,98 experiment_id,99 reported_rewards_sum100 ):101 self.cw_client.put_metric_data(102 Namespace=experiment_id,103 MetricData=[104 {105 "MetricName": "reported_rewards_score",106 "Timestamp": time.time(),107 "Value": float(reported_rewards_sum)108 }109 ]110 )111 def create_cloudwatch_dashboard_from_experiment_id(112 self,113 experiment_id114 ):115 cw_json = self.get_cloudwatch_dashboard_json_for_experiment_id(...

Full Screen

Full Screen

frontier_metrics.py

Source:frontier_metrics.py Github

copy

Full Screen

...5 self.namespace = 'atrax/' + self.crawl_job_name6 self.cw = AwsConnections.cloudwatch()7 ### Per Fetcher ###8 def put_fetcher_queues(self, fetcher_id, value):9 self.cw.put_metric_data(namespace=self.namespace,10 name='queues',11 unit='Count',12 dimensions={'fetcher_id': fetcher_id},13 value=value)14 def put_fetcher_active_queues(self, fetcher_id, value):15 self.cw.put_metric_data(namespace=self.namespace,16 name='active_queues',17 unit='Count',18 dimensions={'fetcher_id': fetcher_id},19 value=value)20 def put_fetcher_per_queue_dequeue_rate(self, fetcher_id, value):21 self.cw.put_metric_data(namespace=self.namespace,22 name='per_queue_dequeue_rate',23 unit='Count/Second',24 dimensions={'fetcher_id': fetcher_id},25 value=value)26 def put_fetcher_total_dequeue_rate(self, fetcher_id, value):27 self.cw.put_metric_data(namespace=self.namespace,28 name='total_dequeue_rate',29 unit='Count/Second',30 dimensions={'fetcher_id': fetcher_id},31 value=value)32 ### Frontier ###33 def put_is_scaling(self, value):34 self.cw.put_metric_data(namespace=self.namespace,35 name='is_scaling',36 unit='Count',37 value=1 if value else 0)38 def put_frontier_request_rate(self, value):39 self.cw.put_metric_data(namespace=self.namespace,40 name='frontier_request_rate',41 unit='Count/Second',42 value=value)43 def put_frontier_dequeue_rate(self, value):44 self.cw.put_metric_data(namespace=self.namespace,45 name='frontier_dequeue_rate',46 unit='Count/Second',47 value=value)48 def put_frontier_enqueue_rate(self, value):49 self.cw.put_metric_data(namespace=self.namespace,50 name='frontier_enqueue_rate',51 unit='Count/Second',52 value=value)53 def put_unassigned_queues(self, value):54 self.cw.put_metric_data(namespace=self.namespace,55 name='unassigned_queues',56 unit='Count',57 value=value)58 def put_active_queues(self, value):59 self.cw.put_metric_data(namespace=self.namespace,60 name='active_queues',61 unit='Count',62 value=value)63 def put_available_queues(self, value):64 self.cw.put_metric_data(namespace=self.namespace,65 name='available_queues',66 unit='Count',67 value=value)68 def put_ave_queues_per_consumer(self, value):69 self.cw.put_metric_data(namespace=self.namespace,70 name='ave_queues_per_consumer',71 unit='Count',72 value=value)73 def put_fetchers_needed(self, value):74 self.cw.put_metric_data(namespace=self.namespace,75 name='fetchers_needed',76 unit='Count',77 value=value)78 def put_consumers(self, value):79 self.cw.put_metric_data(namespace=self.namespace,80 name='consumers',81 unit='Count',82 value=value)83 def put_affordable_instances(self, value):84 self.cw.put_metric_data(namespace=self.namespace,85 name='affordable_instances',86 unit='Count',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful