scope.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. package service
  2. import (
  3. "fmt"
  4. "go-admin/app/observe/service/dto"
  5. "go-admin/utils"
  6. )
  7. type WeaveScope struct {
  8. // service.Service
  9. utils.OtService
  10. }
  11. const menuString = `
  12. [
  13. {
  14. "hide_if_empty":false,
  15. "name":"容器/部署",
  16. "options":[
  17. {
  18. "defaultValue":"application",
  19. "id":"system",
  20. "options":[
  21. {
  22. "label":"All",
  23. "value":"all"
  24. },
  25. {
  26. "label":"System containers",
  27. "value":"system"
  28. },
  29. {
  30. "label":"Application containers",
  31. "value":"application"
  32. }
  33. ]
  34. },
  35. {
  36. "defaultValue":"running",
  37. "id":"stopped",
  38. "options":[
  39. {
  40. "label":"Stopped containers",
  41. "value":"stopped"
  42. },
  43. {
  44. "label":"Running containers",
  45. "value":"running"
  46. },
  47. {
  48. "label":"Both",
  49. "value":"both"
  50. }
  51. ]
  52. },
  53. {
  54. "defaultValue":"hide",
  55. "id":"pseudo",
  56. "options":[
  57. {
  58. "label":"显示非容器化",
  59. "value":"show"
  60. },
  61. {
  62. "label":"隐藏非容器化",
  63. "value":"hide"
  64. }
  65. ]
  66. }
  67. ],
  68. "rank":2,
  69. "stats":{
  70. "edge_count":22,
  71. "filtered_nodes":1,
  72. "node_count":300,
  73. "nonpseudo_node_count":297
  74. },
  75. "sub_topologies":[
  76. {
  77. "hide_if_empty":false,
  78. "name":"by DNS name",
  79. "options":[
  80. {
  81. "defaultValue":"application",
  82. "id":"system",
  83. "options":[
  84. {
  85. "label":"All",
  86. "value":"all"
  87. },
  88. {
  89. "label":"System containers",
  90. "value":"system"
  91. },
  92. {
  93. "label":"Application containers",
  94. "value":"application"
  95. }
  96. ]
  97. },
  98. {
  99. "defaultValue":"running",
  100. "id":"stopped",
  101. "options":[
  102. {
  103. "label":"Stopped containers",
  104. "value":"stopped"
  105. },
  106. {
  107. "label":"Running containers",
  108. "value":"running"
  109. },
  110. {
  111. "label":"Both",
  112. "value":"both"
  113. }
  114. ]
  115. },
  116. {
  117. "defaultValue":"hide",
  118. "id":"pseudo",
  119. "options":[
  120. {
  121. "label":"Show uncontained",
  122. "value":"show"
  123. },
  124. {
  125. "label":"Hide uncontained",
  126. "value":"hide"
  127. }
  128. ]
  129. }
  130. ],
  131. "rank":0,
  132. "stats":{
  133. "edge_count":20,
  134. "filtered_nodes":1,
  135. "node_count":252,
  136. "nonpseudo_node_count":249
  137. },
  138. "url":"/api/topology/containers-by-hostname"
  139. },
  140. {
  141. "hide_if_empty":false,
  142. "name":"by image",
  143. "options":[
  144. {
  145. "defaultValue":"application",
  146. "id":"system",
  147. "options":[
  148. {
  149. "label":"All",
  150. "value":"all"
  151. },
  152. {
  153. "label":"System containers",
  154. "value":"system"
  155. },
  156. {
  157. "label":"Application containers",
  158. "value":"application"
  159. }
  160. ]
  161. },
  162. {
  163. "defaultValue":"running",
  164. "id":"stopped",
  165. "options":[
  166. {
  167. "label":"Stopped containers",
  168. "value":"stopped"
  169. },
  170. {
  171. "label":"Running containers",
  172. "value":"running"
  173. },
  174. {
  175. "label":"Both",
  176. "value":"both"
  177. }
  178. ]
  179. },
  180. {
  181. "defaultValue":"hide",
  182. "id":"pseudo",
  183. "options":[
  184. {
  185. "label":"Show uncontained",
  186. "value":"show"
  187. },
  188. {
  189. "label":"Hide uncontained",
  190. "value":"hide"
  191. }
  192. ]
  193. }
  194. ],
  195. "rank":0,
  196. "stats":{
  197. "edge_count":22,
  198. "filtered_nodes":1,
  199. "node_count":34,
  200. "nonpseudo_node_count":31
  201. },
  202. "url":"/api/topology/containers-by-image"
  203. }
  204. ],
  205. "url":"/api/topology/containers"
  206. },
  207. {
  208. "hide_if_empty":false,
  209. "name":"服务拓扑",
  210. "options":null,
  211. "rank":4,
  212. "stats":{
  213. "edge_count":3,
  214. "filtered_nodes":0,
  215. "node_count":3,
  216. "nonpseudo_node_count":1
  217. },
  218. "sub_topologies":[
  219. {
  220. "hide_if_empty":false,
  221. "name":"Weave Net",
  222. "options":null,
  223. "rank":0,
  224. "stats":{
  225. "edge_count":0,
  226. "filtered_nodes":0,
  227. "node_count":1,
  228. "nonpseudo_node_count":1
  229. },
  230. "url":"/api/topology/weave"
  231. }
  232. ],
  233. "url":"/api/v1/ws/topology/services/ws?t=5s&app_alias=%s"
  234. },
  235. {
  236. "hide_if_empty":true,
  237. "name":"Pods",
  238. "options":[
  239. {
  240. "defaultValue":"hide",
  241. "id":"snapshot",
  242. "options":[
  243. {
  244. "label":"Show snapshots",
  245. "value":"show"
  246. },
  247. {
  248. "label":"Hide snapshots",
  249. "value":"hide"
  250. }
  251. ]
  252. },
  253. {
  254. "defaultValue":"hide",
  255. "id":"storage",
  256. "options":[
  257. {
  258. "label":"Show storage",
  259. "value":"show"
  260. },
  261. {
  262. "label":"Hide storage",
  263. "value":"hide"
  264. }
  265. ]
  266. },
  267. {
  268. "defaultValue":"hide",
  269. "id":"pseudo",
  270. "options":[
  271. {
  272. "label":"Show unmanaged",
  273. "value":"show"
  274. },
  275. {
  276. "label":"Hide unmanaged",
  277. "value":"hide"
  278. }
  279. ]
  280. }
  281. ],
  282. "rank":3,
  283. "stats":{
  284. "edge_count":0,
  285. "filtered_nodes":0,
  286. "node_count":0,
  287. "nonpseudo_node_count":0
  288. },
  289. "sub_topologies":[
  290. {
  291. "hide_if_empty":true,
  292. "name":"Controllers",
  293. "options":[
  294. {
  295. "defaultValue":"hide",
  296. "id":"pseudo",
  297. "options":[
  298. {
  299. "label":"Show unmanaged",
  300. "value":"show"
  301. },
  302. {
  303. "label":"Hide unmanaged",
  304. "value":"hide"
  305. }
  306. ]
  307. }
  308. ],
  309. "rank":0,
  310. "stats":{
  311. "edge_count":0,
  312. "filtered_nodes":0,
  313. "node_count":0,
  314. "nonpseudo_node_count":0
  315. },
  316. "url":"/api/topology/kube-controllers/%s"
  317. },
  318. {
  319. "hide_if_empty":true,
  320. "name":"Services",
  321. "options":[
  322. {
  323. "defaultValue":"hide",
  324. "id":"pseudo",
  325. "options":[
  326. {
  327. "label":"Show unmanaged",
  328. "value":"show"
  329. },
  330. {
  331. "label":"Hide unmanaged",
  332. "value":"hide"
  333. }
  334. ]
  335. }
  336. ],
  337. "rank":0,
  338. "stats":{
  339. "edge_count":0,
  340. "filtered_nodes":0,
  341. "node_count":0,
  342. "nonpseudo_node_count":0
  343. },
  344. "url":"/api/topology/services"
  345. }
  346. ],
  347. "url":"/api/topology/pods"
  348. },
  349. {
  350. "hide_if_empty":true,
  351. "name":"进程",
  352. "options":[
  353. {
  354. "defaultValue":"hide",
  355. "id":"unconnected",
  356. "options":[
  357. {
  358. "label":"显示未连接",
  359. "value":"show"
  360. },
  361. {
  362. "label":"隐藏未连接",
  363. "value":"hide"
  364. }
  365. ]
  366. }
  367. ],
  368. "rank":1,
  369. "stats":{
  370. "edge_count":24,
  371. "filtered_nodes":0,
  372. "node_count":316,
  373. "nonpseudo_node_count":314
  374. },
  375. "url":"/api/topology/processes"
  376. },
  377. {
  378. "hide_if_empty":true,
  379. "name":"Services",
  380. "options":[
  381. {
  382. "defaultValue":"hide",
  383. "id":"pseudo",
  384. "options":[
  385. {
  386. "label":"Show unmanaged",
  387. "value":"show"
  388. },
  389. {
  390. "label":"Hide unmanaged",
  391. "value":"hide"
  392. }
  393. ]
  394. }
  395. ],
  396. "rank":3,
  397. "stats":{
  398. "edge_count":0,
  399. "filtered_nodes":0,
  400. "node_count":0,
  401. "nonpseudo_node_count":0
  402. },
  403. "url":"/api/topology/swarm-services"
  404. },
  405. {
  406. "hide_if_empty":true,
  407. "name":"Tasks",
  408. "options":[
  409. {
  410. "defaultValue":"hide",
  411. "id":"pseudo",
  412. "options":[
  413. {
  414. "label":"Show unmanaged",
  415. "value":"show"
  416. },
  417. {
  418. "label":"Hide unmanaged",
  419. "value":"hide"
  420. }
  421. ]
  422. }
  423. ],
  424. "rank":3,
  425. "stats":{
  426. "edge_count":0,
  427. "filtered_nodes":0,
  428. "node_count":0,
  429. "nonpseudo_node_count":0
  430. },
  431. "sub_topologies":[
  432. {
  433. "hide_if_empty":true,
  434. "name":"Services",
  435. "options":[
  436. {
  437. "defaultValue":"hide",
  438. "id":"pseudo",
  439. "options":[
  440. {
  441. "label":"Show unmanaged",
  442. "value":"show"
  443. },
  444. {
  445. "label":"Hide unmanaged",
  446. "value":"hide"
  447. }
  448. ]
  449. }
  450. ],
  451. "rank":0,
  452. "stats":{
  453. "edge_count":0,
  454. "filtered_nodes":0,
  455. "node_count":0,
  456. "nonpseudo_node_count":0
  457. },
  458. "url":"/api/topology/ecs-services"
  459. }
  460. ],
  461. "url":"/api/topology/ecs-tasks"
  462. }
  463. ]
  464. `
  465. const menuStringServiceOnly = `
  466. [
  467. {
  468. "hide_if_empty":false,
  469. "name":"服务拓扑",
  470. "options":null,
  471. "rank":4,
  472. "stats":{
  473. "edge_count":19,
  474. "filtered_nodes":0,
  475. "node_count":16,
  476. "nonpseudo_node_count":16
  477. },
  478. "sub_topologies":[],
  479. "url":"/api/v1/ws/topology/services"
  480. }
  481. ]
  482. `
  483. // GetPage 获取UrlMapping列表
  484. func (e *WeaveScope) GetMenu(req *dto.ScopeMenuResp) string {
  485. return fmt.Sprintf(menuStringServiceOnly) // req.AppAlias, req.Live,
  486. // req.AppAlias, req.Live,
  487. }
  488. //"url":"/api/v1/ws/topology/services/ws?system=application&t=5s&app_alias=%s&start_time=%v&end_time=%v&live=%v"
  489. // "url":"/api/v1/ss/topology/services/ws?system=application&t=5s&app_alias=%s&live=%v"