@perses-dev/prometheus-plugin 0.56.0 → 0.57.0-beta.0

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 (204) hide show
  1. package/__mf/js/Prometheus.2bb892ab.js +6 -0
  2. package/__mf/js/async/1233.0ab88b51.js +1 -0
  3. package/__mf/js/async/1324.ce01eced.js +1 -0
  4. package/__mf/js/async/1432.0c3e4ed0.js +1 -0
  5. package/__mf/js/async/1490.7e5068f1.js +22 -0
  6. package/__mf/js/async/1605.dc180cb8.js +110 -0
  7. package/__mf/js/async/1616.7587ce79.js +1 -0
  8. package/__mf/js/async/1728.af16c4ec.js +1 -0
  9. package/__mf/js/async/1969.372d36b8.js +1 -0
  10. package/__mf/js/async/2043.d0fbb886.js +2 -0
  11. package/__mf/js/async/2186.e58838a5.js +38 -0
  12. package/__mf/js/async/2506.1e336b3b.js +1 -0
  13. package/__mf/js/async/2984.7182c2f5.js +1 -0
  14. package/__mf/js/async/2999.1d8347df.js +1 -0
  15. package/__mf/js/async/3184.6b4ad42e.js +1 -0
  16. package/__mf/js/async/3664.ba8b26b6.js +2 -0
  17. package/__mf/js/async/392.7cda691a.js +2 -0
  18. package/__mf/js/async/3963.5fef6ffb.js +1 -0
  19. package/__mf/js/async/3996.69a9c1dc.js +1 -0
  20. package/__mf/js/async/{1964.1d168a86.js → 4121.828d661d.js} +2 -2
  21. package/__mf/js/async/4626.173e602a.js +1 -0
  22. package/__mf/js/async/4987.c12b89cb.js +1 -0
  23. package/__mf/js/async/{8930.700a5439.js → 5002.e4f54e8e.js} +1 -1
  24. package/__mf/js/async/5071.e1c33fa7.js +1 -0
  25. package/__mf/js/async/529.2303b01b.js +1 -0
  26. package/__mf/js/async/5440.c13c3533.js +2 -0
  27. package/__mf/js/async/5501.6166367c.js +2 -0
  28. package/__mf/js/async/{5214.0fca84ed.js → 5587.4d72fc35.js} +1 -1
  29. package/__mf/js/async/5763.4ba478ff.js +1 -0
  30. package/__mf/js/async/5922.d1619ac1.js +1 -0
  31. package/__mf/js/async/6149.19799c37.js +7 -0
  32. package/__mf/js/async/6274.478a68f8.js +2 -0
  33. package/__mf/js/async/6283.181cb622.js +2 -0
  34. package/__mf/js/async/6969.b959b6f8.js +1 -0
  35. package/__mf/js/async/{4062.06f48b93.js → 7177.205c9aaf.js} +1 -1
  36. package/__mf/js/async/7192.d835931b.js +1 -0
  37. package/__mf/js/async/7894.9c5245d7.js +1 -0
  38. package/__mf/js/async/7968.6ac0ce96.js +1 -0
  39. package/__mf/js/async/7978.9532d5b8.js +1 -0
  40. package/__mf/js/async/8356.789e1dfb.js +1 -0
  41. package/__mf/js/async/8470.9b14a625.js +2 -0
  42. package/__mf/js/async/873.448eab23.js +1 -0
  43. package/__mf/js/async/8888.59eb50a2.js +1 -0
  44. package/__mf/js/async/9020.c19782f1.js +1 -0
  45. package/__mf/js/async/9184.43a8d927.js +1 -0
  46. package/__mf/js/async/9235.36c3cd8c.js +1 -0
  47. package/__mf/js/async/9351.715f25c3.js +1 -0
  48. package/__mf/js/async/941.53b13124.js +2 -0
  49. package/__mf/js/async/9518.38e38a33.js +1 -0
  50. package/__mf/js/async/9588.9081c7de.js +1 -0
  51. package/__mf/js/async/9605.a92ec9c1.js +1 -0
  52. package/__mf/js/async/9836.00da6086.js +1 -0
  53. package/__mf/js/async/__federation_expose_PrometheusDatasource.6f63e147.js +1 -0
  54. package/__mf/js/async/__federation_expose_PrometheusExplorer.584a073d.js +1 -0
  55. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.40984a4d.js +1 -0
  56. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.bd3eb00c.js +1 -0
  57. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.5cca8417.js +1 -0
  58. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.f59141f4.js +1 -0
  59. package/__mf/js/main.9617b605.js +6 -0
  60. package/lib/bootstrap.js +1 -1
  61. package/lib/bootstrap.js.map +1 -1
  62. package/lib/cjs/components/PromQLEditor.js +4 -7
  63. package/lib/cjs/components/promql/ast.js +10 -10
  64. package/lib/cjs/components/promql/format.js +3 -3
  65. package/lib/cjs/components/promql/utils.js +5 -5
  66. package/lib/cjs/components/query.js +3 -3
  67. package/lib/cjs/explore/PrometheusExplorer.js +10 -6
  68. package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +4 -4
  69. package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +3 -3
  70. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +4 -4
  71. package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +3 -3
  72. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +4 -4
  73. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +4 -4
  74. package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +5 -5
  75. package/lib/cjs/index-federation.js +12 -12
  76. package/lib/cjs/model/parse-sample-values.js +3 -3
  77. package/lib/cjs/model/prometheus-client.js +29 -19
  78. package/lib/cjs/model/prometheus-selectors.js +5 -5
  79. package/lib/cjs/model/time.js +4 -4
  80. package/lib/cjs/plugins/PrometheusDatasourceEditor.js +175 -2
  81. package/lib/cjs/plugins/prometheus-datasource.js +17 -9
  82. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +36 -1
  83. package/lib/cjs/plugins/prometheus-time-series-query/query-editor-model.js +4 -4
  84. package/lib/cjs/plugins/prometheus-variables.js +52 -33
  85. package/lib/cjs/utils/utils.js +4 -4
  86. package/lib/components/PromQLEditor.d.ts +5 -1
  87. package/lib/components/PromQLEditor.d.ts.map +1 -1
  88. package/lib/components/PromQLEditor.js +5 -8
  89. package/lib/components/PromQLEditor.js.map +1 -1
  90. package/lib/components/TreeNode.js +1 -1
  91. package/lib/components/TreeNode.js.map +1 -1
  92. package/lib/components/promql/format.js +1 -1
  93. package/lib/components/promql/format.js.map +1 -1
  94. package/lib/explore/PrometheusExplorer.d.ts.map +1 -1
  95. package/lib/explore/PrometheusExplorer.js +10 -6
  96. package/lib/explore/PrometheusExplorer.js.map +1 -1
  97. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +1 -1
  98. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -1
  99. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +1 -1
  100. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -1
  101. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +1 -1
  102. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -1
  103. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +1 -1
  104. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -1
  105. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  106. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
  107. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +1 -1
  108. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -1
  109. package/lib/model/prometheus-client.d.ts +1 -0
  110. package/lib/model/prometheus-client.d.ts.map +1 -1
  111. package/lib/model/prometheus-client.js +19 -9
  112. package/lib/model/prometheus-client.js.map +1 -1
  113. package/lib/plugins/MatcherEditor.js +1 -1
  114. package/lib/plugins/MatcherEditor.js.map +1 -1
  115. package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
  116. package/lib/plugins/PrometheusDatasourceEditor.js +135 -3
  117. package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -1
  118. package/lib/plugins/prometheus-datasource.js +17 -9
  119. package/lib/plugins/prometheus-datasource.js.map +1 -1
  120. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  121. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +39 -4
  122. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  123. package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  124. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  125. package/lib/plugins/prometheus-variables.d.ts.map +1 -1
  126. package/lib/plugins/prometheus-variables.js +47 -28
  127. package/lib/plugins/prometheus-variables.js.map +1 -1
  128. package/lib/plugins/types.d.ts +1 -0
  129. package/lib/plugins/types.d.ts.map +1 -1
  130. package/lib/plugins/types.js.map +1 -1
  131. package/mf-manifest.json +268 -253
  132. package/mf-stats.json +271 -254
  133. package/package.json +7 -7
  134. package/__mf/js/Prometheus.4d0d5812.js +0 -5
  135. package/__mf/js/async/1339.194207db.js +0 -1
  136. package/__mf/js/async/1441.c735f7dd.js +0 -1
  137. package/__mf/js/async/1576.8eac7ce9.js +0 -1
  138. package/__mf/js/async/212.5fcca998.js +0 -1
  139. package/__mf/js/async/2292.57d8fd0d.js +0 -2
  140. package/__mf/js/async/3224.b63f87bf.js +0 -1
  141. package/__mf/js/async/3507.f1653337.js +0 -101
  142. package/__mf/js/async/3749.3ecd9372.js +0 -1
  143. package/__mf/js/async/3863.7192dfdf.js +0 -2
  144. package/__mf/js/async/3960.3eedafbd.js +0 -2
  145. package/__mf/js/async/3980.0b0d272c.js +0 -2
  146. package/__mf/js/async/4075.dab1b7b8.js +0 -1
  147. package/__mf/js/async/4238.c48b1950.js +0 -1
  148. package/__mf/js/async/4421.1fcb466e.js +0 -1
  149. package/__mf/js/async/4535.f24704ea.js +0 -1
  150. package/__mf/js/async/4557.f3eb9456.js +0 -2
  151. package/__mf/js/async/4576.f42daf99.js +0 -1
  152. package/__mf/js/async/4665.cad36935.js +0 -1
  153. package/__mf/js/async/4676.b7a22f90.js +0 -22
  154. package/__mf/js/async/5257.ce463cb7.js +0 -1
  155. package/__mf/js/async/5409.955ffd51.js +0 -1
  156. package/__mf/js/async/5614.cce8ba96.js +0 -1
  157. package/__mf/js/async/5724.794828e3.js +0 -1
  158. package/__mf/js/async/5774.a3fae698.js +0 -1
  159. package/__mf/js/async/5790.a9b31ca8.js +0 -1
  160. package/__mf/js/async/58.1c9a8daa.js +0 -2
  161. package/__mf/js/async/5981.eb502d27.js +0 -2
  162. package/__mf/js/async/6292.2afe0c6d.js +0 -1
  163. package/__mf/js/async/6341.20eccf91.js +0 -7
  164. package/__mf/js/async/6377.c40920f2.js +0 -2
  165. package/__mf/js/async/6770.7099bb3b.js +0 -1
  166. package/__mf/js/async/684.4495f632.js +0 -1
  167. package/__mf/js/async/694.8462a746.js +0 -1
  168. package/__mf/js/async/7272.6fa2f127.js +0 -1
  169. package/__mf/js/async/7376.2e948f2b.js +0 -1
  170. package/__mf/js/async/738.a1ffff79.js +0 -1
  171. package/__mf/js/async/7740.a8777825.js +0 -1
  172. package/__mf/js/async/8045.7f554a45.js +0 -10
  173. package/__mf/js/async/8164.bb3d3363.js +0 -1
  174. package/__mf/js/async/8216.e689c178.js +0 -1
  175. package/__mf/js/async/8488.cbbe542b.js +0 -1
  176. package/__mf/js/async/8587.40df6f5c.js +0 -1
  177. package/__mf/js/async/8706.89677575.js +0 -1
  178. package/__mf/js/async/9010.bdb2ef97.js +0 -1
  179. package/__mf/js/async/9173.915b80af.js +0 -2
  180. package/__mf/js/async/9550.642ce5ad.js +0 -38
  181. package/__mf/js/async/9817.70eae424.js +0 -1
  182. package/__mf/js/async/__federation_expose_PrometheusDatasource.45ee94e2.js +0 -1
  183. package/__mf/js/async/__federation_expose_PrometheusExplorer.b8e555e1.js +0 -1
  184. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.00dfb1dd.js +0 -1
  185. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.956ef2d0.js +0 -1
  186. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.59f2d170.js +0 -1
  187. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d7143352.js +0 -1
  188. package/__mf/js/main.afc2ee60.js +0 -5
  189. /package/__mf/css/async/{1339.d3010b86.css → 1233.d3010b86.css} +0 -0
  190. /package/__mf/css/async/{1576.d3010b86.css → 1324.d3010b86.css} +0 -0
  191. /package/__mf/css/async/{4576.d3010b86.css → 9518.d3010b86.css} +0 -0
  192. /package/__mf/js/async/{4676.b7a22f90.js.LICENSE.txt → 1490.7e5068f1.js.LICENSE.txt} +0 -0
  193. /package/__mf/js/async/{8045.7f554a45.js.LICENSE.txt → 1605.dc180cb8.js.LICENSE.txt} +0 -0
  194. /package/__mf/js/async/{2292.57d8fd0d.js.LICENSE.txt → 2043.d0fbb886.js.LICENSE.txt} +0 -0
  195. /package/__mf/js/async/{58.1c9a8daa.js.LICENSE.txt → 3664.ba8b26b6.js.LICENSE.txt} +0 -0
  196. /package/__mf/js/async/{5981.eb502d27.js.LICENSE.txt → 392.7cda691a.js.LICENSE.txt} +0 -0
  197. /package/__mf/js/async/{1964.1d168a86.js.LICENSE.txt → 4121.828d661d.js.LICENSE.txt} +0 -0
  198. /package/__mf/js/async/{6377.c40920f2.js.LICENSE.txt → 5440.c13c3533.js.LICENSE.txt} +0 -0
  199. /package/__mf/js/async/{4557.f3eb9456.js.LICENSE.txt → 5501.6166367c.js.LICENSE.txt} +0 -0
  200. /package/__mf/js/async/{6341.20eccf91.js.LICENSE.txt → 6149.19799c37.js.LICENSE.txt} +0 -0
  201. /package/__mf/js/async/{3960.3eedafbd.js.LICENSE.txt → 6274.478a68f8.js.LICENSE.txt} +0 -0
  202. /package/__mf/js/async/{3980.0b0d272c.js.LICENSE.txt → 6283.181cb622.js.LICENSE.txt} +0 -0
  203. /package/__mf/js/async/{9173.915b80af.js.LICENSE.txt → 8470.9b14a625.js.LICENSE.txt} +0 -0
  204. /package/__mf/js/async/{3863.7192dfdf.js.LICENSE.txt → 941.53b13124.js.LICENSE.txt} +0 -0
