metrics_table.sql 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. create database if not exists ob_metrics;
  2. create table if not exists ob_metrics.public.service_metrics_15s
  3. (
  4. timestamp timestamp,
  5. app_name varchar(256),
  6. service_name varchar(512),
  7. apdex float,
  8. http_code_300_count int,
  9. http_code_400_count int,
  10. http_code_500_count int,
  11. span_status_error_count int,
  12. exception_count int,
  13. max_latency bigint,
  14. min_latency bigint,
  15. avg_latency bigint,
  16. request_count bigint,
  17. rpm bigint,
  18. count_le_500 bigint,
  19. count_le_1000 bigint,
  20. count_le_5000 bigint,
  21. quantile_50 bigint,
  22. quantile_90 float,
  23. quantile_95 float,
  24. quantile_99 float
  25. );
  26. SELECT create_hypertable('service_metrics_15s', by_range('timestamp'));
  27. create table if not exists ob_metrics.public.service_instance_metrics_15s
  28. (
  29. timestamp timestamp,
  30. app_name varchar(256),
  31. service_name varchar(512),
  32. apdex float,
  33. http_code_300_count int,
  34. http_code_400_count int,
  35. http_code_500_count int,
  36. span_status_error_count int,
  37. exception_count int,
  38. max_latency bigint,
  39. min_latency bigint,
  40. avg_latency bigint,
  41. request_count bigint,
  42. rpm bigint,
  43. count_le_500 bigint,
  44. count_le_1000 bigint,
  45. count_le_5000 bigint,
  46. quantile_50 bigint,
  47. quantile_90 float,
  48. quantile_95 float,
  49. quantile_99 float,
  50. instanceID varchar(512)
  51. );
  52. SELECT create_hypertable('service_instance_metrics_15s', by_range('timestamp'));
  53. create table if not exists ob_metrics.public.endpoint_metrics_15s
  54. (
  55. timestamp timestamp,
  56. app_name varchar(256),
  57. service_name varchar(512),
  58. apdex float,
  59. http_code_300_count int,
  60. http_code_400_count int,
  61. http_code_500_count int,
  62. span_status_error_count int,
  63. exception_count int,
  64. max_latency bigint,
  65. min_latency bigint,
  66. avg_latency bigint,
  67. request_count bigint,
  68. rpm bigint,
  69. count_le_500 bigint,
  70. count_le_1000 bigint,
  71. count_le_5000 bigint,
  72. quantile_50 bigint,
  73. quantile_90 float,
  74. quantile_95 float,
  75. quantile_99 float,
  76. instanceID varchar(512),
  77. endpoint varchar(512)
  78. );
  79. SELECT create_hypertable('endpoint_metrics_15s', by_range('timestamp'));
  80. create table if not exists ob_metrics.public.service_metrics_5m
  81. (
  82. timestamp timestamp,
  83. app_name varchar(256),
  84. service_name varchar(512),
  85. apdex float,
  86. http_code_300_count int,
  87. http_code_400_count int,
  88. http_code_500_count int,
  89. span_status_error_count int,
  90. exception_count int,
  91. max_latency bigint,
  92. min_latency bigint,
  93. avg_latency bigint,
  94. request_count bigint,
  95. rpm bigint,
  96. count_le_500 bigint,
  97. count_le_1000 bigint,
  98. count_le_5000 bigint,
  99. quantile_50 bigint,
  100. quantile_90 float,
  101. quantile_95 float,
  102. quantile_99 float
  103. );
  104. SELECT create_hypertable('service_metrics_5m', by_range('timestamp'));
  105. create table if not exists ob_metrics.public.service_instance_metrics_5m
  106. (
  107. timestamp timestamp,
  108. app_name varchar(256),
  109. service_name varchar(512),
  110. apdex float,
  111. http_code_300_count int,
  112. http_code_400_count int,
  113. http_code_500_count int,
  114. span_status_error_count int,
  115. exception_count int,
  116. max_latency bigint,
  117. min_latency bigint,
  118. avg_latency bigint,
  119. request_count bigint,
  120. rpm bigint,
  121. count_le_500 bigint,
  122. count_le_1000 bigint,
  123. count_le_5000 bigint,
  124. quantile_50 bigint,
  125. quantile_90 float,
  126. quantile_95 float,
  127. quantile_99 float,
  128. instanceID varchar(512)
  129. );
  130. SELECT create_hypertable('service_instance_metrics_5m', by_range('timestamp'));
  131. create table if not exists ob_metrics.public.endpoint_metrics_5m
  132. (
  133. timestamp timestamp,
  134. app_name varchar(256),
  135. service_name varchar(512),
  136. apdex float,
  137. http_code_300_count int,
  138. http_code_400_count int,
  139. http_code_500_count int,
  140. span_status_error_count int,
  141. exception_count int,
  142. max_latency bigint,
  143. min_latency bigint,
  144. avg_latency bigint,
  145. request_count bigint,
  146. rpm bigint,
  147. count_le_500 bigint,
  148. count_le_1000 bigint,
  149. count_le_5000 bigint,
  150. quantile_50 bigint,
  151. quantile_90 float,
  152. quantile_95 float,
  153. quantile_99 float,
  154. instanceID varchar(512),
  155. endpoint varchar(512)
  156. );
  157. SELECT create_hypertable('endpoint_metrics_5m', by_range('timestamp'));
  158. create table if not exists ob_metrics.public.service_metrics_20m
  159. (
  160. timestamp timestamp,
  161. app_name varchar(256),
  162. service_name varchar(512),
  163. apdex float,
  164. http_code_300_count int,
  165. http_code_400_count int,
  166. http_code_500_count int,
  167. span_status_error_count int,
  168. exception_count int,
  169. max_latency bigint,
  170. min_latency bigint,
  171. avg_latency bigint,
  172. request_count bigint,
  173. rpm bigint,
  174. count_le_500 bigint,
  175. count_le_1000 bigint,
  176. count_le_5000 bigint,
  177. quantile_50 bigint,
  178. quantile_90 float,
  179. quantile_95 float,
  180. quantile_99 float
  181. );
  182. SELECT create_hypertable('service_metrics_20m', by_range('timestamp'));
  183. create table if not exists ob_metrics.public.service_instance_metrics_20m
  184. (
  185. timestamp timestamp,
  186. app_name varchar(256),
  187. service_name varchar(512),
  188. apdex float,
  189. http_code_300_count int,
  190. http_code_400_count int,
  191. http_code_500_count int,
  192. span_status_error_count int,
  193. exception_count int,
  194. max_latency bigint,
  195. min_latency bigint,
  196. avg_latency bigint,
  197. request_count bigint,
  198. rpm bigint,
  199. count_le_500 bigint,
  200. count_le_1000 bigint,
  201. count_le_5000 bigint,
  202. quantile_50 bigint,
  203. quantile_90 float,
  204. quantile_95 float,
  205. quantile_99 float,
  206. instanceID varchar(512)
  207. );
  208. SELECT create_hypertable('service_instance_metrics_20m', by_range('timestamp'));
  209. create table if not exists ob_metrics.public.endpoint_metrics_20m
  210. (
  211. timestamp timestamp,
  212. app_name varchar(256),
  213. service_name varchar(512),
  214. apdex float,
  215. http_code_300_count int,
  216. http_code_400_count int,
  217. http_code_500_count int,
  218. span_status_error_count int,
  219. exception_count int,
  220. max_latency bigint,
  221. min_latency bigint,
  222. avg_latency bigint,
  223. request_count bigint,
  224. rpm bigint,
  225. count_le_500 bigint,
  226. count_le_1000 bigint,
  227. count_le_5000 bigint,
  228. quantile_50 bigint,
  229. quantile_90 float,
  230. quantile_95 float,
  231. quantile_99 float,
  232. instanceID varchar(512),
  233. endpoint varchar(512)
  234. );
  235. SELECT create_hypertable('endpoint_metrics_20m', by_range('timestamp'));
  236. create table if not exists ob_metrics.public.service_metrics_1h
  237. (
  238. timestamp timestamp,
  239. app_name varchar(256),
  240. service_name varchar(512),
  241. apdex float,
  242. http_code_300_count int,
  243. http_code_400_count int,
  244. http_code_500_count int,
  245. span_status_error_count int,
  246. exception_count int,
  247. max_latency bigint,
  248. min_latency bigint,
  249. avg_latency bigint,
  250. request_count bigint,
  251. rpm bigint,
  252. count_le_500 bigint,
  253. count_le_1000 bigint,
  254. count_le_5000 bigint,
  255. quantile_50 bigint,
  256. quantile_90 float,
  257. quantile_95 float,
  258. quantile_99 float
  259. );
  260. SELECT create_hypertable('service_metrics_1h', by_range('timestamp'));
  261. create table if not exists ob_metrics.public.service_instance_metrics_1h
  262. (
  263. timestamp timestamp,
  264. app_name varchar(256),
  265. service_name varchar(512),
  266. apdex float,
  267. http_code_300_count int,
  268. http_code_400_count int,
  269. http_code_500_count int,
  270. span_status_error_count int,
  271. exception_count int,
  272. max_latency bigint,
  273. min_latency bigint,
  274. avg_latency bigint,
  275. request_count bigint,
  276. rpm bigint,
  277. count_le_500 bigint,
  278. count_le_1000 bigint,
  279. count_le_5000 bigint,
  280. quantile_50 bigint,
  281. quantile_90 float,
  282. quantile_95 float,
  283. quantile_99 float,
  284. instanceID varchar(512)
  285. );
  286. SELECT create_hypertable('service_instance_metrics_1h', by_range('timestamp'));
  287. create table if not exists ob_metrics.public.endpoint_metrics_1h
  288. (
  289. timestamp timestamp,
  290. app_name varchar(256),
  291. service_name varchar(512),
  292. apdex float,
  293. http_code_300_count int,
  294. http_code_400_count int,
  295. http_code_500_count int,
  296. span_status_error_count int,
  297. exception_count int,
  298. max_latency bigint,
  299. min_latency bigint,
  300. avg_latency bigint,
  301. request_count bigint,
  302. rpm bigint,
  303. count_le_500 bigint,
  304. count_le_1000 bigint,
  305. count_le_5000 bigint,
  306. quantile_50 bigint,
  307. quantile_90 float,
  308. quantile_95 float,
  309. quantile_99 float,
  310. instanceID varchar(512),
  311. endpoint varchar(512)
  312. );
  313. SELECT create_hypertable('endpoint_metrics_1h', by_range('timestamp'));
  314. SELECT add_retention_policy('service_metrics_15s', INTERVAL '10 days');
  315. SELECT add_retention_policy('service_metrics_5m', INTERVAL '10 days');
  316. SELECT add_retention_policy('service_metrics_20m', INTERVAL '10 days');
  317. SELECT add_retention_policy('service_metrics_1h', INTERVAL '10 days');
  318. SELECT add_retention_policy('service_instance_metrics_15s', INTERVAL '10 days');
  319. SELECT add_retention_policy('service_instance_metrics_5m', INTERVAL '10 days');
  320. SELECT add_retention_policy('service_instance_metrics_20m', INTERVAL '10 days');
  321. SELECT add_retention_policy('service_instance_metrics_1h', INTERVAL '10 days');
  322. SELECT add_retention_policy('endpoint_metrics_15s', INTERVAL '10 days');
  323. SELECT add_retention_policy('endpoint_metrics_5m', INTERVAL '10 days');
  324. SELECT add_retention_policy('endpoint_metrics_20m', INTERVAL '10 days');
  325. SELECT add_retention_policy('endpoint_metrics_1h', INTERVAL '10 days');