@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab

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 (84) hide show
  1. package/dist/cjs/components/PromQL.js +9 -7
  2. package/dist/cjs/components/index.js +10 -8
  3. package/dist/cjs/index.js +33 -19
  4. package/dist/cjs/model/index.js +15 -13
  5. package/dist/cjs/model/parse-sample-values.js +6 -2
  6. package/dist/cjs/model/prometheus-client.js +40 -5
  7. package/dist/cjs/model/prometheus-selectors.js +12 -4
  8. package/dist/cjs/model/templating.js +7 -5
  9. package/dist/cjs/model/time.js +14 -8
  10. package/dist/cjs/plugins/MatcherEditor.js +13 -11
  11. package/dist/cjs/plugins/PrometheusDatasourceEditor.js +612 -0
  12. package/dist/cjs/plugins/prometheus-datasource.js +58 -6
  13. package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +88 -0
  14. package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +123 -0
  15. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
  16. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +48 -50
  17. package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +41 -21
  18. package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
  19. package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +42 -9
  20. package/dist/cjs/plugins/prometheus-variables.js +60 -54
  21. package/dist/cjs/plugins/types.js +7 -0
  22. package/dist/cjs/plugins/variable.js +9 -7
  23. package/dist/cjs/utils/index.js +10 -8
  24. package/dist/cjs/utils/utils.js +12 -6
  25. package/dist/components/PromQL.js.map +1 -1
  26. package/dist/components/index.js.map +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/model/index.js.map +1 -1
  29. package/dist/model/parse-sample-values.js.map +1 -1
  30. package/dist/model/prometheus-client.d.ts +4 -0
  31. package/dist/model/prometheus-client.d.ts.map +1 -1
  32. package/dist/model/prometheus-client.js +24 -0
  33. package/dist/model/prometheus-client.js.map +1 -1
  34. package/dist/model/prometheus-selectors.js.map +1 -1
  35. package/dist/model/templating.js.map +1 -1
  36. package/dist/model/time.js +1 -1
  37. package/dist/model/time.js.map +1 -1
  38. package/dist/plugins/MatcherEditor.js.map +1 -1
  39. package/dist/plugins/PrometheusDatasourceEditor.d.ts +9 -0
  40. package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
  41. package/dist/plugins/PrometheusDatasourceEditor.js +560 -0
  42. package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
  43. package/dist/plugins/prometheus-datasource.d.ts +1 -5
  44. package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
  45. package/dist/plugins/prometheus-datasource.js +56 -6
  46. package/dist/plugins/prometheus-datasource.js.map +1 -1
  47. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +21 -0
  48. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  49. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +80 -0
  50. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -0
  51. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +21 -0
  52. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  53. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +115 -0
  54. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +1 -0
  55. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  56. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
  57. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  58. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +43 -47
  59. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  60. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  61. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +34 -16
  62. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  63. package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
  64. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +10 -1
  65. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
  66. package/dist/plugins/prometheus-time-series-query/query-editor-model.js +36 -8
  67. package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  68. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -2
  69. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
  70. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
  71. package/dist/plugins/prometheus-variables.js +27 -27
  72. package/dist/plugins/prometheus-variables.js.map +1 -1
  73. package/dist/plugins/types.d.ts +9 -2
  74. package/dist/plugins/types.d.ts.map +1 -1
  75. package/dist/plugins/types.js +1 -1
  76. package/dist/plugins/types.js.map +1 -1
  77. package/dist/plugins/variable.js +2 -2
  78. package/dist/plugins/variable.js.map +1 -1
  79. package/dist/test/setup-tests.js.map +1 -1
  80. package/dist/utils/index.js.map +1 -1
  81. package/dist/utils/utils.d.ts +1 -1
  82. package/dist/utils/utils.js +3 -3
  83. package/dist/utils/utils.js.map +1 -1
  84. package/package.json +6 -6
@@ -21,8 +21,15 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useQueryState: ()=>useQueryState,
25
- useFormatState: ()=>useFormatState
24
+ useQueryState: function() {
25
+ return useQueryState;
26
+ },
27
+ useFormatState: function() {
28
+ return useFormatState;
29
+ },
30
+ useMinStepState: function() {
31
+ return useMinStepState;
32
+ }
26
33
  });
27
34
  const _react = require("react");
28
35
  const _immer = require("immer");