@@ -17,20 +17,20 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useLabelValues: function() {
24
+ get useLabelValues () {
25
25
  return useLabelValues;
26
26
  },
27
- useLabels: function() {
27
+ get useLabels () {
28
28
  return useLabels;
29
29
  },
30
- useMetricMetadata: function() {
30
+ get useMetricMetadata () {
31
31
  return useMetricMetadata;
32
32
  },
33
- useSeriesStates: function() {
33
+ get useSeriesStates () {
34
34
  return useSeriesStates;
35
35
  }
36
36
  });
@@ -1,15 +1,3 @@
1
- // Copyright 2024 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
1
  "use strict";
14
2
  function _getRequireWildcardCache(nodeInterop) {
15
3
  if (typeof WeakMap !== "function") return null;
@@ -52,4 +40,16 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
40
  }
53
41
  return newObj;
54
42
  }
43
+ // Copyright 2024 The Perses Authors
44
+ // Licensed under the Apache License, Version 2.0 (the "License");
45
+ // you may not use this file except in compliance with the License.
46
+ // You may obtain a copy of the License at
47
+ //
48
+ // http://www.apache.org/licenses/LICENSE-2.0
49
+ //
50
+ // Unless required by applicable law or agreed to in writing, software
51
+ // distributed under the License is distributed on an "AS IS" BASIS,
52
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ // See the License for the specific language governing permissions and
54
+ // limitations under the License.
55
55
  Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- parseSampleValue: function() {
24
+ get parseSampleValue () {
25
25
  return parseSampleValue;
26
26
  },
27
- parseValueTuple: function() {
27
+ get parseValueTuple () {
28
28
  return parseValueTuple;
29
29
  }
30
30
  });
@@ -17,42 +17,56 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- fetchResults: function() {
24
+ get fetchResults () {
25
25
  return fetchResults;
26
26
  },
27
- healthCheck: function() {
27
+ get healthCheck () {
28
28
  return healthCheck;
29
29
  },
30
- instantQuery: function() {
30
+ get instantQuery () {
31
31
  return instantQuery;
32
32
  },
33
- labelNames: function() {
33
+ get labelNames () {
34
34
  return labelNames;
35
35
  },
36
- labelValues: function() {
36
+ get labelValues () {
37
37
  return labelValues;
38
38
  },
39
- metricMetadata: function() {
39
+ get metricMetadata () {
40
40
  return metricMetadata;
41
41
  },
42
- parseQuery: function() {
42
+ get parseQuery () {
43
43
  return parseQuery;
44
44
  },
45
- rangeQuery: function() {
45
+ get rangeQuery () {
46
46
  return rangeQuery;
47
47
  },
48
- series: function() {
48
+ get series () {
49
49
  return series;
50
50
  }
51
51
  });
52
52
  const _core = require("@perses-dev/core");
53
+ /**
54
+ * Builds a query string from datasource-level query parameters.
55
+ * Optionally merges with existing URLSearchParams.
56
+ * Returns empty string if no parameters, otherwise returns query string with leading '?'.
57
+ */ function buildQueryString(queryParams, initialParams) {
58
+ const urlParams = initialParams || new URLSearchParams();
59
+ if (queryParams) {
60
+ Object.entries(queryParams).forEach(([key, value])=>{
61
+ urlParams.set(key, value);
62
+ });
63
+ }
64
+ const queryString = urlParams.toString();
65
+ return queryString !== '' ? `?${queryString}` : '';
66
+ }
53
67
  function healthCheck(queryOptions) {
54
68
  return async ()=>{
55
- const url = `${queryOptions.datasourceUrl}/-/healthy`;
69
+ const url = `${queryOptions.datasourceUrl}/-/healthy${buildQueryString(queryOptions.queryParams)}`;
56
70
  try {
57
71
  const resp = await (0, _core.fetch)(url, {
58
72
  headers: queryOptions.headers,
@@ -100,20 +114,16 @@ function parseQuery(params, queryOptions) {
100
114
  return fetchWithPost(apiURI, params, queryOptions);
101
115
  }
102
116
  function fetchWithGet(apiURI, params, queryOptions) {
103
- const { datasourceUrl, headers } = queryOptions;
104
- let url = `${datasourceUrl}${apiURI}`;
105
- const urlParams = createSearchParams(params).toString();
106
- if (urlParams !== '') {
107
- url += `?${urlParams}`;
108
- }
117
+ const { datasourceUrl, headers, queryParams } = queryOptions;
118
+ const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams, createSearchParams(params))}`;
109
119
  return (0, _core.fetchJson)(url, {
110
120
  method: 'GET',
111
121
  headers
112
122
  });
113
123
  }
114
124
  function fetchWithPost(apiURI, params, queryOptions) {
115
- const { datasourceUrl, headers, abortSignal: signal } = queryOptions;
116
- const url = `${datasourceUrl}${apiURI}`;
125
+ const { datasourceUrl, headers, abortSignal: signal, queryParams } = queryOptions;
126
+ const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams)}`;
117
127
  const init = {
118
128
  method: 'POST',
119
129
  headers: {
@@ -17,20 +17,20 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DEFAULT_PROM: function() {
24
+ get DEFAULT_PROM () {
25
25
  return DEFAULT_PROM;
26
26
  },
27
- PROM_DATASOURCE_KIND: function() {
27
+ get PROM_DATASOURCE_KIND () {
28
28
  return PROM_DATASOURCE_KIND;
29
29
  },
30
- isDefaultPromSelector: function() {
30
+ get isDefaultPromSelector () {
31
31
  return isDefaultPromSelector;
32
32
  },
33
- isPrometheusDatasourceSelector: function() {
33
+ get isPrometheusDatasourceSelector () {
34
34
  return isPrometheusDatasourceSelector;
35
35
  }
36
36
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getDurationStringSeconds: function() {
24
+ get getDurationStringSeconds () {
25
25
  return getDurationStringSeconds;
26
26
  },
27
- getPrometheusTimeRange: function() {
27
+ get getPrometheusTimeRange () {
28
28
  return getPrometheusTimeRange;
29
29
  },
30
- getRangeStep: function() {
30
+ get getRangeStep () {
31
31
  return getRangeStep;
32
32
  }
33
33
  });
@@ -23,15 +23,127 @@ Object.defineProperty(exports, "PrometheusDatasourceEditor", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _pluginsystem = require("@perses-dev/plugin-system");
25
25
  const _material = require("@mui/material");
26
- const _react = /*#__PURE__*/ _interop_require_default(require("react"));
26
+ const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
27
+ const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
28
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
27
29
  const _types = require("./types");
28
30
  function _interop_require_default(obj) {
29
31
  return obj && obj.__esModule ? obj : {
30
32
  default: obj
31
33
  };
32
34
  }
35
+ function _getRequireWildcardCache(nodeInterop) {
36
+ if (typeof WeakMap !== "function") return null;
37
+ var cacheBabelInterop = new WeakMap();
38
+ var cacheNodeInterop = new WeakMap();
39
+ return (_getRequireWildcardCache = function(nodeInterop) {
40
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
41
+ })(nodeInterop);
42
+ }
43
+ function _interop_require_wildcard(obj, nodeInterop) {
44
+ if (!nodeInterop && obj && obj.__esModule) {
45
+ return obj;
46
+ }
47
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
48
+ return {
49
+ default: obj
50
+ };
51
+ }
52
+ var cache = _getRequireWildcardCache(nodeInterop);
53
+ if (cache && cache.has(obj)) {
54
+ return cache.get(obj);
55
+ }
56
+ var newObj = {
57
+ __proto__: null
58
+ };
59
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
60
+ for(var key in obj){
61
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
62
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
63
+ if (desc && (desc.get || desc.set)) {
64
+ Object.defineProperty(newObj, key, desc);
65
+ } else {
66
+ newObj[key] = obj[key];
67
+ }
68
+ }
69
+ }
70
+ newObj.default = obj;
71
+ if (cache) {
72
+ cache.set(obj, newObj);
73
+ }
74
+ return newObj;
75
+ }
33
76
  function PrometheusDatasourceEditor(props) {
34
77
  const { value, onChange, isReadonly } = props;
78
+ // Counter for generating unique IDs
79
+ const nextIdRef = (0, _react.useRef)(0);
80
+ // Use local state to maintain an array of entries during editing, instead of
81
+ // manipulating a map directly which causes weird UX.
82
+ const [entries, setEntries] = (0, _react.useState)(()=>{
83
+ const queryParams = value.queryParams ?? {};
84
+ return Object.entries(queryParams).map(([key, value])=>({
85
+ id: String(nextIdRef.current++),
86
+ key,
87
+ value
88
+ }));
89
+ });
90
+ // Check for duplicate keys
91
+ const keyMap = new Map();
92
+ const duplicateKeys = new Set();
93
+ entries.forEach(({ key })=>{
94
+ if (key !== '') {
95
+ const count = (keyMap.get(key) || 0) + 1;
96
+ keyMap.set(key, count);
97
+ if (count > 1) {
98
+ duplicateKeys.add(key);
99
+ }
100
+ }
101
+ });
102
+ const hasDuplicates = duplicateKeys.size > 0;
103
+ // Convert entries array to object and trigger onChange
104
+ const syncToParent = (newEntries)=>{
105
+ const newParams = {};
106
+ newEntries.forEach(({ key, value })=>{
107
+ if (key !== '') {
108
+ newParams[key] = value;
109
+ }
110
+ });
111
+ onChange({
112
+ ...value,
113
+ queryParams: Object.keys(newParams).length > 0 ? newParams : undefined
114
+ });
115
+ };
116
+ const handleQueryParamChange = (id, field, newValue)=>{
117
+ const newEntries = entries.map((entry)=>{
118
+ if (entry.id !== id) return entry;
119
+ return field === 'key' ? {
120
+ ...entry,
121
+ key: newValue
122
+ } : {
123
+ ...entry,
124
+ value: newValue
125
+ };
126
+ });
127
+ setEntries(newEntries);
128
+ syncToParent(newEntries);
129
+ };
130
+ const addQueryParam = ()=>{
131
+ const newEntries = [
132
+ ...entries,
133
+ {
134
+ id: String(nextIdRef.current++),
135
+ key: '',
136
+ value: ''
137
+ }
138
+ ];
139
+ setEntries(newEntries);
140
+ syncToParent(newEntries);
141
+ };
142
+ const removeQueryParam = (id)=>{
143
+ const newEntries = entries.filter((entry)=>entry.id !== id);
144
+ setEntries(newEntries);
145
+ syncToParent(newEntries);
146
+ };
35
147
  const initialSpecDirect = {
36
148
  directUrl: ''
37
149
  };
@@ -82,6 +194,7 @@ function PrometheusDatasourceEditor(props) {
82
194
  children: "General Settings"
83
195
  }),
84
196
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
197
+ size: "small",
85
198
  fullWidth: true,
86
199
  label: "Scrape Interval",
87
200
  value: value.scrapeInterval || '',
@@ -95,7 +208,8 @@ function PrometheusDatasourceEditor(props) {
95
208
  onChange: (e)=>onChange({
96
209
  ...value,
97
210
  scrapeInterval: e.target.value
98
- })
211
+ }),
212
+ helperText: "Set it to match the typical scrape interval used in your Prometheus instance."
99
213
  }),
100
214
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.HTTPSettingsEditor, {
101
215
  value: value,
@@ -103,6 +217,65 @@ function PrometheusDatasourceEditor(props) {
103
217
  isReadonly: isReadonly,
104
218
  initialSpecDirect: initialSpecDirect,
105
219
  initialSpecProxy: initialSpecProxy
220
+ }),
221
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
222
+ variant: "h5",
223
+ mt: 2,
224
+ mb: 1,
225
+ children: "Query Parameters"
226
+ }),
227
+ entries.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
228
+ children: entries.map((entry)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
229
+ display: "flex",
230
+ alignItems: "center",
231
+ gap: 2,
232
+ mb: 1,
233
+ children: [
234
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
235
+ size: "small",
236
+ label: "Key",
237
+ value: entry.key,
238
+ placeholder: "Parameter name",
239
+ disabled: isReadonly,
240
+ onChange: (e)=>handleQueryParamChange(entry.id, 'key', e.target.value),
241
+ error: duplicateKeys.has(entry.key),
242
+ sx: {
243
+ minWidth: 150
244
+ }
245
+ }),
246
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
247
+ size: "small",
248
+ label: "Value",
249
+ value: entry.value,
250
+ placeholder: "Parameter value",
251
+ disabled: isReadonly,
252
+ onChange: (e)=>handleQueryParamChange(entry.id, 'value', e.target.value),
253
+ sx: {
254
+ minWidth: 150,
255
+ flexGrow: 1
256
+ }
257
+ }),
258
+ !isReadonly && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
259
+ onClick: ()=>removeQueryParam(entry.id),
260
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
261
+ })
262
+ ]
263
+ }, entry.id))
264
+ }),
265
+ hasDuplicates && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
266
+ variant: "body2",
267
+ color: "error",
268
+ mb: 1,
269
+ children: "Duplicate parameter keys detected. Each key must be unique."
270
+ }),
271
+ entries.length === 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
272
+ variant: "body2",
273
+ color: "textSecondary",
274
+ children: "No query parameters configured. Use query parameters to pass additional options to Prometheus (e.g., dedup=false for Thanos)."
275
+ }),
276
+ !isReadonly && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
277
+ onClick: addQueryParam,
278
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
106
279
  })
