@perses-dev/prometheus-plugin 0.50.2 → 0.51.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (434) hide show
  1. package/LICENSE +183 -183
  2. package/README.md +41 -0
  3. package/__mf/css/async/2341.dacad691.css +1 -0
  4. package/__mf/css/async/5263.dacad691.css +1 -0
  5. package/__mf/css/async/6759.dacad691.css +1 -0
  6. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  7. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  8. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  9. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  10. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  11. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  12. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  13. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  17. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  18. package/__mf/js/622.f7592106.js +5 -0
  19. package/__mf/js/Prometheus.328aad7c.js +5 -0
  20. package/__mf/js/async/1465.3b5e12d5.js +1 -0
  21. package/__mf/js/async/1495.6c8b8071.js +1 -0
  22. package/__mf/js/async/1620.6376bd14.js +2 -0
  23. package/__mf/js/async/1620.6376bd14.js.LICENSE.txt +9 -0
  24. package/__mf/js/async/1864.df7c4beb.js +1 -0
  25. package/__mf/js/async/1950.704c331e.js +1 -0
  26. package/__mf/js/async/1964.95da06f6.js +2 -0
  27. package/__mf/js/async/1964.95da06f6.js.LICENSE.txt +9 -0
  28. package/__mf/js/async/1996.01084c88.js +2 -0
  29. package/__mf/js/async/1996.01084c88.js.LICENSE.txt +24 -0
  30. package/__mf/js/async/212.bd5d617a.js +1 -0
  31. package/__mf/js/async/2316.fec4907a.js +1 -0
  32. package/__mf/js/async/232.f3523a60.js +1 -0
  33. package/__mf/js/async/2569.daf868a6.js +10 -0
  34. package/__mf/js/async/2569.daf868a6.js.LICENSE.txt +27 -0
  35. package/__mf/js/async/2675.c3b73822.js +1 -0
  36. package/__mf/js/async/3224.23f0dccf.js +1 -0
  37. package/__mf/js/async/3355.a4dbcdb0.js +1 -0
  38. package/__mf/js/async/3436.97c926a4.js +1 -0
  39. package/__mf/js/async/3818.dde21d04.js +1 -0
  40. package/__mf/js/async/3871.6915e369.js +1 -0
  41. package/__mf/js/async/3960.129d5ef5.js +2 -0
  42. package/__mf/js/async/3960.129d5ef5.js.LICENSE.txt +8 -0
  43. package/__mf/js/async/4075.b77ca1c7.js +1 -0
  44. package/__mf/js/async/4238.8e4d29d5.js +1 -0
  45. package/__mf/js/async/4323.4266fd6a.js +1 -0
  46. package/__mf/js/async/4421.1bcc1637.js +1 -0
  47. package/__mf/js/async/4489.3361e7bc.js +29 -0
  48. package/__mf/js/async/4489.3361e7bc.js.LICENSE.txt +59 -0
  49. package/__mf/js/async/5214.027c4332.js +1 -0
  50. package/__mf/js/async/5345.8c2e4b4a.js +1 -0
  51. package/__mf/js/async/537.6911ea2e.js +1 -0
  52. package/__mf/js/async/5387.fd6e16d6.js +1 -0
  53. package/__mf/js/async/5654.ecb41aea.js +38 -0
  54. package/__mf/js/async/5724.6ee6ec51.js +1 -0
  55. package/__mf/js/async/5774.9b0b6be1.js +1 -0
  56. package/__mf/js/async/5790.2273e061.js +1 -0
  57. package/__mf/js/async/5913.9d30fd07.js +73 -0
  58. package/__mf/js/async/5913.9d30fd07.js.LICENSE.txt +19 -0
  59. package/__mf/js/async/5914.bd342d22.js +74 -0
  60. package/__mf/js/async/5981.40bed0d0.js +2 -0
  61. package/__mf/js/async/5981.40bed0d0.js.LICENSE.txt +8 -0
  62. package/__mf/js/async/6292.7b8efa78.js +1 -0
  63. package/__mf/js/async/6333.865a46e0.js +2 -0
  64. package/__mf/js/async/6333.865a46e0.js.LICENSE.txt +9 -0
  65. package/__mf/js/async/6377.ca974d89.js +2 -0
  66. package/__mf/js/async/6377.ca974d89.js.LICENSE.txt +32 -0
  67. package/__mf/js/async/6770.adb1c939.js +1 -0
  68. package/__mf/js/async/684.ca510333.js +1 -0
  69. package/__mf/js/async/694.f861d67c.js +1 -0
  70. package/__mf/js/async/7272.a763aa92.js +1 -0
  71. package/__mf/js/async/738.aca54e25.js +1 -0
  72. package/__mf/js/async/7740.0c5363fd.js +1 -0
  73. package/__mf/js/async/8265.b9e2c31e.js +1 -0
  74. package/__mf/js/async/8488.5237550f.js +1 -0
  75. package/__mf/js/async/8587.4891ea90.js +1 -0
  76. package/__mf/js/async/8610.8300df79.js +1 -0
  77. package/__mf/js/async/87.fdc843ac.js +1 -0
  78. package/__mf/js/async/8930.9fbbc975.js +1 -0
  79. package/__mf/js/async/8997.18901f45.js +28 -0
  80. package/__mf/js/async/9173.e8fbead5.js +2 -0
  81. package/__mf/js/async/9173.e8fbead5.js.LICENSE.txt +19 -0
  82. package/__mf/js/async/__federation_expose_PrometheusDatasource.f6f57299.js +1 -0
  83. package/__mf/js/async/__federation_expose_PrometheusExplorer.5fcf955a.js +1 -0
  84. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86d0ad5a.js +1 -0
  85. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.b2893484.js +1 -0
  86. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.cd16f6e8.js +1 -0
  87. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.eb9eefa6.js +1 -0
  88. package/__mf/js/main.154a5b65.js +1 -0
  89. package/lib/bootstrap.d.ts +2 -0
  90. package/lib/bootstrap.d.ts.map +1 -0
  91. package/lib/bootstrap.js +19 -0
  92. package/lib/bootstrap.js.map +1 -0
  93. package/lib/cjs/bootstrap.js +26 -0
  94. package/{dist → lib}/cjs/components/PromQLEditor.js +9 -7
  95. package/lib/cjs/components/TreeNode.js +492 -0
  96. package/{dist → lib}/cjs/components/promql/ast.js +21 -21
  97. package/lib/cjs/components/promql/functionSignatures.js +651 -0
  98. package/lib/cjs/components/promql/serialize.js +88 -0
  99. package/{dist → lib}/cjs/components/promql/utils.js +12 -1
  100. package/{dist/cjs/components/parse.js → lib/cjs/components/query.js} +37 -4
  101. package/lib/cjs/env.d.js +14 -0
  102. package/lib/cjs/explore/PrometheusExplorer.js +203 -0
  103. package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +268 -0
  104. package/lib/cjs/explore/PrometheusMetricsFinder/display/MetricChip.js +61 -0
  105. package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +179 -0
  106. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +231 -0
  107. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +97 -0
  108. package/{dist/cjs/plugins/prometheus-time-series-query → lib/cjs/explore/PrometheusMetricsFinder}/index.js +1 -1
  109. package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +235 -0
  110. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +144 -0
  111. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +423 -0
  112. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +53 -0
  113. package/lib/cjs/explore/PrometheusMetricsFinder/types.js +25 -0
  114. package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +203 -0
  115. package/lib/cjs/explore/index.js +19 -0
  116. package/lib/cjs/getPluginModule.js +27 -0
  117. package/lib/cjs/index-federation.js +55 -0
  118. package/lib/cjs/index.js +28 -0
  119. package/{dist → lib}/cjs/model/api-types.js +1 -1
  120. package/{dist → lib}/cjs/model/prometheus-client.js +1 -1
  121. package/lib/cjs/plugins/PrometheusDatasourceEditor.js +109 -0
  122. package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +34 -0
  123. package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +38 -0
  124. package/lib/cjs/plugins/PrometheusPromQLVariable.js +42 -0
  125. package/lib/cjs/plugins/index.js +26 -0
  126. package/{dist → lib}/cjs/plugins/prometheus-datasource.js +9 -9
  127. package/{dist → lib}/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +11 -9
  128. package/{dist → lib}/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +51 -29
  129. package/lib/cjs/plugins/prometheus-time-series-query/index.js +35 -0
  130. package/{dist → lib}/cjs/plugins/prometheus-variables.js +25 -101
  131. package/{dist → lib}/cjs/plugins/variable.js +1 -2
  132. package/lib/cjs/setup-tests.js +19 -0
  133. package/{dist → lib}/cjs/utils/utils.js +1 -2
  134. package/lib/components/PromQLEditor.d.ts.map +1 -0
  135. package/{dist → lib}/components/PromQLEditor.js +9 -7
  136. package/lib/components/PromQLEditor.js.map +1 -0
  137. package/lib/components/TreeNode.d.ts +15 -0
  138. package/lib/components/TreeNode.d.ts.map +1 -0
  139. package/lib/components/TreeNode.js +479 -0
  140. package/lib/components/TreeNode.js.map +1 -0
  141. package/lib/components/index.d.ts.map +1 -0
  142. package/lib/components/index.js.map +1 -0
  143. package/lib/components/promql/ast.d.ts.map +1 -0
  144. package/{dist → lib}/components/promql/ast.js +21 -21
  145. package/lib/components/promql/ast.js.map +1 -0
  146. package/{dist → lib}/components/promql/format.d.ts +1 -1
  147. package/lib/components/promql/format.d.ts.map +1 -0
  148. package/lib/components/promql/format.js.map +1 -0
  149. package/lib/components/promql/functionSignatures.d.ts +3 -0
  150. package/lib/components/promql/functionSignatures.d.ts.map +1 -0
  151. package/lib/components/promql/functionSignatures.js +643 -0
  152. package/lib/components/promql/functionSignatures.js.map +1 -0
  153. package/lib/components/promql/serialize.d.ts +4 -0
  154. package/lib/components/promql/serialize.d.ts.map +1 -0
  155. package/lib/components/promql/serialize.js +80 -0
  156. package/lib/components/promql/serialize.js.map +1 -0
  157. package/{dist → lib}/components/promql/utils.d.ts +1 -0
  158. package/lib/components/promql/utils.d.ts.map +1 -0
  159. package/{dist → lib}/components/promql/utils.js +9 -1
  160. package/lib/components/promql/utils.js.map +1 -0
  161. package/lib/components/query.d.ts +6 -0
  162. package/lib/components/query.d.ts.map +1 -0
  163. package/{dist/components/parse.js → lib/components/query.js} +27 -2
  164. package/lib/components/query.js.map +1 -0
  165. package/lib/env.d.js +15 -0
  166. package/lib/env.d.js.map +1 -0
  167. package/lib/explore/PrometheusExplorer.d.ts +3 -0
  168. package/lib/explore/PrometheusExplorer.d.ts.map +1 -0
  169. package/lib/explore/PrometheusExplorer.js +190 -0
  170. package/lib/explore/PrometheusExplorer.js.map +1 -0
  171. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts +31 -0
  172. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts.map +1 -0
  173. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +244 -0
  174. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -0
  175. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.d.ts +4 -0
  176. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.d.ts.map +1 -0
  177. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +53 -0
  178. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -0
  179. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.d.ts +27 -0
  180. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.d.ts.map +1 -0
  181. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +158 -0
  182. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -0
  183. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.d.ts +23 -0
  184. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.d.ts.map +1 -0
  185. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +209 -0
  186. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -0
  187. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts +13 -0
  188. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +1 -0
  189. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +84 -0
  190. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -0
  191. package/lib/explore/PrometheusMetricsFinder/index.d.ts +2 -0
  192. package/lib/explore/PrometheusMetricsFinder/index.d.ts.map +1 -0
  193. package/{dist/model/api-types.js → lib/explore/PrometheusMetricsFinder/index.js} +2 -2
  194. package/lib/explore/PrometheusMetricsFinder/index.js.map +1 -0
  195. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.d.ts +23 -0
  196. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.d.ts.map +1 -0
  197. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +214 -0
  198. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -0
  199. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts +28 -0
  200. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts.map +1 -0
  201. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +125 -0
  202. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +1 -0
  203. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts +25 -0
  204. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts.map +1 -0
  205. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +399 -0
  206. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +1 -0
  207. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts +12 -0
  208. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts.map +1 -0
  209. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +45 -0
  210. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +1 -0
  211. package/lib/explore/PrometheusMetricsFinder/types.d.ts +22 -0
  212. package/lib/explore/PrometheusMetricsFinder/types.d.ts.map +1 -0
  213. package/lib/explore/PrometheusMetricsFinder/types.js +17 -0
  214. package/lib/explore/PrometheusMetricsFinder/types.js.map +1 -0
  215. package/lib/explore/PrometheusMetricsFinder/utils.d.ts +22 -0
  216. package/lib/explore/PrometheusMetricsFinder/utils.d.ts.map +1 -0
  217. package/lib/explore/PrometheusMetricsFinder/utils.js +185 -0
  218. package/lib/explore/PrometheusMetricsFinder/utils.js.map +1 -0
  219. package/lib/explore/index.d.ts +3 -0
  220. package/lib/explore/index.d.ts.map +1 -0
  221. package/lib/explore/index.js +4 -0
  222. package/lib/explore/index.js.map +1 -0
  223. package/lib/getPluginModule.d.ts +6 -0
  224. package/lib/getPluginModule.d.ts.map +1 -0
  225. package/lib/getPluginModule.js +16 -0
  226. package/lib/getPluginModule.js.map +1 -0
  227. package/lib/index-federation.d.ts +1 -0
  228. package/lib/index-federation.d.ts.map +1 -0
  229. package/lib/index-federation.js +15 -0
  230. package/{dist/components/index.js.map → lib/index-federation.js.map} +1 -1
  231. package/lib/index.d.ts +6 -0
  232. package/lib/index.d.ts.map +1 -0
  233. package/lib/index.js +7 -0
  234. package/lib/index.js.map +1 -0
  235. package/{dist → lib}/model/api-types.d.ts +18 -1
  236. package/lib/model/api-types.d.ts.map +1 -0
  237. package/{dist/plugins/prometheus-time-series-query/index.js → lib/model/api-types.js} +3 -3
  238. package/lib/model/api-types.js.map +1 -0
  239. package/lib/model/index.d.ts.map +1 -0
  240. package/lib/model/index.js.map +1 -0
  241. package/lib/model/parse-sample-values.d.ts.map +1 -0
  242. package/lib/model/parse-sample-values.js.map +1 -0
  243. package/lib/model/prometheus-client.d.ts.map +1 -0
  244. package/{dist → lib}/model/prometheus-client.js +1 -1
  245. package/lib/model/prometheus-client.js.map +1 -0
  246. package/lib/model/prometheus-selectors.d.ts.map +1 -0
  247. package/lib/model/prometheus-selectors.js.map +1 -0
  248. package/lib/model/time.d.ts.map +1 -0
  249. package/lib/model/time.js.map +1 -0
  250. package/lib/plugins/MatcherEditor.d.ts.map +1 -0
  251. package/lib/plugins/MatcherEditor.js.map +1 -0
  252. package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
  253. package/lib/plugins/PrometheusDatasourceEditor.js +96 -0
  254. package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -0
  255. package/lib/plugins/PrometheusLabelNamesVariable.d.ts +4 -0
  256. package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -0
  257. package/lib/plugins/PrometheusLabelNamesVariable.js +26 -0
  258. package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -0
  259. package/lib/plugins/PrometheusLabelValuesVariable.d.ts +4 -0
  260. package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -0
  261. package/lib/plugins/PrometheusLabelValuesVariable.js +30 -0
  262. package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -0
  263. package/lib/plugins/PrometheusPromQLVariable.d.ts +4 -0
  264. package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -0
  265. package/lib/plugins/PrometheusPromQLVariable.js +34 -0
  266. package/lib/plugins/PrometheusPromQLVariable.js.map +1 -0
  267. package/lib/plugins/index.d.ts +10 -0
  268. package/lib/plugins/index.d.ts.map +1 -0
  269. package/lib/plugins/index.js +11 -0
  270. package/lib/plugins/index.js.map +1 -0
  271. package/lib/plugins/prometheus-datasource.d.ts.map +1 -0
  272. package/{dist → lib}/plugins/prometheus-datasource.js +9 -9
  273. package/lib/plugins/prometheus-datasource.js.map +1 -0
  274. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -0
  275. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -0
  276. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  277. package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +9 -7
  278. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -0
  279. package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -0
  280. package/{dist → lib}/plugins/prometheus-time-series-query/get-time-series-data.js +51 -29
  281. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -0
  282. package/lib/plugins/prometheus-time-series-query/index.d.ts +7 -0
  283. package/lib/plugins/prometheus-time-series-query/index.d.ts.map +1 -0
  284. package/lib/plugins/prometheus-time-series-query/index.js +20 -0
  285. package/lib/plugins/prometheus-time-series-query/index.js.map +1 -0
  286. package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -0
  287. package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -0
  288. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts.map +1 -0
  289. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +1 -0
  290. package/lib/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -0
  291. package/lib/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -0
  292. package/lib/plugins/prometheus-variables.d.ts +14 -0
  293. package/lib/plugins/prometheus-variables.d.ts.map +1 -0
  294. package/{dist → lib}/plugins/prometheus-variables.js +15 -98
  295. package/lib/plugins/prometheus-variables.js.map +1 -0
  296. package/lib/plugins/types.d.ts.map +1 -0
  297. package/lib/plugins/types.js.map +1 -0
  298. package/lib/plugins/variable.d.ts.map +1 -0
  299. package/{dist → lib}/plugins/variable.js +1 -2
  300. package/lib/plugins/variable.js.map +1 -0
  301. package/lib/setup-tests.d.ts +2 -0
  302. package/lib/setup-tests.d.ts.map +1 -0
  303. package/lib/setup-tests.js +17 -0
  304. package/{dist/utils/index.js.map → lib/setup-tests.js.map} +1 -1
  305. package/lib/test/setup-tests.d.ts.map +1 -0
  306. package/lib/test/setup-tests.js.map +1 -0
  307. package/lib/utils/index.d.ts.map +1 -0
  308. package/lib/utils/index.js.map +1 -0
  309. package/lib/utils/utils.d.ts.map +1 -0
  310. package/{dist → lib}/utils/utils.js +1 -2
  311. package/lib/utils/utils.js.map +1 -0
  312. package/mf-manifest.json +898 -0
  313. package/mf-stats.json +1004 -0
  314. package/package.json +99 -38
  315. package/dist/cjs/components/TreeNode.js +0 -147
  316. package/dist/cjs/index.js +0 -61
  317. package/dist/cjs/plugins/PrometheusDatasourceEditor.js +0 -626
  318. package/dist/components/PromQLEditor.d.ts.map +0 -1
  319. package/dist/components/PromQLEditor.js.map +0 -1
  320. package/dist/components/TreeNode.d.ts +0 -10
  321. package/dist/components/TreeNode.d.ts.map +0 -1
  322. package/dist/components/TreeNode.js +0 -139
  323. package/dist/components/TreeNode.js.map +0 -1
  324. package/dist/components/index.d.ts.map +0 -1
  325. package/dist/components/parse.d.ts +0 -5
  326. package/dist/components/parse.d.ts.map +0 -1
  327. package/dist/components/parse.js.map +0 -1
  328. package/dist/components/promql/ast.d.ts.map +0 -1
  329. package/dist/components/promql/ast.js.map +0 -1
  330. package/dist/components/promql/format.d.ts.map +0 -1
  331. package/dist/components/promql/format.js.map +0 -1
  332. package/dist/components/promql/utils.d.ts.map +0 -1
  333. package/dist/components/promql/utils.js.map +0 -1
  334. package/dist/index.d.ts +0 -8
  335. package/dist/index.d.ts.map +0 -1
  336. package/dist/index.js +0 -24
  337. package/dist/index.js.map +0 -1
  338. package/dist/model/api-types.d.ts.map +0 -1
  339. package/dist/model/api-types.js.map +0 -1
  340. package/dist/model/index.d.ts.map +0 -1
  341. package/dist/model/index.js.map +0 -1
  342. package/dist/model/parse-sample-values.d.ts.map +0 -1
  343. package/dist/model/parse-sample-values.js.map +0 -1
  344. package/dist/model/prometheus-client.d.ts.map +0 -1
  345. package/dist/model/prometheus-client.js.map +0 -1
  346. package/dist/model/prometheus-selectors.d.ts.map +0 -1
  347. package/dist/model/prometheus-selectors.js.map +0 -1
  348. package/dist/model/time.d.ts.map +0 -1
  349. package/dist/model/time.js.map +0 -1
  350. package/dist/plugins/MatcherEditor.d.ts.map +0 -1
  351. package/dist/plugins/MatcherEditor.js.map +0 -1
  352. package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +0 -1
  353. package/dist/plugins/PrometheusDatasourceEditor.js +0 -572
  354. package/dist/plugins/PrometheusDatasourceEditor.js.map +0 -1
  355. package/dist/plugins/prometheus-datasource.d.ts.map +0 -1
  356. package/dist/plugins/prometheus-datasource.js.map +0 -1
  357. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +0 -1
  358. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +0 -1
  359. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +0 -1
  360. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +0 -1
  361. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +0 -1
  362. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +0 -1
  363. package/dist/plugins/prometheus-time-series-query/index.d.ts +0 -2
  364. package/dist/plugins/prometheus-time-series-query/index.d.ts.map +0 -1
  365. package/dist/plugins/prometheus-time-series-query/index.js.map +0 -1
  366. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +0 -1
  367. package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +0 -1
  368. package/dist/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts.map +0 -1
  369. package/dist/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +0 -1
  370. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +0 -1
  371. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +0 -1
  372. package/dist/plugins/prometheus-variables.d.ts +0 -6
  373. package/dist/plugins/prometheus-variables.d.ts.map +0 -1
  374. package/dist/plugins/prometheus-variables.js.map +0 -1
  375. package/dist/plugins/types.d.ts.map +0 -1
  376. package/dist/plugins/types.js.map +0 -1
  377. package/dist/plugins/variable.d.ts.map +0 -1
  378. package/dist/plugins/variable.js.map +0 -1
  379. package/dist/test/setup-tests.d.ts.map +0 -1
  380. package/dist/test/setup-tests.js.map +0 -1
  381. package/dist/utils/index.d.ts.map +0 -1
  382. package/dist/utils/utils.d.ts.map +0 -1
  383. package/dist/utils/utils.js.map +0 -1
  384. package/plugin.json +0 -58
  385. /package/{dist → lib}/cjs/components/index.js +0 -0
  386. /package/{dist → lib}/cjs/components/promql/format.js +0 -0
  387. /package/{dist → lib}/cjs/model/index.js +0 -0
  388. /package/{dist → lib}/cjs/model/parse-sample-values.js +0 -0
  389. /package/{dist → lib}/cjs/model/prometheus-selectors.js +0 -0
  390. /package/{dist → lib}/cjs/model/time.js +0 -0
  391. /package/{dist → lib}/cjs/plugins/MatcherEditor.js +0 -0
  392. /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +0 -0
  393. /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/query-editor-model.js +0 -0
  394. /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +0 -0
  395. /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +0 -0
  396. /package/{dist → lib}/cjs/plugins/types.js +0 -0
  397. /package/{dist → lib}/cjs/test/setup-tests.js +0 -0
  398. /package/{dist → lib}/cjs/utils/index.js +0 -0
  399. /package/{dist → lib}/components/PromQLEditor.d.ts +0 -0
  400. /package/{dist → lib}/components/index.d.ts +0 -0
  401. /package/{dist → lib}/components/index.js +0 -0
  402. /package/{dist → lib}/components/promql/ast.d.ts +0 -0
  403. /package/{dist → lib}/components/promql/format.js +0 -0
  404. /package/{dist → lib}/model/index.d.ts +0 -0
  405. /package/{dist → lib}/model/index.js +0 -0
  406. /package/{dist → lib}/model/parse-sample-values.d.ts +0 -0
  407. /package/{dist → lib}/model/parse-sample-values.js +0 -0
  408. /package/{dist → lib}/model/prometheus-client.d.ts +0 -0
  409. /package/{dist → lib}/model/prometheus-selectors.d.ts +0 -0
  410. /package/{dist → lib}/model/prometheus-selectors.js +0 -0
  411. /package/{dist → lib}/model/time.d.ts +0 -0
  412. /package/{dist → lib}/model/time.js +0 -0
  413. /package/{dist → lib}/plugins/MatcherEditor.d.ts +0 -0
  414. /package/{dist → lib}/plugins/MatcherEditor.js +0 -0
  415. /package/{dist → lib}/plugins/PrometheusDatasourceEditor.d.ts +0 -0
  416. /package/{dist → lib}/plugins/prometheus-datasource.d.ts +0 -0
  417. /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts +0 -0
  418. /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +0 -0
  419. /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +0 -0
  420. /package/{dist → lib}/plugins/prometheus-time-series-query/get-time-series-data.d.ts +0 -0
  421. /package/{dist → lib}/plugins/prometheus-time-series-query/query-editor-model.d.ts +0 -0
  422. /package/{dist → lib}/plugins/prometheus-time-series-query/query-editor-model.js +0 -0
  423. /package/{dist → lib}/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts +0 -0
  424. /package/{dist → lib}/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +0 -0
  425. /package/{dist → lib}/plugins/prometheus-time-series-query/time-series-query-model.d.ts +0 -0
  426. /package/{dist → lib}/plugins/prometheus-time-series-query/time-series-query-model.js +0 -0
  427. /package/{dist → lib}/plugins/types.d.ts +0 -0
  428. /package/{dist → lib}/plugins/types.js +0 -0
  429. /package/{dist → lib}/plugins/variable.d.ts +0 -0
  430. /package/{dist → lib}/test/setup-tests.d.ts +0 -0
  431. /package/{dist → lib}/test/setup-tests.js +0 -0
  432. /package/{dist → lib}/utils/index.d.ts +0 -0
  433. /package/{dist → lib}/utils/index.js +0 -0
  434. /package/{dist → lib}/utils/utils.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-sample-values.d.ts","sourceRoot":"","sources":["../../../src/model/parse-sample-values.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAKlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAenE"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/parse-sample-values.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ValueTuple } from './api-types';\n\n/**\n * ValueTuple from the Prom server, parsed into ms and floating point number\n */\nexport type ParsedValueTuple = [unixTimeMs: number, value: number];\n\n/**\n * Parse a ValueTuple from a PromServer response into the a millisecond-based\n * unix time and a numeric sample value.\n */\nexport function parseValueTuple(data: ValueTuple): ParsedValueTuple {\n const [unixTimeSeconds, sampleValue] = data;\n\n // Prom returns unix time in seconds, so convert to ms\n return [unixTimeSeconds * 1000, parseSampleValue(sampleValue)];\n}\n\n/**\n * Parses a string sample value from Prometheus, usually included as the\n * second member of a ValueTuple.\n */\nexport function parseSampleValue(sampleValue: ValueTuple[1]): number {\n // Account for Prometheus' representation of +/- infinity, otherwise just\n // parse the sample value as a float\n let value: number;\n switch (sampleValue) {\n case '+Inf':\n value = Number.POSITIVE_INFINITY;\n break;\n case '-Inf':\n value = Number.NEGATIVE_INFINITY;\n break;\n default:\n value = parseFloat(sampleValue);\n }\n return value;\n}\n"],"names":["parseValueTuple","data","unixTimeSeconds","sampleValue","parseSampleValue","value","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","parseFloat"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAgB;IAC9C,MAAM,CAACC,iBAAiBC,YAAY,GAAGF;IAEvC,sDAAsD;IACtD,OAAO;QAACC,kBAAkB;QAAME,iBAAiBD;KAAa;AAChE;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBD,WAA0B;IACzD,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE;IACJ,OAAQF;QACN,KAAK;YACHE,QAAQC,OAAOC,iBAAiB;YAChC;QACF,KAAK;YACHF,QAAQC,OAAOE,iBAAiB;YAChC;QACF;YACEH,QAAQI,WAAWN;IACvB;IACA,OAAOE;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-client.ts"],"names":[],"mappings":"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"}
@@ -21,7 +21,7 @@ import { fetch, fetchJson } from '@perses-dev/core';
21
21
  headers: queryOptions.headers
22
22
  });