@@ -58,21 +65,21 @@ function useQueryState(props) {
58
65
  function useFormatState(props) {
59
66
  const { onChange , value } = props;
60
67
  // TODO: reusable hook or helper util instead of duplicating from useQueryState
61
- const [format, setFormat] = (0, _react.useState)(value.series_name_format);
62
- const [lastSyncedFormat, setLastSyncedFormat] = (0, _react.useState)(value.series_name_format);
63
- if (value.series_name_format !== lastSyncedFormat) {
64
- setFormat(value.series_name_format);
65
- setLastSyncedFormat(value.series_name_format);
68
+ const [format, setFormat] = (0, _react.useState)(value.seriesNameFormat);
69
+ const [lastSyncedFormat, setLastSyncedFormat] = (0, _react.useState)(value.seriesNameFormat);
70
+ if (value.seriesNameFormat !== lastSyncedFormat) {
71
+ setFormat(value.seriesNameFormat);
72
+ setLastSyncedFormat(value.seriesNameFormat);
66
73
  }
67
74
  // Update our local state as the user types
68
75
  const handleFormatChange = (e)=>{
69
76
  setFormat(e);
70
77
  };
71
- // Propagate changes to the panel preview component when series_name_format TextField is blurred
78
+ // Propagate changes to the panel preview component when seriesNameFormat TextField is blurred
72
79
  const handleFormatBlur = ()=>{
73
80
  setLastSyncedFormat(format);
74
81
  onChange((0, _immer.produce)(value, (draft)=>{
75
- draft.series_name_format = format;
82
+ draft.seriesNameFormat = format;
76
83
  }));
77
84
  };
78
85
  return {
@@ -81,3 +88,29 @@ function useFormatState(props) {
81
88
  handleFormatBlur
82
89
  };
83
90
  }
91
+ function useMinStepState(props) {
92
+ const { onChange , value } = props;
93
+ // TODO: reusable hook or helper util instead of duplicating from useQueryState
94
+ const [minStep, setMinStep] = (0, _react.useState)(value.minStep);
95
+ const [lastSyncedMinStep, setLastSyncedMinStep] = (0, _react.useState)(value.minStep);
96
+ if (value.minStep !== lastSyncedMinStep) {
97
+ setMinStep(value.minStep);
98
+ setLastSyncedMinStep(value.minStep);
99
+ }
100
+ // Update our local state as the user types
101
+ const handleMinStepChange = (e)=>{
102
+ setMinStep(e);
103
+ };
104
+ // Propagate changes to the panel preview component when minStep TextField is blurred
105
+ const handleMinStepBlur = ()=>{
106
+ setLastSyncedMinStep(minStep);
107
+ onChange((0, _immer.produce)(value, (draft)=>{
108
+ draft.minStep = minStep;
109
+ }));
110
+ };
111
+ return {
112
+ minStep,
113
+ handleMinStepChange,
114
+ handleMinStepBlur
115
+ };
116
+ }
@@ -21,17 +21,23 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PrometheusLabelNamesVariable: ()=>PrometheusLabelNamesVariable,
25
- PrometheusLabelValuesVariable: ()=>PrometheusLabelValuesVariable,
26
- PrometheusPromQLVariable: ()=>PrometheusPromQLVariable
24
+ PrometheusLabelNamesVariable: function() {
25
+ return PrometheusLabelNamesVariable;
26
+ },
27
+ PrometheusLabelValuesVariable: function() {
28
+ return PrometheusLabelValuesVariable;
29
+ },
30
+ PrometheusPromQLVariable: function() {
31
+ return PrometheusPromQLVariable;
32
+ }
27
33
  });
28
- const _jsxRuntime = require("react/jsx-runtime");
29
- const _pluginSystem = require("@perses-dev/plugin-system");
34
+ const _jsxruntime = require("react/jsx-runtime");
35
+ const _pluginsystem = require("@perses-dev/plugin-system");
30
36
  const _material = require("@mui/material");
31
37
  const _immer = require("immer");
32
38
  const _model = require("../model");
33
39
  const _components = require("../components");
34
- const _matcherEditor = require("./MatcherEditor");
40
+ const _MatcherEditor = require("./MatcherEditor");
35
41
  function PrometheusLabelValuesVariableEditor(props) {
36
42
  const { onChange , value } = props;
37
43
  const { datasource } = value;
@@ -46,18 +52,18 @@ function PrometheusLabelValuesVariableEditor(props) {
46
52
  }
47
53
  throw new Error('Got unexpected non-Prometheus datasource selector');
48
54
  };
49
- var _matchers;
50
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
55
+ var _props_value_matchers;
56
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
51
57
  spacing: 2,
52
58
  children: [
53
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
59
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
54
60
  margin: "dense",
55
61
  children: [
56
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
62
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
57
63
  id: "prom-datasource-label",
58
64
  children: "Prometheus Datasource"
59
65
  }),
60
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
66
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
61
67
  datasourcePluginKind: "PrometheusDatasource",
62
68
  value: selectedDatasource,
63
69
  onChange: handleDatasourceChange,
@@ -67,22 +73,22 @@ function PrometheusLabelValuesVariableEditor(props) {
67
73
  })