107
280
  ]
108
281
  });
@@ -25,7 +25,7 @@ const _PrometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
25
25
  /**
26
26
  * Creates a PrometheusClient for a specific datasource spec.
27
27
  */ const createClient = (spec, options)=>{
28
- const { directUrl, proxy } = spec;
28
+ const { directUrl, proxy, queryParams } = spec;
29
29
  const { proxyUrl } = options;
30
30
  // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
31
31
  const datasourceUrl = directUrl ?? proxyUrl;
@@ -40,42 +40,50 @@ const _PrometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
40
40
  },
41
41
  healthCheck: (0, _model.healthCheck)({
42
42
  datasourceUrl,
43
- headers: specHeaders
43
+ headers: specHeaders,
44
+ queryParams
44
45
  }),
45
46
  instantQuery: (params, headers, abortSignal)=>(0, _model.instantQuery)(params, {
46
47
  datasourceUrl,
47
48
  headers: headers ?? specHeaders,
48
- abortSignal
49
+ abortSignal,
50
+ queryParams
49
51
  }),
50
52
  rangeQuery: (params, headers, abortSignal)=>(0, _model.rangeQuery)(params, {
51
53
  datasourceUrl,
52
54
  headers: headers ?? specHeaders,
53
- abortSignal
55
+ abortSignal,
56
+ queryParams
54
57
  }),
