adjust-dashboard-for-channel.py 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/usr/bin/env python3
  2. #
  3. # Adjusts the testnet monitor dashboard for the specified release channel
  4. #
  5. import sys
  6. import json
  7. if len(sys.argv) != 3:
  8. print('Error: Dashboard or Channel not specified')
  9. sys.exit(1)
  10. dashboard_json = sys.argv[1]
  11. channel = sys.argv[2]
  12. if channel not in ['edge', 'beta', 'stable', 'local']:
  13. print('Error: Unknown channel:', channel)
  14. sys.exit(2)
  15. with open(dashboard_json, 'r') as read_file:
  16. data = json.load(read_file)
  17. if channel == 'local':
  18. data['title'] = 'Local Cluster Monitor'
  19. data['uid'] = 'local'
  20. data['links'] = []
  21. data['templating']['list'] = [{'current': {'text': '$datasource',
  22. 'value': '$datasource'},
  23. 'hide': 1,
  24. 'label': 'Data Source',
  25. 'name': 'datasource',
  26. 'options': [],
  27. 'query': 'influxdb',
  28. 'refresh': 1,
  29. 'regex': '',
  30. 'type': 'datasource'},
  31. {'allValue': None,
  32. 'current': {'text': 'testnet',
  33. 'value': 'testnet'},
  34. 'hide': 1,
  35. 'includeAll': False,
  36. 'label': 'Testnet',
  37. 'multi': False,
  38. 'name': 'testnet',
  39. 'options': [{'selected': True,
  40. 'text': 'testnet',
  41. 'value': 'testnet'}],
  42. 'query': 'testnet',
  43. 'type': 'custom'},
  44. {'allValue': ".*",
  45. 'datasource': '$datasource',
  46. 'hide': 0,
  47. 'includeAll': True,
  48. 'label': 'HostID',
  49. 'multi': False,
  50. 'name': 'hostid',
  51. 'options': [],
  52. 'query': 'SELECT DISTINCT(\"id\") FROM \"$testnet\".\"autogen\".\"validator-new\" ',
  53. 'refresh': 2,
  54. 'regex': '',
  55. 'sort': 1,
  56. 'tagValuesQuery': '',
  57. 'tags': [],
  58. 'tagsQuery': '',
  59. 'type': 'query',
  60. 'useTags': False}]
  61. elif channel == 'stable':
  62. # Stable dashboard only allows the user to select between public clusters
  63. data['title'] = 'Cluster Telemetry'
  64. data['uid'] = 'monitor'
  65. data['templating']['list'] = [{'current': {'text': '$datasource',
  66. 'value': '$datasource'},
  67. 'hide': 1,
  68. 'label': 'Data Source',
  69. 'name': 'datasource',
  70. 'options': [],
  71. 'query': 'influxdb',
  72. 'refresh': 1,
  73. 'regex': '',
  74. 'type': 'datasource'},
  75. {'allValue': None,
  76. 'current': {'text': 'Developer Testnet',
  77. 'value': 'devnet'},
  78. 'hide': 1,
  79. 'includeAll': False,
  80. 'label': 'Testnet',
  81. 'multi': False,
  82. 'name': 'testnet',
  83. 'options': [{'selected': True,
  84. 'text': 'Developer Testnet',
  85. 'value': 'devnet'},
  86. {'selected': False,
  87. 'text': 'Mainnet Beta',
  88. 'value': 'mainnet-beta'},
  89. {'selected': False,
  90. 'text': 'Tour de SOL Testnet',
  91. 'value': 'tds'},
  92. {'selected': False,
  93. 'text': 'Soft Launch Testnet',
  94. 'value': 'cluster'}],
  95. 'query': 'devnet,mainnet-beta,tds,cluster',
  96. 'type': 'custom'},
  97. {'allValue': ".*",
  98. 'datasource': '$datasource',
  99. 'hide': 0,
  100. 'includeAll': True,
  101. 'label': 'HostID',
  102. 'multi': False,
  103. 'name': 'hostid',
  104. 'options': [],
  105. 'query': 'SELECT DISTINCT(\"id\") FROM \"$testnet\".\"autogen\".\"validator-new\" ',
  106. 'refresh': 2,
  107. 'regex': '',
  108. 'sort': 1,
  109. 'tagValuesQuery': '',
  110. 'tags': [],
  111. 'tagsQuery': '',
  112. 'type': 'query',
  113. 'useTags': False}]
  114. else:
  115. # Non-stable dashboard includes all the dev clusters
  116. data['title'] = 'Cluster Telemetry ({})'.format(channel)
  117. data['uid'] = 'monitor-' + channel
  118. data['templating']['list'] = [{'current': {'text': '$datasource',
  119. 'value': '$datasource'},
  120. 'hide': 1,
  121. 'label': 'Data Source',
  122. 'name': 'datasource',
  123. 'options': [],
  124. 'query': 'influxdb',
  125. 'refresh': 1,
  126. 'regex': '',
  127. 'type': 'datasource'},
  128. {'allValue': ".*",
  129. 'current': {'text': 'Developer Testnet',
  130. 'value': 'devnet'},
  131. 'datasource': '$datasource',
  132. 'hide': 1,
  133. 'includeAll': False,
  134. 'label': 'Testnet',
  135. 'multi': False,
  136. 'name': 'testnet',
  137. 'options': [],
  138. 'query': 'show databases',
  139. 'refresh': 1,
  140. 'regex': '(devnet|cluster|tds|mainnet-beta|testnet.*)',
  141. 'sort': 1,
  142. 'tagValuesQuery': '',
  143. 'tags': [],
  144. 'tagsQuery': '',
  145. 'type': 'query',
  146. 'useTags': False},
  147. {'allValue': ".*",
  148. 'datasource': '$datasource',
  149. 'hide': 0,
  150. 'includeAll': True,
  151. 'label': 'HostID',
  152. 'multi': False,
  153. 'name': 'hostid',
  154. 'options': [],
  155. 'query': 'SELECT DISTINCT(\"id\") FROM \"$testnet\".\"autogen\".\"validator-new\" ',
  156. 'refresh': 2,
  157. 'regex': '',
  158. 'sort': 1,
  159. 'tagValuesQuery': '',
  160. 'tags': [],
  161. 'tagsQuery': '',
  162. 'type': 'query',
  163. 'useTags': False}]
  164. with open(dashboard_json, 'w') as write_file:
  165. json.dump(data, write_file, indent=2)