68
74
  ]
69
75
  }),
70
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
76
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
71
77
  label: "Label Name",
72
78
  required: true,
73
- value: props.value.label_name,
79
+ value: props.value.labelName,
74
80
  onChange: (e)=>{
75
81
  props.onChange({
76
82
  ...props.value,
77
- label_name: e.target.value
83
+ labelName: e.target.value
78
84
  });
79
85
  },
80
86
  InputProps: {
81
87
  readOnly: props.isReadonly
82
88
  }
83
89
  }),
84
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
85
- matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
90
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
91
+ matchers: (_props_value_matchers = props.value.matchers) !== null && _props_value_matchers !== void 0 ? _props_value_matchers : [],
86
92
  onChange: (e)=>{
87
93
  props.onChange({
88
94
  ...props.value,
@@ -108,18 +114,18 @@ function PrometheusLabelNamesVariableEditor(props) {
108
114
  }
109
115
  throw new Error('Got unexpected non-Prometheus datasource selector');
110
116
  };
111
- var _matchers;
112
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
117
+ var _props_value_matchers;
118
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
113
119
  spacing: 2,
114
120
  children: [
115
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
121
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
116
122
  margin: "dense",
117
123
  children: [
118
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
124
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
119
125
  id: "prom-datasource-label",
120
126
  children: "Prometheus Datasource"
121
127
  }),
122
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
128
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
123
129
  datasourcePluginKind: "PrometheusDatasource",
124
130
  value: selectedDatasource,
125
131
  onChange: handleDatasourceChange,
@@ -129,8 +135,8 @@ function PrometheusLabelNamesVariableEditor(props) {
129
135
  })
130
136
  ]
131
137
  }),
132
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
133
- matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
138
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
139
+ matchers: (_props_value_matchers = props.value.matchers) !== null && _props_value_matchers !== void 0 ? _props_value_matchers : [],
134
140
  isReadonly: props.isReadonly,
135
141
  onChange: (e)=>{
136
142
  props.onChange({
@@ -146,7 +152,7 @@ function PrometheusPromQLVariableEditor(props) {
146
152
  const { onChange , value } = props;
147
153
  const { datasource } = value;
148
154
  const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
149
- const { data: client } = (0, _pluginSystem.useDatasourceClient)(selectedDatasource);
155
+ const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
150
156
  const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
151
157
  const handleDatasourceChange = (next)=>{
152
158
  if ((0, _model.isPrometheusDatasourceSelector)(next)) {
@@ -158,17 +164,17 @@ function PrometheusPromQLVariableEditor(props) {
158
164
  }
159
165
  throw new Error('Got unexpected non-Prometheus datasource selector');
160
166
  };
161
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
167
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
162
168
  spacing: 2,
163
169
  children: [
164
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
170
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
165
171
  margin: "dense",
166
172
  children: [
167
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
173
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
168
174
  id: "prom-datasource-label",
169
175
  children: "Prometheus Datasource"
170
176
  }),
171
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
177
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
172
178
  datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
173
179
  value: selectedDatasource,
174
180
  onChange: handleDatasourceChange,
@@ -178,7 +184,7 @@ function PrometheusPromQLVariableEditor(props) {
178
184
  })
179
185
  ]
180
186
  }),
181
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.PromQLEditor, {
187
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PromQLEditor, {
182
188
  completeConfig: {
183
189
  remote: {
184
190
  url: promURL
@@ -194,36 +200,36 @@ function PrometheusPromQLVariableEditor(props) {
194
200
  readOnly: props.isReadonly,
195
201
  width: "100%"
196
202
  }),
197
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
203
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
198
204
  label: "Label Name",
199
- value: props.value.label_name,
205
+ value: props.value.labelName,
200
206
  InputProps: {
201
207
  readOnly: props.isReadonly
202
208
  },
203
209
  onChange: (e)=>{
204
210
  props.onChange({
205
211
  ...props.value,
206
- label_name: e.target.value
212
+ labelName: e.target.value
207
213
  });
208
214
  }
209
215
  })
210
216
  ]
211
217
  });