55
58
  labelNames: (params, headers, abortSignal)=>(0, _model.labelNames)(params, {
56
59
  datasourceUrl,
57
60
  headers: headers ?? specHeaders,
58
- abortSignal
61
+ abortSignal,
62
+ queryParams
59
63
  }),
60
64
  labelValues: (params, headers, abortSignal)=>(0, _model.labelValues)(params, {
61
65
  datasourceUrl,
62
66
  headers: headers ?? specHeaders,
63
- abortSignal
67
+ abortSignal,
68
+ queryParams
64
69
  }),
65
70
  metricMetadata: (params, headers, abortSignal)=>(0, _model.metricMetadata)(params, {
66
71
  datasourceUrl,
67
72
  headers: headers ?? specHeaders,
68
- abortSignal
73
+ abortSignal,
74
+ queryParams
69
75
  }),
70
76
  series: (params, headers, abortSignal)=>(0, _model.series)(params, {
71
77
  datasourceUrl,
72
78
  headers: headers ?? specHeaders,
73
- abortSignal
79
+ abortSignal,
80
+ queryParams
74
81
  }),
75
82
  parseQuery: (params, headers, abortSignal)=>(0, _model.parseQuery)(params, {
76
83
  datasourceUrl,
77
84
  headers: headers ?? specHeaders,
78
- abortSignal
85
+ abortSignal,
86
+ queryParams
79
87
  })