23
23
  return resp.status === 200;
24
- } catch (e) {
24
+ } catch {
25
25
  return false;
26
26
  }
27
27
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/prometheus-client.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SeriesRequestParameters,\n SeriesResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(params: InstantQueryRequestParameters, headers?: RequestHeaders): Promise<InstantQueryResponse>;\n rangeQuery(params: RangeQueryRequestParameters, headers?: RequestHeaders): Promise<RangeQueryResponse>;\n labelNames(params: LabelNamesRequestParameters, headers?: RequestHeaders): Promise<LabelNamesResponse>;\n labelValues(params: LabelValuesRequestParameters, headers?: RequestHeaders): Promise<LabelValuesResponse>;\n metricMetadata(params: MetricMetadataRequestParameters, headers?: RequestHeaders): Promise<MetricMetadataResponse>;\n series(params: SeriesRequestParameters, headers?: RequestHeaders): Promise<SeriesResponse>;\n parseQuery(params: ParseQueryRequestParameters, headers?: RequestHeaders): Promise<ParseQueryResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\n/**\n * Calls the `/-/healthy` endpoint to check if the datasource is healthy.\n */\nexport function healthCheck(queryOptions: QueryOptions) {\n return async (): Promise<boolean> => {\n const url = `${queryOptions.datasourceUrl}/-/healthy`;\n\n try {\n const resp = await fetch(url, { headers: queryOptions.headers });\n return resp.status === 200;\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(\n params: InstantQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<InstantQueryResponse> {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(\n params: RangeQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<RangeQueryResponse> {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(\n params: LabelNamesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelNamesResponse> {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function metricMetadata(\n params: MetricMetadataRequestParameters,\n queryOptions: QueryOptions\n): Promise<MetricMetadataResponse> {\n const apiURI = `/api/v1/metadata`;\n return fetchWithGet<MetricMetadataRequestParameters, MetricMetadataResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/series` endpoint to finding series by label matchers.\n */\nexport function series(params: SeriesRequestParameters, queryOptions: QueryOptions): Promise<SeriesResponse> {\n const apiURI = `/api/v1/series`;\n return fetchWithPost<SeriesRequestParameters, SeriesResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/parse_query` to parse the given promQL expresion into an abstract syntax tree (AST).\n */\nexport function parseQuery(\n params: ParseQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<ParseQueryResponse> {\n const apiURI = `/api/v1/parse_query`;\n return fetchWithPost<ParseQueryRequestParameters, ParseQueryResponse>(apiURI, params, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = createSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n return fetchJson<TResponse>(url, { method: 'GET', headers });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers } = queryOptions;\n\n const url = `${datasourceUrl}${apiURI}`;\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T): URLSearchParams {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>): Promise<T> {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","healthCheck","queryOptions","url","datasourceUrl","resp","headers","status","instantQuery","params","fetchWithPost","rangeQuery","labelNames","labelValues","labelName","searchParams","length","Promise","resolve","data","apiURI","encodeURIComponent","fetchWithGet","metricMetadata","series","parseQuery","urlParams","createSearchParams","toString","method","init","body","fetchResults","URLSearchParams","key","value","undefined","append","val","args","response","json","rawResponse"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,IAAI,EAAE,OAAO,oBAAoB,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,4BAA6D,CAAC;AAEzF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,OAAO,CAErF;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,IAAI,4BAA4B,CAErH"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided PrometheusDatasourceSelector is the default one.\n */\nexport function isDefaultPromSelector(selector: PrometheusDatasourceSelector): boolean {\n return selector.name === undefined;\n}\n\n/**\n * Type guard to make sure a DatasourceSelector is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(selector: DatasourceSelector): selector is PrometheusDatasourceSelector {\n return selector.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","selector","name","undefined","isPrometheusDatasourceSelector"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBAAsBC,QAAsC;IAC1E,OAAOA,SAASC,IAAI,KAAKC;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASC,+BAA+BH,QAA4B;IACzE,OAAOA,SAASF,IAAI,KAAKF;AAC3B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,GAAG,EAAE,oBAAoB,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAMnG;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,mBAAmB,EAC9B,cAAc,SAAK,EACnB,UAAU,SAAI,EACd,eAAe,SAAI,GAClB,MAAM,CAUR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAM5F"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/time.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds, getUnixTime } from 'date-fns';\nimport { UnixTimestampSeconds } from './api-types';\n\nexport interface PrometheusTimeRange {\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n}\n\n/**\n * Converts an AbsoluteTimeRange to Prometheus time in Unix time (i.e. in seconds).\n */\nexport function getPrometheusTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n// Max data points to allow returning from a Prom Query, used to calculate a\n// \"safe\" step for a range query\nconst MAX_PROM_DATA_POINTS = 10000;\n\n/**\n * Gets the step to use for a Prom range query. Tries to take into account a suggested step size (probably based on the\n * width of a visualization where the data will be graphed), any minimum step/resolution set by the user, and a \"safe\"\n * step based on the max data points we want to allow returning from a Prom query.\n */\nexport function getRangeStep(\n timeRange: PrometheusTimeRange,\n minStepSeconds = 15,\n resolution = 1,\n suggestedStepMs = 0\n): number {\n const suggestedStepSeconds = suggestedStepMs / 1000;\n const queryRangeSeconds = timeRange.end - timeRange.start;\n\n let safeStep = queryRangeSeconds / MAX_PROM_DATA_POINTS;\n if (safeStep > 1) {\n safeStep = Math.ceil(safeStep);\n }\n\n return Math.max(suggestedStepSeconds * resolution, minStepSeconds, safeStep);\n}\n\n/**\n * Converts a DurationString to seconds, rounding down.\n */\nexport function getDurationStringSeconds(durationString?: DurationString): number | undefined {\n if (!durationString) return undefined;\n\n const duration = parseDurationString(durationString);\n const ms = milliseconds(duration);\n return Math.floor(ms / 1000);\n}\n"],"names":["parseDurationString","milliseconds","getUnixTime","getPrometheusTimeRange","timeRange","start","end","Math","ceil","MAX_PROM_DATA_POINTS","getRangeStep","minStepSeconds","resolution","suggestedStepMs","suggestedStepSeconds","queryRangeSeconds","safeStep","max","getDurationStringSeconds","durationString","undefined","duration","ms","floor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA4CA,mBAAmB,QAAQ,mBAAmB;AAC1F,SAASC,YAAY,EAAEC,WAAW,QAAQ,WAAW;AAQrD;;CAEC,GACD,OAAO,SAASC,uBAAuBC,SAA4B;IACjE,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACN,YAAYG;QAC7BC,KAAKC,KAAKC,IAAI,CAACN,YAAYI;IAC7B;AACF;AAEA,4EAA4E;AAC5E,gCAAgC;AAChC,MAAMG,uBAAuB;AAE7B;;;;CAIC,GACD,OAAO,SAASC,aACdN,SAA8B,EAC9BO,iBAAiB,EAAE,EACnBC,aAAa,CAAC,EACdC,kBAAkB,CAAC;IAEnB,MAAMC,uBAAuBD,kBAAkB;IAC/C,MAAME,oBAAoBX,UAAUE,GAAG,GAAGF,UAAUC,KAAK;IAEzD,IAAIW,WAAWD,oBAAoBN;IACnC,IAAIO,WAAW,GAAG;QAChBA,WAAWT,KAAKC,IAAI,CAACQ;IACvB;IAEA,OAAOT,KAAKU,GAAG,CAACH,uBAAuBF,YAAYD,gBAAgBK;AACrE;AAEA;;CAEC,GACD,OAAO,SAASE,yBAAyBC,cAA+B;IACtE,IAAI,CAACA,gBAAgB,OAAOC;IAE5B,MAAMC,WAAWrB,oBAAoBmB;IACrC,MAAMG,KAAKrB,aAAaoB;IACxB,OAAOd,KAAKgB,KAAK,CAACD,KAAK;AACzB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatcherEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/MatcherEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAkDlG"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { ReactElement } from 'react';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n isReadonly?: boolean;\n};\n\nexport function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps): ReactElement {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","isReadonly","spacing","mb","map","matcher","index","display","fullWidth","label","value","InputProps","readOnly","e","newMatchers","draft","target","onClick","splice","disabled","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,2BAA2B;AASjD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,EAAsB;IAClF,qBACE,MAACV;QAAMW,SAAS;QAAGC,IAAI;;YACpBJ,SAASK,GAAG,CAAC,CAACC,SAASC,sBACtB,MAACZ;oBAAgBa,SAAQ;;sCACvB,KAACf;4BACCgB,SAAS;4BACTC,OAAM;4BACNC,OAAOL;4BACPM,YAAY;gCACVC,UAAUX;4BACZ;4BACAD,UAAU,CAACa;gCACT,MAAMC,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,KAAK,CAACT,MAAM,GAAGO,EAAEG,MAAM,CAACN,KAAK;gCAC/B;gCACAV,SAASc;4BACX;;sCAEF,KAACnB;4BACCsB,SAAS;gCACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,MAAMG,MAAM,CAACZ,OAAO;gCACtB;gCACAN,SAASc;4BACX;4BACAK,UAAUlB;sCAEV,cAAA,KAACJ;;;mBAxBKS;0BA4BZ,KAACZ;0BACC,cAAA,KAACD;oBACCe,WAAW;oBACXY,OAAM;oBACNC,SAAQ;oBACRJ,SAAS;wBACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;4BACrCA,MAAMO,IAAI,CAAC;wBACb;wBACAtB,SAASc;oBACX;oBACAK,UAAUlB;8BACX;;;;;AAMT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,YAAY,CAwE/F"}
@@ -0,0 +1,96 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { HTTPSettingsEditor } from '@perses-dev/plugin-system';
15
+ import { TextField, Typography } from '@mui/material';
16
+ import React from 'react';
17
+ import { DEFAULT_SCRAPE_INTERVAL } from './types';
18
+ export function PrometheusDatasourceEditor(props) {
19
+ const { value, onChange, isReadonly } = props;
20
+ const initialSpecDirect = {
21
+ directUrl: ''
22
+ };
23
+ const initialSpecProxy = {
24
+ proxy: {
25
+ kind: 'HTTPProxy',
26
+ spec: {
27
+ allowedEndpoints: [
28
+ // list of standard endpoints suggested by default
29
+ {
30
+ endpointPattern: '/api/v1/labels',
31
+ method: 'POST'
32
+ },
33
+ {
34
+ endpointPattern: '/api/v1/series',
35
+ method: 'POST'
36
+ },
37
+ {
38
+ endpointPattern: '/api/v1/metadata',
39
+ method: 'GET'
40
+ },
41
+ {
42
+ endpointPattern: '/api/v1/query',
43
+ method: 'POST'
44
+ },
45
+ {
46
+ endpointPattern: '/api/v1/query_range',
47
+ method: 'POST'
48
+ },
49
+ {
50
+ endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
51
+ method: 'GET'
52
+ },
53
+ {
54
+ endpointPattern: '/api/v1/parse_query',
55
+ method: 'POST'
56
+ }
57
+ ],
58
+ url: ''
59
+ }
60
+ }
61
+ };
62
+ return /*#__PURE__*/ _jsxs(_Fragment, {
63
+ children: [
64
+ /*#__PURE__*/ _jsx(Typography, {
65
+ variant: "h4",
66
+ mb: 2,
67
+ children: "General Settings"
68
+ }),
69
+ /*#__PURE__*/ _jsx(TextField, {
70
+ fullWidth: true,
71
+ label: "Scrape Interval",
72
+ value: value.scrapeInterval || '',
73
+ placeholder: `Default: ${DEFAULT_SCRAPE_INTERVAL}`,
74
+ InputProps: {
75
+ readOnly: isReadonly
76
+ },
77
+ InputLabelProps: {
78
+ shrink: isReadonly ? true : undefined
79
+ },
80
+ onChange: (e)=>onChange({
81
+ ...value,
82
+ scrapeInterval: e.target.value
83
+ })
84
+ }),
85
+ /*#__PURE__*/ _jsx(HTTPSettingsEditor, {
86
+ value: value,
87
+ onChange: onChange,
88
+ isReadonly: isReadonly,
89
+ initialSpecDirect: initialSpecDirect,
90
+ initialSpecProxy: initialSpecProxy
91
+ })
92
+ ]
93
+ });
94
+ }
95
+
96
+ //# sourceMappingURL=PrometheusDatasourceEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport { HTTPSettingsEditor } from '@perses-dev/plugin-system';\nimport { TextField, Typography } from '@mui/material';\nimport React, { ReactElement } from 'react';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from './types';\n\nexport interface PrometheusDatasourceEditorProps {\n value: PrometheusDatasourceSpec;\n onChange: (next: PrometheusDatasourceSpec) => void;\n isReadonly?: boolean;\n}\n\nexport function PrometheusDatasourceEditor(props: PrometheusDatasourceEditorProps): ReactElement {\n const { value, onChange, isReadonly } = props;\n\n const initialSpecDirect: PrometheusDatasourceSpec = {\n directUrl: '',\n };\n\n const initialSpecProxy: PrometheusDatasourceSpec = {\n proxy: {\n kind: 'HTTPProxy',\n spec: {\n allowedEndpoints: [\n // list of standard endpoints suggested by default\n {\n endpointPattern: '/api/v1/labels',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/series',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/metadata',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/query',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/query_range',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/parse_query',\n method: 'POST',\n },\n ],\n url: '',\n },\n },\n };\n\n return (\n <>\n <Typography variant=\"h4\" mb={2}>\n General Settings\n </Typography>\n <TextField\n fullWidth\n label=\"Scrape Interval\"\n value={value.scrapeInterval || ''}\n placeholder={`Default: ${DEFAULT_SCRAPE_INTERVAL}`}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => onChange({ ...value, scrapeInterval: e.target.value as DurationString })}\n />\n <HTTPSettingsEditor\n value={value}\n onChange={onChange}\n isReadonly={isReadonly}\n initialSpecDirect={initialSpecDirect}\n initialSpecProxy={initialSpecProxy}\n />\n </>\n );\n}\n"],"names":["HTTPSettingsEditor","TextField","Typography","React","DEFAULT_SCRAPE_INTERVAL","PrometheusDatasourceEditor","props","value","onChange","isReadonly","initialSpecDirect","directUrl","initialSpecProxy","proxy","kind","spec","allowedEndpoints","endpointPattern","method","url","variant","mb","fullWidth","label","scrapeInterval","placeholder","InputProps","readOnly","InputLabelProps","shrink","undefined","e","target"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AACtD,OAAOC,WAA6B,QAAQ;AAC5C,SAASC,uBAAuB,QAAkC,UAAU;AAQ5E,OAAO,SAASC,2BAA2BC,KAAsC;IAC/E,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGH;IAExC,MAAMI,oBAA8C;QAClDC,WAAW;IACb;IAEA,MAAMC,mBAA6C;QACjDC,OAAO;YACLC,MAAM;YACNC,MAAM;gBACJC,kBAAkB;oBAChB,kDAAkD;oBAClD;wBACEC,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;iBACD;gBACDC,KAAK;YACP;QACF;IACF;IAEA,qBACE;;0BACE,KAACjB;gBAAWkB,SAAQ;gBAAKC,IAAI;0BAAG;;0BAGhC,KAACpB;gBACCqB,SAAS;gBACTC,OAAM;gBACNhB,OAAOA,MAAMiB,cAAc,IAAI;gBAC/BC,aAAa,CAAC,SAAS,EAAErB,yBAAyB;gBAClDsB,YAAY;oBACVC,UAAUlB;gBACZ;gBACAmB,iBAAiB;oBAAEC,QAAQpB,aAAa,OAAOqB;gBAAU;gBACzDtB,UAAU,CAACuB,IAAMvB,SAAS;wBAAE,GAAGD,KAAK;wBAAEiB,gBAAgBO,EAAEC,MAAM,CAACzB,KAAK;oBAAmB;;0BAEzF,KAACP;gBACCO,OAAOA;gBACPC,UAAUA;gBACVC,YAAYA;gBACZC,mBAAmBA;gBACnBE,kBAAkBA;;;;AAI1B"}
@@ -0,0 +1,4 @@
1
+ import { VariablePlugin } from '@perses-dev/plugin-system';
2
+ import { PrometheusLabelNamesVariableOptions } from './types';
3
+ export declare const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions>;
4
+ //# sourceMappingURL=PrometheusLabelNamesVariable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusLabelNamesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAGxH,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAgB5F,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM, getPrometheusTimeRange } from '../model';
3
+ import { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';
4
+ export const PrometheusLabelNamesVariable = {
5
+ getVariableOptions: async (spec, ctx)=>{
6
+ const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
7
+ const match = spec.matchers ? spec.matchers.map((m)=>replaceVariables(m, ctx.variables)) : undefined;
8
+ const timeRange = getPrometheusTimeRange(ctx.timeRange);
9
+ const { data: options } = await client.labelNames({
10
+ 'match[]': match,
11
+ ...timeRange
12
+ });
13
+ return {
14
+ data: stringArrayToVariableOptions(options)
15
+ };
16
+ },
17
+ dependsOn: (spec)=>{
18
+ return {
19
+ variables: spec.matchers?.map((m)=>parseVariables(m)).flat() || []
20
+ };
21
+ },
22
+ OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
23
+ createInitialOptions: ()=>({})
24
+ };
25
+
26
+ //# sourceMappingURL=PrometheusLabelNamesVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelNamesVariableOptions } from './types';\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelNamesVariableOptions, ctx: GetVariableOptionsContext) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelNamesVariableOptions) => {\n return { variables: spec.matchers?.map((m) => parseVariables(m)).flat() || [] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","getPrometheusTimeRange","stringArrayToVariableOptions","PrometheusLabelNamesVariableEditor","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","matchers","map","m","variables","undefined","timeRange","data","options","labelNames","dependsOn","flat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,EAAEC,sBAAsB,QAAQ,WAAW;AAClF,SAASC,4BAA4B,EAAEC,kCAAkC,QAAQ,yBAAyB;AAG1G,OAAO,MAAMC,+BAAoF;IAC/FC,oBAAoB,OAAOC,MAA2CC;QACpE,MAAMC,SAA2B,MAAMD,IAAIE,eAAe,CAACC,mBAAmB,CAACJ,KAAKK,UAAU,IAAIX;QAClG,MAAMY,QAAQN,KAAKO,QAAQ,GAAGP,KAAKO,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMjB,iBAAiBiB,GAAGR,IAAIS,SAAS,KAAKC;QAC7F,MAAMC,YAAYjB,uBAAuBM,IAAIW,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMZ,OAAOa,UAAU,CAAC;YAAE,WAAWT;YAAO,GAAGM,SAAS;QAAC;QACnF,OAAO;YACLC,MAAMjB,6BAA6BkB;QACrC;IACF;IACAE,WAAW,CAAChB;QACV,OAAO;YAAEU,WAAWV,KAAKO,QAAQ,EAAEC,IAAI,CAACC,IAAMhB,eAAegB,IAAIQ,UAAU,EAAE;QAAC;IAChF;IACAC,wBAAwBrB;IACxBsB,sBAAsB,IAAO,CAAA,CAAC,CAAA;AAChC,EAAE"}
@@ -0,0 +1,4 @@
1
+ import { VariablePlugin } from '@perses-dev/plugin-system';
2
+ import { PrometheusLabelValuesVariableOptions } from './types';
3
+ export declare const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions>;
4
+ //# sourceMappingURL=PrometheusLabelValuesVariable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusLabelValuesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAGxH,OAAO,EAAE,oCAAoC,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CA4B9F,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM, getPrometheusTimeRange } from '../model';
3
+ import { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';
4
+ export const PrometheusLabelValuesVariable = {
5
+ getVariableOptions: async (spec, ctx)=>{
6
+ const pluginDef = spec;
7
+ const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
8
+ const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>replaceVariables(m, ctx.variables)) : undefined;
9
+ const timeRange = getPrometheusTimeRange(ctx.timeRange);
10
+ const { data: options } = await client.labelValues({
11
+ labelName: replaceVariables(pluginDef.labelName, ctx.variables),
12
+ 'match[]': match,
13
+ ...timeRange
14
+ });
15
+ return {
16
+ data: stringArrayToVariableOptions(options)
17
+ };
18
+ },
19
+ dependsOn: (spec)=>{
20
+ return {
21
+ variables: spec.matchers?.map((m)=>parseVariables(m)).flat().concat(parseVariables(spec.labelName)) || []
22
+ };
23
+ },
24
+ OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
25
+ createInitialOptions: ()=>({
26
+ labelName: ''
27
+ })
28
+ };
29
+
30
+ //# sourceMappingURL=PrometheusLabelValuesVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelValuesVariableOptions } from './types';\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions) => {\n return {\n variables:\n spec.matchers\n ?.map((m) => parseVariables(m))\n .flat()\n .concat(parseVariables(spec.labelName)) || [],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","getPrometheusTimeRange","stringArrayToVariableOptions","PrometheusLabelValuesVariableEditor","PrometheusLabelValuesVariable","getVariableOptions","spec","ctx","pluginDef","client","datasourceStore","getDatasourceClient","datasource","match","matchers","map","m","variables","undefined","timeRange","data","options","labelValues","labelName","dependsOn","flat","concat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,EAAEC,sBAAsB,QAAQ,WAAW;AAClF,SAASC,4BAA4B,EAAEC,mCAAmC,QAAQ,yBAAyB;AAG3G,OAAO,MAAMC,gCAAsF;IACjGC,oBAAoB,OAAOC,MAA4CC;QACrE,MAAMC,YAAYF;QAClB,MAAMG,SAA2B,MAAMF,IAAIG,eAAe,CAACC,mBAAmB,CAACL,KAAKM,UAAU,IAAIZ;QAClG,MAAMa,QAAQL,UAAUM,QAAQ,GAAGN,UAAUM,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMlB,iBAAiBkB,GAAGT,IAAIU,SAAS,KAAKC;QAEvG,MAAMC,YAAYlB,uBAAuBM,IAAIY,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMZ,OAAOa,WAAW,CAAC;YACjDC,WAAWzB,iBAAiBU,UAAUe,SAAS,EAAEhB,IAAIU,SAAS;YAC9D,WAAWJ;YACX,GAAGM,SAAS;QACd;QACA,OAAO;YACLC,MAAMlB,6BAA6BmB;QACrC;IACF;IACAG,WAAW,CAAClB;QACV,OAAO;YACLW,WACEX,KAAKQ,QAAQ,EACTC,IAAI,CAACC,IAAMjB,eAAeiB,IAC3BS,OACAC,OAAO3B,eAAeO,KAAKiB,SAAS,MAAM,EAAE;QACnD;IACF;IACAI,wBAAwBxB;IACxByB,sBAAsB,IAAO,CAAA;YAAEL,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -0,0 +1,4 @@
1
+ import { VariablePlugin } from '@perses-dev/plugin-system';
2
+ import { PrometheusPromQLVariableOptions } from './types';
3
+ export declare const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions>;
4
+ //# sourceMappingURL=PrometheusPromQLVariable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusPromQLVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAQxH,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAwBpF,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM } from '../model';
3
+ import { capturingMatrix, capturingVector, stringArrayToVariableOptions, PrometheusPromQLVariableEditor } from './prometheus-variables';
4
+ export const PrometheusPromQLVariable = {
5
+ getVariableOptions: async (spec, ctx)=>{
6
+ const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
7
+ // TODO we may want to manage a range query as well.
8
+ const { data: options } = await client.instantQuery({
9
+ query: replaceVariables(spec.expr, ctx.variables)
10
+ });
11
+ const labelName = replaceVariables(spec.labelName, ctx.variables);
12
+ let values = [];
13
+ if (options?.resultType === 'matrix') {
14
+ values = capturingMatrix(options, labelName);
15
+ } else if (options?.resultType === 'vector') {
16
+ values = capturingVector(options, labelName);
17
+ }
18
+ return {
19
+ data: stringArrayToVariableOptions(values)
20
+ };
21
+ },
22
+ dependsOn: (spec)=>{
23
+ return {
24
+ variables: parseVariables(spec.expr).concat(parseVariables(spec.labelName))
25
+ };
26
+ },
27
+ OptionsEditorComponent: PrometheusPromQLVariableEditor,
28
+ createInitialOptions: ()=>({
29
+ expr: '',
30
+ labelName: ''
31
+ })
32
+ };
33
+
34
+ //# sourceMappingURL=PrometheusPromQLVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM } from '../model';\nimport {\n capturingMatrix,\n capturingVector,\n stringArrayToVariableOptions,\n PrometheusPromQLVariableEditor,\n} from './prometheus-variables';\nimport { PrometheusPromQLVariableOptions } from './types';\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec: PrometheusPromQLVariableOptions, ctx: GetVariableOptionsContext) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceVariables(spec.labelName, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec: PrometheusPromQLVariableOptions) => {\n return { variables: parseVariables(spec.expr).concat(parseVariables(spec.labelName)) };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","capturingMatrix","capturingVector","stringArrayToVariableOptions","PrometheusPromQLVariableEditor","PrometheusPromQLVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","data","options","instantQuery","query","expr","variables","labelName","values","resultType","dependsOn","concat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,QAAQ,WAAW;AAC1D,SACEC,eAAe,EACfC,eAAe,EACfC,4BAA4B,EAC5BC,8BAA8B,QACzB,yBAAyB;AAGhC,OAAO,MAAMC,2BAA4E;IACvFC,oBAAoB,OAAOC,MAAuCC;QAChE,MAAMC,SAA2B,MAAMD,IAAIE,eAAe,CAACC,mBAAmB,CAACJ,KAAKK,UAAU,IAAIZ;QAClG,oDAAoD;QACpD,MAAM,EAAEa,MAAMC,OAAO,EAAE,GAAG,MAAML,OAAOM,YAAY,CAAC;YAClDC,OAAOlB,iBAAiBS,KAAKU,IAAI,EAAET,IAAIU,SAAS;QAClD;QACA,MAAMC,YAAYrB,iBAAiBS,KAAKY,SAAS,EAAEX,IAAIU,SAAS;QAChE,IAAIE,SAAmB,EAAE;QACzB,IAAIN,SAASO,eAAe,UAAU;YACpCD,SAASnB,gBAAgBa,SAASK;QACpC,OAAO,IAAIL,SAASO,eAAe,UAAU;YAC3CD,SAASlB,gBAAgBY,SAASK;QACpC;QAEA,OAAO;YACLN,MAAMV,6BAA6BiB;QACrC;IACF;IACAE,WAAW,CAACf;QACV,OAAO;YAAEW,WAAWnB,eAAeQ,KAAKU,IAAI,EAAEM,MAAM,CAACxB,eAAeQ,KAAKY,SAAS;QAAG;IACvF;IACAK,wBAAwBpB;IACxBqB,sBAAsB,IAAO,CAAA;YAAER,MAAM;YAAIE,WAAW;QAAG,CAAA;AACzD,EAAE"}
@@ -0,0 +1,10 @@
1
+ export * from './MatcherEditor';
2
+ export * from './prometheus-datasource';
3
+ export * from './prometheus-time-series-query';
4
+ export * from './prometheus-variables';
5
+ export * from './PrometheusDatasourceEditor';
6
+ export * from './PrometheusLabelNamesVariable';
7
+ export * from './PrometheusPromQLVariable';
8
+ export * from './types';
9
+ export * from './variable';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from './MatcherEditor';
2
+ export * from './prometheus-datasource';
3
+ export * from './prometheus-time-series-query';
4
+ export * from './prometheus-variables';
5
+ export * from './PrometheusDatasourceEditor';
6
+ export * from './PrometheusLabelNamesVariable';
7
+ export * from './PrometheusPromQLVariable';
8
+ export * from './types';
9
+ export * from './variable';
10
+
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/index.ts"],"sourcesContent":["export * from './MatcherEditor';\nexport * from './prometheus-datasource';\nexport * from './prometheus-time-series-query';\nexport * from './prometheus-variables';\nexport * from './PrometheusDatasourceEditor';\nexport * from './PrometheusLabelNamesVariable';\nexport * from './PrometheusPromQLVariable';\nexport * from './types';\nexport * from './variable';\n"],"names":[],"mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,0BAA0B;AACxC,cAAc,iCAAiC;AAC/C,cAAc,yBAAyB;AACvC,cAAc,+BAA+B;AAC7C,cAAc,iCAAiC;AAC/C,cAAc,6BAA6B;AAC3C,cAAc,UAAU;AACxB,cAAc,aAAa"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-datasource.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAML,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAgFnD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAK7F,CAAC"}
@@ -18,11 +18,11 @@ import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
18
18
  const { directUrl, proxy } = spec;
19
19
  const { proxyUrl } = options;
20
20
  // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
21
- const datasourceUrl = directUrl !== null && directUrl !== void 0 ? directUrl : proxyUrl;
21
+ const datasourceUrl = directUrl ?? proxyUrl;
22
22
  if (datasourceUrl === undefined) {
23
23
  throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');
24
24
  }
25
- const specHeaders = proxy === null || proxy === void 0 ? void 0 : proxy.spec.headers;
25
+ const specHeaders = proxy?.spec.headers;
26
26
  // Could think about this becoming a class, although it definitely doesn't have to be
27
27
  return {
28
28
  options: {
@@ -34,31 +34,31 @@ import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
34
34
  }),
35
35
  instantQuery: (params, headers)=>instantQuery(params, {
36
36
  datasourceUrl,
37
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
37
+ headers: headers ?? specHeaders
38
38
  }),
39
39
  rangeQuery: (params, headers)=>rangeQuery(params, {
40
40
  datasourceUrl,
41
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
41
+ headers: headers ?? specHeaders
42
42
  }),
43
43
  labelNames: (params, headers)=>labelNames(params, {
44
44
  datasourceUrl,
45
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
45
+ headers: headers ?? specHeaders
46
46
  }),
47
47
  labelValues: (params, headers)=>labelValues(params, {
48
48
  datasourceUrl,
49
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
49
+ headers: headers ?? specHeaders
50
50
  }),
51
51
  metricMetadata: (params, headers)=>metricMetadata(params, {
52
52
  datasourceUrl,
53
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
53
+ headers: headers ?? specHeaders
54
54
  }),
55
55
  series: (params, headers)=>series(params, {
56
56
  datasourceUrl,
57
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
57
+ headers: headers ?? specHeaders
58
58
  }),
59
59
  parseQuery: (params, headers)=>parseQuery(params, {
60
60
  datasourceUrl,
61
- headers: headers !== null && headers !== void 0 ? headers : specHeaders
61
+ headers: headers ?? specHeaders
62
62
  })
63
63
  };
64
64
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-datasource.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n healthCheck,\n instantQuery,\n rangeQuery,\n labelNames,\n labelValues,\n PrometheusClient,\n metricMetadata,\n series,\n parseQuery,\n} from '../model';\nimport { PrometheusDatasourceSpec } from './types';\nimport { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';\n\n/**\n * Creates a PrometheusClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy } = spec;\n const { proxyUrl } = options;\n\n // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n // Could think about this becoming a class, although it definitely doesn't have to be\n return {\n options: {\n datasourceUrl,\n },\n healthCheck: healthCheck({ datasourceUrl, headers: specHeaders }),\n instantQuery: (params, headers) => instantQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n rangeQuery: (params, headers) => rangeQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labelNames: (params, headers) => labelNames(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labelValues: (params, headers) => labelValues(params, { datasourceUrl, headers: headers ?? specHeaders }),\n metricMetadata: (params, headers) => metricMetadata(params, { datasourceUrl, headers: headers ?? specHeaders }),\n series: (params, headers) => series(params, { datasourceUrl, headers: headers ?? specHeaders }),\n parseQuery: (params, headers) => parseQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n };\n};\n\nconst getBuiltinVariableDefinitions: () => BuiltinVariableDefinition[] = () => {\n return [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval',\n value: () => '$__interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval',\n description:\n 'For dynamic queries that adapt across different time ranges, use $__interval instead of hardcoded intervals. It represents the actual spacing between data points: it’s calculated based on the current time range and the panel pixel width (taking the \"Min step\" as a lower bound).',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval_ms',\n value: () => '$__interval_ms', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval_ms',\n description: 'Same as $__interval but in milliseconds.',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__rate_interval',\n value: () => '$__rate_interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__rate_interval',\n description:\n 'Use this one rather than $__interval as the range parameter of functions like rate, increase, etc. With such function it is advised to choose a range that is at least 4x the scrape interval (this is to allow for various races, and to be resilient to a failed scrape). $__rate_interval provides that, as it is defined as `max($__interval + Min Step, 4 * Min Step)`, where Min Step value should represent the scrape interval of the metrics.',\n hidden: true,\n },\n },\n },\n ] as BuiltinVariableDefinition[];\n};\n\nexport const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient> = {\n createClient,\n getBuiltinVariableDefinitions,\n OptionsEditorComponent: PrometheusDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["healthCheck","instantQuery","rangeQuery","labelNames","labelValues","metricMetadata","series","parseQuery","PrometheusDatasourceEditor","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders","headers","params","getBuiltinVariableDefinitions","kind","name","value","source","display","description","hidden","PrometheusDatasource","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SACEA,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,UAAU,EACVC,WAAW,EAEXC,cAAc,EACdC,MAAM,EACNC,UAAU,QACL,WAAW;AAElB,SAASC,0BAA0B,QAAQ,+BAA+B;AAE1E;;CAEC,GACD,MAAMC,eAA6F,CAACC,MAAMC;IACxG,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGH;IAC7B,MAAM,EAAEI,QAAQ,EAAE,GAAGH;IAErB,4FAA4F;IAC5F,MAAMI,gBAAgBH,aAAaE;IACnC,IAAIC,kBAAkBC,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,cAAcL,OAAOH,KAAKS;IAEhC,qFAAqF;IACrF,OAAO;QACLR,SAAS;YACPI;QACF;QACAf,aAAaA,YAAY;YAAEe;YAAeI,SAASD;QAAY;QAC/DjB,cAAc,CAACmB,QAAQD,UAAYlB,aAAamB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACzGhB,YAAY,CAACkB,QAAQD,UAAYjB,WAAWkB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACrGf,YAAY,CAACiB,QAAQD,UAAYhB,WAAWiB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACrGd,aAAa,CAACgB,QAAQD,UAAYf,YAAYgB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACvGb,gBAAgB,CAACe,QAAQD,UAAYd,eAAee,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QAC7GZ,QAAQ,CAACc,QAAQD,UAAYb,OAAOc,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QAC7FX,YAAY,CAACa,QAAQD,UAAYZ,WAAWa,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;IACvG;AACF;AAEA,MAAMG,gCAAmE;IACvE,OAAO;QACL;YACEC,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aAAa;oBACbC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;KACD;AACH;AAEA,OAAO,MAAMC,uBAAqF;IAChGpB;IACAY;IACAS,wBAAwBtB;IACxBuB,sBAAsB,IAAO,CAAA;YAAEnB,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusTimeSeriesQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,2BAA2B,CAAC;AAGlF,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,qBAAqB,CAAC,6BAA6B,CAgB1F,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system';\nimport { getTimeSeriesData } from './get-time-series-data';\nimport { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\n/**\n * The core Prometheus TimeSeriesQuery plugin for Perses.\n */\nexport const PrometheusTimeSeriesQuery: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec> = {\n getTimeSeriesData,\n OptionsEditorComponent: PrometheusTimeSeriesQueryEditor,\n createInitialOptions: () => ({\n query: '',\n datasource: undefined,\n }),\n dependsOn: (spec) => {\n // Variables can be used in the query and/or in the legend format string\n const queryVariables = parseVariables(spec.query);\n const legendVariables = parseVariables(spec.seriesNameFormat || '');\n const allVariables = [...new Set([...queryVariables, ...legendVariables])];\n return {\n variables: allVariables,\n };\n },\n};\n"],"names":["parseVariables","getTimeSeriesData","PrometheusTimeSeriesQueryEditor","PrometheusTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined","dependsOn","spec","queryVariables","legendVariables","seriesNameFormat","allVariables","Set","variables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAgCA,cAAc,QAAQ,4BAA4B;AAClF,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,+BAA+B,QAAQ,oCAAoC;AAGpF;;CAEC,GACD,OAAO,MAAMC,4BAAkF;IAC7FF;IACAG,wBAAwBF;IACxBG,sBAAsB,IAAO,CAAA;YAC3BC,OAAO;YACPC,YAAYC;QACd,CAAA;IACAC,WAAW,CAACC;QACV,wEAAwE;QACxE,MAAMC,iBAAiBX,eAAeU,KAAKJ,KAAK;QAChD,MAAMM,kBAAkBZ,eAAeU,KAAKG,gBAAgB,IAAI;QAChE,MAAMC,eAAe;eAAI,IAAIC,IAAI;mBAAIJ;mBAAmBC;aAAgB;SAAE;QAC1E,OAAO;YACLI,WAAWF;QACb;IACF;AACF,EAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAWrC,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CA6EzG"}
@@ -13,6 +13,7 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { produce } from 'immer';
15
15
  import { DatasourceSelect, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';
16
+ import { useId } from '@perses-dev/components';
16
17
  import { FormControl, InputLabel, Stack, TextField } from '@mui/material';
17
18
  import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
18
19
  import { DEFAULT_SCRAPE_INTERVAL } from '../types';
@@ -23,16 +24,15 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
23
24
  */ export function PrometheusTimeSeriesQueryEditor(props) {
24
25
  const { onChange, value } = props;
25
26
  const { datasource } = value;
26
- const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM;
27
- const datasourceSelectLabelID = `prom-datasource-label-${selectedDatasource.name || 'default'}`;
27
+ const selectedDatasource = datasource ?? DEFAULT_PROM;
28
+ const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page
28
29
  const { data: client } = useDatasourceClient(selectedDatasource);
29
- const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
30
+ const promURL = client?.options.datasourceUrl;
30
31
  const { data: datasourceResource } = useDatasource(selectedDatasource);
31
32
  const { handleQueryChange, handleQueryBlur } = useQueryState(props);
32
33
  const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);
33
34
  const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);
34
- var _ref;
35
- const minStepPlaceholder = (_ref = minStep !== null && minStep !== void 0 ? minStep : datasourceResource && (datasourceResource === null || datasourceResource === void 0 ? void 0 : datasourceResource.plugin.spec).scrapeInterval) !== null && _ref !== void 0 ? _ref : DEFAULT_SCRAPE_INTERVAL;
35
+ const minStepPlaceholder = minStep ?? (datasourceResource && (datasourceResource?.plugin.spec).scrapeInterval) ?? DEFAULT_SCRAPE_INTERVAL;
36
36
  const handleDatasourceChange = (next)=>{
37
37
  if (isPrometheusDatasourceSelector(next)) {
38
38
  onChange(produce(value, (draft)=>{
@@ -53,6 +53,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
53
53
  children: [
54
54
  /*#__PURE__*/ _jsx(InputLabel, {
55
55
  id: datasourceSelectLabelID,
56
+ shrink: true,
56
57
  children: "Prometheus Datasource"
57
58
  }),
58
59
  /*#__PURE__*/ _jsx(DatasourceSelect, {
@@ -60,7 +61,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
60
61
  value: selectedDatasource,
61
62
  onChange: handleDatasourceChange,
62
63
  labelId: datasourceSelectLabelID,
63
- label: "Prometheus Datasource"
64
+ label: "Prometheus Datasource",
65
+ notched: true
64
66
  })
65
67
  ]
66
68
  }),
@@ -84,7 +86,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
84
86
  label: "Legend",
85
87
  placeholder: "Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...",
86
88
  helperText: "Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",
87
- value: format !== null && format !== void 0 ? format : '',
89
+ value: format ?? '',
88
90
  onChange: (e)=>handleFormatChange(e.target.value),
89
91
  onBlur: handleFormatBlur
90
92
  }),
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport { DatasourceSelect, DatasourceSelectProps, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';\nimport { useId } from '@perses-dev/components';\nimport { FormControl, InputLabel, Stack, TextField } from '@mui/material';\nimport { ReactElement } from 'react';\nimport {\n DEFAULT_PROM,\n DurationString,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n} from '../../model';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PromQLEditor } from '../../components';\nimport {\n PrometheusTimeSeriesQueryEditorProps,\n useQueryState,\n useFormatState,\n useMinStepState,\n} from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const { data: datasourceResource } = useDatasource(selectedDatasource);\n\n const { handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);\n const minStepPlaceholder =\n minStep ??\n (datasourceResource && (datasourceResource?.plugin.spec as PrometheusDatasourceSpec).scrapeInterval) ??\n DEFAULT_SCRAPE_INTERVAL;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <InputLabel id={datasourceSelectLabelID} shrink>\n Prometheus Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.query} // here we are passing `value.query` and not `query` from useQueryState in order to get updates only on onBlur events\n datasource={selectedDatasource}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n <Stack direction=\"row\" spacing={2}>\n <TextField\n fullWidth\n label=\"Legend\"\n placeholder=\"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...\"\n helperText=\"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n />\n <TextField\n label=\"Min Step\"\n placeholder={minStepPlaceholder}\n helperText=\"Lower bound for the step. If not provided, the scrape interval of the datasource is used.\"\n value={minStep}\n onChange={(e) => handleMinStepChange(e.target.value as DurationString)}\n onBlur={handleMinStepBlur}\n sx={{ width: '250px' }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useId","FormControl","InputLabel","Stack","TextField","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","selectedDatasource","datasourceSelectLabelID","data","client","promURL","options","datasourceUrl","datasourceResource","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","minStep","handleMinStepChange","handleMinStepBlur","minStepPlaceholder","plugin","spec","scrapeInterval","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","id","shrink","datasourcePluginKind","labelId","label","notched","completeConfig","remote","url","query","onBlur","direction","placeholder","helperText","e","target","sx","width"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-time-series-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,2BAA2B,CAAC;AAgBpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAqGvG,CAAC"}