212
218
  }
213
- function capturingMatrix(matrix, label_name) {
219
+ function capturingMatrix(matrix, labelName) {
214
220
  const captured = new Set();
215
221
  for (const sample of matrix.result){
216
- const value = sample.metric[label_name];
222
+ const value = sample.metric[labelName];
217
223
  if (value !== undefined) {
218
224
  captured.add(value);
219
225
  }
220
226
  }
221
227
  return Array.from(captured.values());
222
228
  }
223
- function capturingVector(vector, label_name) {
229
+ function capturingVector(vector, labelName) {
224
230
  const captured = new Set();
225
231
  for (const sample of vector.result){
226
- const value = sample.metric[label_name];
232
+ const value = sample.metric[labelName];
227
233
  if (value !== undefined) {
228
234
  captured.add(value);
229
235
  }
@@ -241,9 +247,9 @@ function capturingVector(vector, label_name) {
241
247
  };
242
248
  const PrometheusLabelNamesVariable = {
243
249
  getVariableOptions: async (spec, ctx)=>{
244
- var _datasource;
245
- const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
246
- const match = spec.matchers ? spec.matchers.map((m)=>(0, _pluginSystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
250
+ var _spec_datasource;
251
+ const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
252
+ const match = spec.matchers ? spec.matchers.map((m)=>(0, _pluginsystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
247
253
  const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
248
254
  const { data: options } = await client.labelNames({
249
255
  'match[]': match,
@@ -254,9 +260,9 @@ const PrometheusLabelNamesVariable = {
254
260
  };
255
261
  },
256
262
  dependsOn: (spec)=>{
257
- var ref;
263
+ var _spec_matchers;
258
264
  return {
259
- variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>(0, _pluginSystem.parseTemplateVariables)(m)).flat()) || []
265
+ variables: ((_spec_matchers = spec.matchers) === null || _spec_matchers === void 0 ? void 0 : _spec_matchers.map((m)=>(0, _pluginsystem.parseTemplateVariables)(m)).flat()) || []
260
266
  };
261
267
  },
262
268
  OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
@@ -265,12 +271,12 @@ const PrometheusLabelNamesVariable = {
265
271
  const PrometheusLabelValuesVariable = {
266
272
  getVariableOptions: async (spec, ctx)=>{
267
273
  const pluginDef = spec;
268
- var _datasource;
269
- const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
270
- const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>(0, _pluginSystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
274
+ var _spec_datasource;
275
+ const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
276
+ const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>(0, _pluginsystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
271
277
  const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
272
278
  const { data: options } = await client.labelValues({
273
- labelName: (0, _pluginSystem.replaceTemplateVariables)(pluginDef.label_name, ctx.variables),
279
+ labelName: (0, _pluginsystem.replaceTemplateVariables)(pluginDef.labelName, ctx.variables),
274
280
  'match[]': match,
275
281
  ...timeRange
276
282
  });
@@ -279,25 +285,25 @@ const PrometheusLabelValuesVariable = {
279
285
  };
280
286
  },
281
287
  dependsOn: (spec)=>{
282
- var ref;
288
+ var _spec_matchers;
283
289
  return {
284
- variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>(0, _pluginSystem.parseTemplateVariables)(m)).flat().concat((0, _pluginSystem.parseTemplateVariables)(spec.label_name))) || []
290
+ variables: ((_spec_matchers = spec.matchers) === null || _spec_matchers === void 0 ? void 0 : _spec_matchers.map((m)=>(0, _pluginsystem.parseTemplateVariables)(m)).flat().concat((0, _pluginsystem.parseTemplateVariables)(spec.labelName))) || []
285
291
  };
286
292
  },
287
293
  OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
288
294
  createInitialOptions: ()=>({
289
- label_name: ''
295
+ labelName: ''
290
296
  })
291
297
  };
292
298
  const PrometheusPromQLVariable = {
293
299
  getVariableOptions: async (spec, ctx)=>{
294
- var _datasource;
295
- const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
300
+ var _spec_datasource;
301
+ const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
296
302
  // TODO we may want to manage a range query as well.
297
303
  const { data: options } = await client.instantQuery({
298
- query: (0, _pluginSystem.replaceTemplateVariables)(spec.expr, ctx.variables)
304
+ query: (0, _pluginsystem.replaceTemplateVariables)(spec.expr, ctx.variables)
299
305
  });
300
- const labelName = (0, _pluginSystem.replaceTemplateVariables)(spec.label_name, ctx.variables);
306
+ const labelName = (0, _pluginsystem.replaceTemplateVariables)(spec.labelName, ctx.variables);
301
307
  let values = [];
302
308
  if ((options === null || options === void 0 ? void 0 : options.resultType) === 'matrix') {
303
309
  values = capturingMatrix(options, labelName);
@@ -310,12 +316,12 @@ const PrometheusPromQLVariable = {
310
316
  },
311
317
  dependsOn: (spec)=>{
312
318
  return {
313
- variables: (0, _pluginSystem.parseTemplateVariables)(spec.expr).concat((0, _pluginSystem.parseTemplateVariables)(spec.label_name))
319
+ variables: (0, _pluginsystem.parseTemplateVariables)(spec.expr).concat((0, _pluginsystem.parseTemplateVariables)(spec.labelName))
314
320
  };
315
321
  },
316
322
  OptionsEditorComponent: PrometheusPromQLVariableEditor,
317
323
  createInitialOptions: ()=>({
318
324
  expr: '',
319
- label_name: ''
325
+ labelName: ''
320
326
  })
321
327
  };
@@ -14,3 +14,10 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "DEFAULT_SCRAPE_INTERVAL", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return DEFAULT_SCRAPE_INTERVAL;
21
+ }
22
+ });
23
+ const DEFAULT_SCRAPE_INTERVAL = '1m';
@@ -16,9 +16,11 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "StaticListVariable", {
18
18
  enumerable: true,
19
- get: ()=>StaticListVariable
19
+ get: function() {
20
+ return StaticListVariable;
21
+ }
20
22
  });
21
- const _jsxRuntime = require("react/jsx-runtime");
23
+ const _jsxruntime = require("react/jsx-runtime");
22
24
  const _material = require("@mui/material");
23
25
  function StaticListVariableOptionEditor(props) {
24
26
  const value = props.value.values.map((v)=>{
@@ -38,8 +40,8 @@ function StaticListVariableOptionEditor(props) {
38
40
  })
39
41
  });
40
42
  };
41
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
42
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
43
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
44
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
43
45
  onPaste: (e)=>{
44
46
  // Append new values on paste
45
47
  const v = e.clipboardData.getData('text/plain');
@@ -56,7 +58,7 @@ function StaticListVariableOptionEditor(props) {
56
58
  freeSolo: true,
57
59
  clearOnBlur: true,
58
60
  readOnly: props.isReadonly,
59
- renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
61
+ renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
60
62
  ...params,
61
63
  label: "Values",
62
64
  placeholder: "Values",
@@ -67,8 +69,8 @@ function StaticListVariableOptionEditor(props) {
67
69
  }
68
70
  const StaticListVariable = {
69
71
  getVariableOptions: async (spec)=>{
70
- var ref;
71
- const values = (ref = spec.values) === null || ref === void 0 ? void 0 : ref.map((v)=>{
72
+ var _spec_values;
73
+ const values = (_spec_values = spec.values) === null || _spec_values === void 0 ? void 0 : _spec_values.map((v)=>{
72
74
  if (typeof v === 'string') {
73
75
  return {
74
76
  label: v,
@@ -14,15 +14,17 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./utils"), exports);
18
- function _exportStar(from, to) {
17
+ _export_star(require("./utils"), exports);
18
+ function _export_star(from, to) {
19
19
  Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
- enumerable: true,
22
- get: function() {
23
- return from[k];
24
- }
25
- });
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
26
28
  });
27
29
  return from;
28
30
  }
@@ -21,16 +21,22 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- formatSeriesName: ()=>formatSeriesName,
25
- getUniqueKeyForPrometheusResult: ()=>getUniqueKeyForPrometheusResult,
26
- getFormattedPrometheusSeriesName: ()=>getFormattedPrometheusSeriesName
24
+ formatSeriesName: function() {
25
+ return formatSeriesName;
26
+ },
27
+ getUniqueKeyForPrometheusResult: function() {
28
+ return getUniqueKeyForPrometheusResult;
29
+ },
30
+ getFormattedPrometheusSeriesName: function() {
31
+ return getFormattedPrometheusSeriesName;
32
+ }
27
33
  });
28
34
  const _core = require("@perses-dev/core");
29
35
  function formatSeriesName(inputFormat, seriesLabels) {
30
36
  const resolveLabelsRegex = /\{\{\s*(.+?)\s*\}\}/g;
31
37
  return inputFormat.replace(resolveLabelsRegex, (_match, token)=>{
32
- var _token;
33
- const resolvedValue = (_token = seriesLabels[token]) !== null && _token !== void 0 ? _token : '';
38
+ var _seriesLabels_token;
39
+ const resolvedValue = (_seriesLabels_token = seriesLabels[token]) !== null && _seriesLabels_token !== void 0 ? _seriesLabels_token : '';
34
40
  return resolvedValue;
35
41
  });
36
42
  }
@@ -75,7 +81,7 @@ function getFormattedPrometheusSeriesName(query, metric, formatter) {
75
81
  if (name === '' || (0, _core.isEmptyObject)(metric)) {
76
82
  name = query;
77
83
  }
78
- // Query editor allows you to define an optional series_name_format property.
84
+ // Query editor allows you to define an optional seriesNameFormat property.
79
85
  // This controls the regex used to customize legend and tooltip display.
80
86
  const formattedName = formatter ? formatSeriesName(formatter, metric) : name;
81
87
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/PromQL.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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme } from '@mui/material';\nimport { useMemo } from 'react';\n\nexport type PromQLEditorProps = { completeConfig: CompleteConfiguration } & Omit<\n ReactCodeMirrorProps,\n 'theme' | 'extensions'\n>;\n\nexport function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[EditorView.lineWrapping, promQLExtension]}\n />\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","useMemo","PromQLEditor","completeConfig","rest","theme","isDarkMode","palette","mode","promQLExtension","activateLinter","setComplete","asExtension","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping"],"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;AAAA,OAAOA,UAAU,MAAgC,uBAAuB,CAAC;AACzE,SAASC,eAAe,QAA+B,kCAAkC,CAAC;AAC1F,SAASC,UAAU,QAAQ,kBAAkB,CAAC;AAC9C,SAASC,QAAQ,QAAQ,eAAe,CAAC;AACzC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAOhC,OAAO,SAASC,YAAY,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAGC,IAAI,EAAqB,EAAE;IAC3E,MAAMC,KAAK,GAAGL,QAAQ,EAAE,AAAC;IACzB,MAAMM,UAAU,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAI,KAAK,MAAM,AAAC;IAEjD,MAAMC,eAAe,GAAGR,OAAO,CAAC,IAAM;QACpC,OAAO,IAAIH,eAAe,EAAE,CAACY,cAAc,CAAC,KAAK,CAAC,CAACC,WAAW,CAACR,cAAc,CAAC,CAACS,WAAW,EAAE,CAAC;IAC/F,CAAC,EAAE;QAACT,cAAc;KAAC,CAAC,AAAC;IAErB,qBACE,KAACN,UAAU;QACR,GAAGO,IAAI;QACRS,KAAK,EAAE;YAAEC,MAAM,EAAE,CAAC,UAAU,EAAET,KAAK,CAACE,OAAO,CAACQ,OAAO,CAAC,CAAC;SAAE;QACvDV,KAAK,EAAEC,UAAU,GAAG,MAAM,GAAG,OAAO;QACpCU,UAAU,EAAE;YACVC,mBAAmB,EAAE,KAAK;YAC1BC,yBAAyB,EAAE,KAAK;YAChCC,UAAU,EAAE,KAAK;SAClB;QACDC,UAAU,EAAE;YAACrB,UAAU,CAACsB,YAAY;YAAEZ,eAAe;SAAC;MACtD,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/components/PromQL.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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme } from '@mui/material';\nimport { useMemo } from 'react';\n\nexport type PromQLEditorProps = { completeConfig: CompleteConfiguration } & Omit<\n ReactCodeMirrorProps,\n 'theme' | 'extensions'\n>;\n\nexport function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[EditorView.lineWrapping, promQLExtension]}\n />\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","useMemo","PromQLEditor","completeConfig","rest","theme","isDarkMode","palette","mode","promQLExtension","activateLinter","setComplete","asExtension","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping"],"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,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,OAAO,QAAQ,QAAQ;AAOhC,OAAO,SAASC,aAAa,EAAEC,eAAc,EAAE,GAAGC,MAAyB;IACzE,MAAMC,QAAQL;IACd,MAAMM,aAAaD,MAAME,QAAQC,SAAS;IAE1C,MAAMC,kBAAkBR,QAAQ;QAC9B,OAAO,IAAIH,kBAAkBY,eAAe,OAAOC,YAAYR,gBAAgBS;IACjF,GAAG;QAACT;KAAe;IAEnB,qBACE,KAACN;QACE,GAAGO,IAAI;QACRS,OAAO;YAAEC,QAAQ,CAAC,UAAU,EAAET,MAAME,QAAQQ,QAAQ,CAAC;QAAC;QACtDV,OAAOC,aAAa,SAAS;QAC7BU,YAAY;YACVC,qBAAqB;YACrBC,2BAA2B;YAC3BC,YAAY;QACd;QACAC,YAAY;YAACrB,WAAWsB;YAAcZ;SAAgB;;AAG5D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/index.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\nexport * from './PromQL';\n"],"names":[],"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,cAAc,UAAU,CAAC"}
1
+ {"version":3,"sources":["../../src/components/index.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\nexport * from './PromQL';\n"],"names":[],"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,cAAc,WAAW"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.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 { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';\n// @TODO: Move this to a more generic location;\nimport { StaticListVariable } from './plugins/variable';\nimport {\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n} from './plugins/prometheus-variables';\nimport { PrometheusDatasource } from './plugins/prometheus-datasource';\n\n// Export plugins under the same name as the kinds they handle from the plugin.json\nexport {\n PrometheusTimeSeriesQuery,\n StaticListVariable,\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n PrometheusDatasource,\n};\n\n// For consumers to leverage in DatasourceStoreProvider onCreate\nexport * from './model/prometheus-client';\nexport * from './model/api-types';\n\nexport * from './plugins/types';\n"],"names":["PrometheusTimeSeriesQuery","StaticListVariable","PrometheusLabelNamesVariable","PrometheusLabelValuesVariable","PrometheusPromQLVariable","PrometheusDatasource"],"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,yBAAyB,QAAQ,wCAAwC,CAAC;AACnF,+CAA+C;AAC/C,SAASC,kBAAkB,QAAQ,oBAAoB,CAAC;AACxD,SACEC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,QACnB,gCAAgC,CAAC;AACxC,SAASC,oBAAoB,QAAQ,iCAAiC,CAAC;AAEvE,mFAAmF;AACnF,SACEL,yBAAyB,EACzBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,oBAAoB,GACpB;AAEF,gEAAgE;AAChE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAElC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"sources":["../src/index.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 { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';\n// @TODO: Move this to a more generic location;\nimport { StaticListVariable } from './plugins/variable';\nimport {\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n} from './plugins/prometheus-variables';\nimport { PrometheusDatasource } from './plugins/prometheus-datasource';\n\n// Export plugins under the same name as the kinds they handle from the plugin.json\nexport {\n PrometheusTimeSeriesQuery,\n StaticListVariable,\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n PrometheusDatasource,\n};\n\n// For consumers to leverage in DatasourceStoreProvider onCreate\nexport * from './model/prometheus-client';\nexport * from './model/api-types';\n\nexport * from './plugins/types';\n"],"names":["PrometheusTimeSeriesQuery","StaticListVariable","PrometheusLabelNamesVariable","PrometheusLabelValuesVariable","PrometheusPromQLVariable","PrometheusDatasource"],"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,yBAAyB,QAAQ,yCAAyC;AACnF,+CAA+C;AAC/C,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SACEC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,QACnB,iCAAiC;AACxC,SAASC,oBAAoB,QAAQ,kCAAkC;AAEvE,mFAAmF;AACnF,SACEL,yBAAyB,EACzBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,oBAAoB,GACpB;AAEF,gEAAgE;AAChE,cAAc,4BAA4B;AAC1C,cAAc,oBAAoB;AAElC,cAAc,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.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\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './templating';\nexport * from './time';\n"],"names":[],"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,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"sources":["../../src/model/index.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\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './templating';\nexport * from './time';\n"],"names":[],"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,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,SAAS"}
@@ -1 +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,eAAe,CAACC,IAAgB,EAAoB;IAClE,MAAM,CAACC,eAAe,EAAEC,WAAW,CAAC,GAAGF,IAAI,AAAC;IAE5C,sDAAsD;IACtD,OAAO;QAACC,eAAe,GAAG,IAAI;QAAEE,gBAAgB,CAACD,WAAW,CAAC;KAAC,CAAC;AACjE,CAAC;AAED;;;CAGC,GACD,OAAO,SAASC,gBAAgB,CAACD,WAA0B,EAAU;IACnE,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE,KAAK,AAAQ,AAAC;IAClB,OAAQF,WAAW;QACjB,KAAK,MAAM;YACTE,KAAK,GAAGC,MAAM,CAACC,iBAAiB,CAAC;YACjC,MAAM;QACR,KAAK,MAAM;YACTF,KAAK,GAAGC,MAAM,CAACE,iBAAiB,CAAC;YACjC,MAAM;QACR;YACEH,KAAK,GAAGI,UAAU,CAACN,WAAW,CAAC,CAAC;KACnC;IACD,OAAOE,KAAK,CAAC;AACf,CAAC"}
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;YACf;QACF,KAAK;YACHF,QAAQC,OAAOE;YACf;QACF;YACEH,QAAQI,WAAWN;IACvB;IACA,OAAOE;AACT"}
@@ -16,6 +16,10 @@ export interface QueryOptions {
16
16
  datasourceUrl: string;
17
17
  headers?: RequestHeaders;
18
18
  }
19
+ /**
20
+ * Calls the `/-/healthy` endpoint to check if the datasource is healthy.
21
+ */
22
+ export declare function healthCheck(queryOptions: QueryOptions): () => Promise<boolean>;
19
23
  /**
20
24
  * Calls the `/api/v1/query` endpoint to get metrics data.
21
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,OAAO,EAAE,uBAAuB,CAAC;IACjC,YAAY,CAAC,MAAM,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC7G,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvG,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvG,WAAW,CAAC,MAAM,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3G;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,6BAA6B,EAAE,YAAY,EAAE,YAAY;;GAE7F;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,YAAY,EAAE,YAAY;;GAEzF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,YAAY,EAAE,YAAY;;GAEzF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,4BAA4B,EAAE,YAAY,EAAE,YAAY,gCAI3F;AA+DD;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC;;GAI7E"}
1
+ {"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAErB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,OAAO,EAAE,uBAAuB,CAAC;IACjC,YAAY,CAAC,MAAM,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC7G,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvG,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvG,WAAW,CAAC,MAAM,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3G;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,0BAWrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,6BAA6B,EAAE,YAAY,EAAE,YAAY;;GAE7F;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,YAAY,EAAE,YAAY;;GAEzF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,YAAY,EAAE,YAAY;;GAEzF;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,4BAA4B,EACpC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAa9B;AA+DD;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC;;GAI7E"}
@@ -11,6 +11,21 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { fetch, fetchJson } from '@perses-dev/core';
14
+ /**
15
+ * Calls the `/-/healthy` endpoint to check if the datasource is healthy.
16
+ */ export function healthCheck(queryOptions) {
17
+ return async ()=>{
18
+ const url = `${queryOptions.datasourceUrl}/-/healthy`;
19
+ try {
20
+ const resp = await fetch(url, {
21
+ headers: queryOptions.headers
22
+ });
23
+ return resp.status === 200;
24
+ } catch (e) {
25
+ return false;
26
+ }
27
+ };
28
+ }
14
29
  /**
15
30
  * Calls the `/api/v1/query` endpoint to get metrics data.
16
31
  */ export function instantQuery(params, queryOptions) {
@@ -30,6 +45,15 @@ import { fetch, fetchJson } from '@perses-dev/core';
30
45
  * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.
31
46
  */ export function labelValues(params, queryOptions) {
32
47
  const { labelName , ...searchParams } = params;
48
+ // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.
49
+ // Note that an empty list is the prometheus result if the label does not exist.
50
+ if (labelName.length === 0) {
51
+ return new Promise((resolve)=>{
52
+ resolve({
53
+ data: []
54
+ });
55
+ });
56
+ }
33
57
  const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;
34
58
  return fetchWithGet(apiURI, searchParams, queryOptions);
35
59
  }