80
88
  };
81
89
  };
@@ -25,6 +25,8 @@ const _immer = require("immer");
25
25
  const _pluginsystem = require("@perses-dev/plugin-system");
26
26
  const _components = require("@perses-dev/components");
27
27
  const _material = require("@mui/material");
28
+ const _react = require("react");
29
+ const _dashboards = require("@perses-dev/dashboards");
28
30
  const _model = require("../../model");
29
31
  const _types = require("../types");
30
32
  const _components1 = require("../../components");
@@ -55,6 +57,38 @@ function PrometheusTimeSeriesQueryEditor(props) {
55
57
  }
56
58
  throw new Error('Got unexpected non-Prometheus datasource selector');
57
59
  };
60
+ const variableState = (0, _pluginsystem.useAllVariableValues)();
61
+ const { absoluteTimeRange } = (0, _pluginsystem.useTimeRange)();
62
+ const panelEditorContext = (0, _react.useContext)(_dashboards.PanelEditorContext);
63
+ const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(panelEditorContext?.preview.previewPanelWidth);
64
+ const minStepMs = (0, _react.useMemo)(()=>{
65
+ /* Try catch is necessary, because when the minStep value is being typed, it will be valid when the duration unit is added. Example: 2m = 2 + m */ try {
66
+ const durationsSeconds = (0, _model.getDurationStringSeconds)((0, _pluginsystem.replaceVariables)(minStepPlaceholder, variableState));
67
+ return durationsSeconds !== undefined ? durationsSeconds * 1000 : undefined;
68
+ } catch {
69
+ return undefined;
70
+ }
71
+ }, [
72
+ variableState,
73
+ minStepPlaceholder
74
+ ]);
75
+ const intervalMs = (0, _react.useMemo)(()=>{
76
+ const minStepSeconds = (minStepMs ?? 0) / 1000;
77
+ return (0, _model.getRangeStep)((0, _model.getPrometheusTimeRange)(absoluteTimeRange), minStepSeconds, undefined, suggestedStepMs) * 1000;
78
+ }, [
79
+ absoluteTimeRange,
80
+ minStepMs,
81
+ suggestedStepMs
82
+ ]);
83
+ const treeViewMetadata = (0, _react.useMemo)(()=>{
84
+ return minStepMs && intervalMs ? {
85
+ minStepMs,
86
+ intervalMs
87
+ } : undefined;
88
+ }, [
89
+ minStepMs,
90
+ intervalMs
91
+ ]);
58
92
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
59
93
  spacing: 2,
60
94
  children: [
@@ -81,7 +115,8 @@ function PrometheusTimeSeriesQueryEditor(props) {
81
115
  datasource: selectedDatasource,
82
116
  onChange: handleQueryChange,
83
117
  onBlur: handleQueryBlur,
84
- isReadOnly: isReadonly
118
+ isReadOnly: isReadonly,
119
+ treeViewMetadata: treeViewMetadata
85
120
  }),
86
121
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
87
122
  direction: "row",
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useFormatState: function() {
24
+ get useFormatState () {
25
25
  return useFormatState;
26
26
  },
27
- useMinStepState: function() {
27
+ get useMinStepState () {
28
28
  return useMinStepState;
29
29
  },
30
- useQueryState: function() {
30
+ get useQueryState () {
31
31
  return useQueryState;
32
32
  }
33
33
  });