@perses-dev/prometheus-plugin 0.53.0 → 0.53.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 (34) hide show
  1. package/__mf/js/{Prometheus.712b445d.js → Prometheus.7d2f1afa.js} +3 -3
  2. package/__mf/js/async/{8706.9a6f6579.js → 8706.a36614fb.js} +1 -1
  3. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js +1 -0
  4. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js +1 -0
  5. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js +1 -0
  6. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js +1 -0
  7. package/__mf/js/{main.61a2057a.js → main.b9fe0e65.js} +2 -2
  8. package/lib/cjs/components/PromQLEditor.js +3 -1
  9. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
  10. package/lib/cjs/plugins/prometheus-variables.js +108 -46
  11. package/lib/components/PromQLEditor.d.ts +2 -1
  12. package/lib/components/PromQLEditor.d.ts.map +1 -1
  13. package/lib/components/PromQLEditor.js +3 -1
  14. package/lib/components/PromQLEditor.js.map +1 -1
  15. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  16. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
  17. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  18. package/lib/plugins/prometheus-variables.d.ts.map +1 -1
  19. package/lib/plugins/prometheus-variables.js +115 -47
  20. package/lib/plugins/prometheus-variables.js.map +1 -1
  21. package/lib/plugins/test/setup-tests.d.ts.map +1 -0
  22. package/lib/plugins/test/setup-tests.js.map +1 -0
  23. package/mf-manifest.json +24 -24
  24. package/mf-stats.json +29 -29
  25. package/package.json +3 -3
  26. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js +0 -1
  27. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js +0 -1
  28. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js +0 -1
  29. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js +0 -1
  30. package/lib/test/setup-tests.d.ts.map +0 -1
  31. package/lib/test/setup-tests.js.map +0 -1
  32. /package/lib/cjs/{test → plugins/test}/setup-tests.js +0 -0
  33. /package/lib/{test → plugins/test}/setup-tests.d.ts +0 -0
  34. /package/lib/{test → plugins/test}/setup-tests.js +0 -0
@@ -14,23 +14,59 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { FormControl, Stack, TextField } from '@mui/material';
15
15
  import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
16
16
  import { produce } from 'immer';
17
+ import { useCallback, useState } from 'react';
17
18
  import { PromQLEditor } from '../components';
18
19
  import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model';
19
20
  import { MatcherEditor } from './MatcherEditor';
20
- export function PrometheusLabelValuesVariableEditor(props) {
21
- const { onChange, value } = props;
22
- const { datasource } = value;
21
+ /* TODO:
22
+ Open Question for later improvement
23
+ The usage of direct onchange here causes an immediate spec update which eventually updates the panel
24
+ This was probably intentional to allow for quick switching between values.
25
+ Shouldn't we update the panel only through the Run Query Button?
26
+ I think we should only track the changes and let the button to Run the query
27
+ */ export function PrometheusLabelValuesVariableEditor(props) {
28
+ const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
23
29
  const selectedDatasource = datasource ?? DEFAULT_PROM;
24
- const handleDatasourceChange = (next)=>{
30
+ const [labelValue, setLabelValue] = useState(props.value.labelName);
31
+ const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
32
+ const handleDatasourceChange = useCallback((next)=>{
25
33
  if (isPrometheusDatasourceSelector(next)) {
26
34
  onChange(produce(value, (draft)=>{
27
35
  // If they're using the default, just omit the datasource prop (i.e. set to undefined)
28
36
  draft.datasource = isDefaultPromSelector(next) ? undefined : next;
29
37
  }));
38
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
39
+ ...value,
40
+ datasource: next
41
+ });
30
42
  return;
31
43
  }
32
44
  throw new Error('Got unexpected non-Prometheus datasource selector');
33
- };
45
+ }, [
46
+ onChange,
47
+ queryHandlerSettings,
48
+ value
49
+ ]);
50
+ const handleLabelChange = useCallback((e)=>{
51
+ setLabelValue(e.target.value);
52
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
53
+ ...value,
54
+ labelName: e.target.value
55
+ });
56
+ }, [
57
+ value,
58
+ queryHandlerSettings
59
+ ]);
60
+ const handleMatchEditorsChange = useCallback((e)=>{
61
+ setMatchersValues(e);
62
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
63
+ ...value,
64
+ matchers: e
65
+ });
66
+ }, [
67
+ value,
68
+ queryHandlerSettings
69
+ ]);
34
70
  return /*#__PURE__*/ _jsxs(Stack, {
35
71
  spacing: 2,
36
72
  children: [
@@ -48,44 +84,54 @@ export function PrometheusLabelValuesVariableEditor(props) {
48
84
  /*#__PURE__*/ _jsx(TextField, {
49
85
  label: "Label Name",
50
86
  required: true,
51
- value: props.value.labelName,
52
- onChange: (e)=>{
53
- props.onChange({
54
- ...props.value,
55
- labelName: e.target.value
56
- });
57
- },
87
+ value: labelValue,
88
+ onChange: handleLabelChange,
58
89
  InputProps: {
59
90
  readOnly: props.isReadonly
60
91
  }
61
92
  }),
62
93
  /*#__PURE__*/ _jsx(MatcherEditor, {
63
- matchers: props.value.matchers ?? [],
64
- onChange: (e)=>{
65
- props.onChange({
66
- ...props.value,
67
- matchers: e
68
- });
69
- },
94
+ matchers: matchersValues,
95
+ onChange: handleMatchEditorsChange,
70
96
  isReadonly: props.isReadonly
71
97
  })
72
98
  ]
73
99
  });
74
100
  }
75
101
  export function PrometheusLabelNamesVariableEditor(props) {
76
- const { onChange, value } = props;
77
- const { datasource } = value;
102
+ const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
78
103
  const selectedDatasource = datasource ?? DEFAULT_PROM;
79
- const handleDatasourceChange = (next)=>{
104
+ const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
105
+ const handleDatasourceChange = useCallback((next)=>{
80
106
  if (isPrometheusDatasourceSelector(next)) {
81
107
  onChange(produce(value, (draft)=>{
82
108
  // If they're using the default, just omit the datasource prop (i.e. set to undefined)
83
109
  draft.datasource = isDefaultPromSelector(next) ? undefined : next;
84
110
  }));
111
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
112
+ ...value,
113
+ datasource: next
114
+ });
85
115
  return;
86
116
  }
87
117
  throw new Error('Got unexpected non-Prometheus datasource selector');
88
- };
118
+ }, [
119
+ onChange,
120
+ queryHandlerSettings,
121
+ value
122
+ ]);
123
+ const handleMatchEditorChange = useCallback((e)=>{
124
+ setMatchersValues(e);
125
+ if (queryHandlerSettings?.setWatchOtherSpecs) {
126
+ queryHandlerSettings.setWatchOtherSpecs({
127
+ ...value,
128
+ matchers: e
129
+ });
130
+ }
131
+ }, [
132
+ value,
133
+ queryHandlerSettings
134
+ ]);
89
135
  return /*#__PURE__*/ _jsxs(Stack, {
90
136
  spacing: 2,
91
137
  children: [
@@ -101,34 +147,65 @@ export function PrometheusLabelNamesVariableEditor(props) {
101
147
  })
102
148
  }),
103
149
  /*#__PURE__*/ _jsx(MatcherEditor, {
104
- matchers: props.value.matchers ?? [],
150
+ matchers: matchersValues,
105
151
  isReadonly: props.isReadonly,
106
- onChange: (e)=>{
107
- props.onChange({
108
- ...props.value,
109
- matchers: e
110
- });
111
- }
152
+ onChange: handleMatchEditorChange
112
153
  })
113
154
  ]
114
155
  });
115
156
  }
116
157
  export function PrometheusPromQLVariableEditor(props) {
117
- const { onChange, value } = props;
118
- const { datasource } = value;
158
+ const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
119
159
  const selectedDatasource = datasource ?? DEFAULT_PROM;
120
160
  const { data: client } = useDatasourceClient(selectedDatasource);
121
161
  const promURL = client?.options.datasourceUrl;
122
- const handleDatasourceChange = (next)=>{
162
+ const [labelValue, setLableValue] = useState(props.value.labelName);
163
+ const handleDatasourceChange = useCallback((next)=>{
123
164
  if (isPrometheusDatasourceSelector(next)) {
124
165
  onChange(produce(value, (draft)=>{
125
166
  // If they're using the default, just omit the datasource prop (i.e. set to undefined)
126
167
  draft.datasource = isDefaultPromSelector(next) ? undefined : next;
127
168
  }));
169
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
170
+ ...value,
171
+ datasource: next
172
+ });
128
173
  return;
129
174
  }
130
175
  throw new Error('Got unexpected non-Prometheus datasource selector');
131
- };
176
+ }, [
177
+ value,
178
+ onChange,
179
+ queryHandlerSettings
180
+ ]);
181
+ const handleOnBlurPromQlChange = useCallback((e)=>{
182
+ onChange({
183
+ ...value,
184
+ expr: e.target.textContent ?? ''
185
+ });
186
+ }, [
187
+ onChange,
188
+ value
189
+ ]);
190
+ const trackPromQlChanges = useCallback((e)=>{
191
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
192
+ ...value,
193
+ expr: e.target.textContent ?? ''
194
+ });
195
+ }, [
196
+ queryHandlerSettings,
197
+ value
198
+ ]);
199
+ const handleLabelNameChange = useCallback((e)=>{
200
+ setLableValue(e.target.value);
201
+ if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
202
+ ...value,
203
+ labelName: e.target.value
204
+ });
205
+ }, [
206
+ queryHandlerSettings,
207
+ value
208
+ ]);
132
209
  return /*#__PURE__*/ _jsxs(Stack, {
133
210
  spacing: 2,
134
211
  children: [
@@ -151,27 +228,18 @@ export function PrometheusPromQLVariableEditor(props) {
151
228
  },
152
229
  value: value.expr,
153
230
  datasource: selectedDatasource,
154
- onBlur: (event)=>{
155
- props.onChange({
156
- ...props.value,
157
- expr: event.target.textContent ?? ''
158
- });
159
- },
231
+ onBlur: queryHandlerSettings?.runWithOnBlur ? handleOnBlurPromQlChange : trackPromQlChanges,
160
232
  readOnly: props.isReadonly,
161
233
  width: "100%"
162
234
  }),
163
235
  /*#__PURE__*/ _jsx(TextField, {
164
236
  label: "Label Name",
165
- value: props.value.labelName,
237
+ required: true,
238
+ value: labelValue,
166
239
  InputProps: {
167
240
  readOnly: props.isReadonly
168
241
  },
169
- onChange: (e)=>{
170
- props.onChange({
171
- ...props.value,
172
- labelName: e.target.value
173
- });
174
- }
242
+ onChange: handleLabelNameChange
175
243
  })
176
244
  ]
177
245
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-variables.tsx"],"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.\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n OptionsEditorProps,\n useDatasourceClient,\n VariableOption,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { ReactElement } from 'react';\nimport { PromQLEditor } from '../components';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n VectorData,\n} from '../model';\nimport { MatcherEditor } from './MatcherEditor';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\n\nexport function PrometheusLabelValuesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>\n): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\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\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n readOnly={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <TextField\n label=\"Label Name\"\n required\n value={props.value.labelName}\n onChange={(e) => {\n props.onChange({ ...props.value, labelName: e.target.value });\n }}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n />\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n isReadonly={props.isReadonly}\n />\n </Stack>\n );\n}\n\nexport function PrometheusLabelNamesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>\n): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\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\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n disabled={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n isReadonly={props.isReadonly}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nexport function PrometheusPromQLVariableEditor(\n props: OptionsEditorProps<PrometheusPromQLVariableOptions>\n): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\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\">\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n disabled={props.isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.expr}\n datasource={selectedDatasource}\n onBlur={(event) => {\n props.onChange({ ...props.value, expr: event.target.textContent ?? '' });\n }}\n readOnly={props.isReadonly}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n value={props.value.labelName}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n onChange={(e) => {\n props.onChange({ ...props.value, labelName: e.target.value });\n }}\n />\n </Stack>\n );\n}\n\nexport function capturingMatrix(matrix: MatrixData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nexport function capturingVector(vector: VectorData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nexport const stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n"],"names":["FormControl","Stack","TextField","DatasourceSelect","useDatasourceClient","produce","PromQLEditor","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","selectedDatasource","handleDatasourceChange","next","draft","undefined","Error","spacing","margin","datasourcePluginKind","readOnly","isReadonly","labelId","label","required","labelName","e","target","InputProps","matchers","PrometheusLabelNamesVariableEditor","disabled","PrometheusPromQLVariableEditor","data","client","promURL","options","datasourceUrl","completeConfig","remote","url","expr","onBlur","event","textContent","width","capturingMatrix","matrix","captured","Set","sample","result","metric","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map"],"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;;AACjC,SAASA,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC9D,SACEC,gBAAgB,EAGhBC,mBAAmB,QAEd,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAE9BC,oBAAo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AAEA;;CAEC,GACD,OAAO,MAAMG,+BAA+B,CAACH;IAC3C,IAAI,CAACA,QAAQ,OAAO,EAAE;IACtB,OAAOA,OAAOI,GAAG,CAAC,CAACnD,QAAW,CAAA;YAC5BA;YACAc,OAAOd;QACT,CAAA;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-variables.tsx"],"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.\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n OptionsEditorProps,\n useDatasourceClient,\n VariableOption,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { ReactElement, useCallback, useState } from 'react';\nimport { PromQLEditor } from '../components';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n VectorData,\n} from '../model';\nimport { MatcherEditor } from './MatcherEditor';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\n\n/* TODO: \nOpen Question for later improvement\nThe usage of direct onchange here causes an immediate spec update which eventually updates the panel\nThis was probably intentional to allow for quick switching between values.\nShouldn't we update the panel only through the Run Query Button? \nI think we should only track the changes and let the button to Run the query\n*/\n\nexport function PrometheusLabelValuesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [labelValue, setLabelValue] = useState(props.value.labelName);\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, queryHandlerSettings, value]\n );\n\n const handleLabelChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLabelValue(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, labelName: e.target.value });\n },\n [value, queryHandlerSettings]\n );\n\n const handleMatchEditorsChange = useCallback(\n (e: string[]) => {\n setMatchersValues(e);\n if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({ ...value, matchers: e });\n },\n [value, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n readOnly={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n onChange={handleLabelChange}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n />\n <MatcherEditor matchers={matchersValues} onChange={handleMatchEditorsChange} isReadonly={props.isReadonly} />\n </Stack>\n );\n}\n\nexport function PrometheusLabelNamesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, queryHandlerSettings, value]\n );\n\n const handleMatchEditorChange = useCallback(\n (e: string[]) => {\n setMatchersValues(e);\n if (queryHandlerSettings?.setWatchOtherSpecs) {\n queryHandlerSettings.setWatchOtherSpecs({ ...value, matchers: e });\n }\n },\n [value, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n disabled={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <MatcherEditor matchers={matchersValues} isReadonly={props.isReadonly} onChange={handleMatchEditorChange} />\n </Stack>\n );\n}\n\nexport function PrometheusPromQLVariableEditor(\n props: OptionsEditorProps<PrometheusPromQLVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const [labelValue, setLableValue] = useState(props.value.labelName);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (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 draft.datasource = isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [value, onChange, queryHandlerSettings]\n );\n\n const handleOnBlurPromQlChange = useCallback(\n (e: React.FocusEvent<HTMLDivElement, Element>) => {\n onChange({ ...value, expr: e.target.textContent ?? '' });\n },\n [onChange, value]\n );\n\n const trackPromQlChanges = useCallback(\n (e: React.FocusEvent<HTMLDivElement, Element>) => {\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, expr: e.target.textContent ?? '' });\n },\n [queryHandlerSettings, value]\n );\n\n const handleLabelNameChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLableValue(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, labelName: e.target.value });\n },\n [queryHandlerSettings, value]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n disabled={props.isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.expr}\n datasource={selectedDatasource}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleOnBlurPromQlChange : trackPromQlChanges}\n readOnly={props.isReadonly}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n onChange={handleLabelNameChange}\n />\n </Stack>\n );\n}\n\nexport function capturingMatrix(matrix: MatrixData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nexport function capturingVector(vector: VectorData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nexport const stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n"],"names":["FormControl","Stack","TextField","DatasourceSelect","useDatasourceClient","produce","useCallback","useState","PromQLEditor","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","queryHandlerSettings","selectedDatasource","labelValue","setLabelValue","labelName","matchersValues","setMatchersValues","matchers","handleDatasourceChange","next","draft","undefined","setWatchOtherSpecs","Error","handleLabelChange","e","target","handleMatchEditorsChange","spacing","margin","datasourcePluginKind","readOnly","isReadonly","labelId","label","required","InputProps","PrometheusLabelNamesVariableEditor","handleMatchEditorChange","disabled","PrometheusPromQLVariableEditor","data","client","promURL","options","datasourceUrl","setLableValue","handleOnBlurPromQlChange","expr","textContent","trackPromQlChanges","handleLabelNameChange","completeConfig","remote","url","onBlur","runWithOnBlur","width","capturingMatrix","matrix","captured","Set","sample","result","metric","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map"],"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;;AACjC,SAASA,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC9D,SACEC,gBAAgB,EAGhBC,mBAAmB,QAEd,4BAA4B;AACnC,SAASC,OAAO,Q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MC,IAAI,CAACP,SAASQ,MAAM;AACnC;AAEA,OAAO,SAASC,gBAAgBC,MAAkB,EAAExD,SAAiB;IACnE,MAAM8C,WAAW,IAAIC;IACrB,KAAK,MAAMC,UAAUQ,OAAOP,MAAM,CAAE;QAClC,MAAMvD,QAAQsD,OAAOE,MAAM,CAAClD,UAAU;QACtC,IAAIN,UAAUa,WAAW;YACvBuC,SAASK,GAAG,CAACzD;QACf;IACF;IACA,OAAO0D,MAAMC,IAAI,CAACP,SAASQ,MAAM;AACnC;AAEA;;CAEC,GACD,OAAO,MAAMG,+BAA+B,CAACH;IAC3C,IAAI,CAACA,QAAQ,OAAO,EAAE;IACtB,OAAOA,OAAOI,GAAG,CAAC,CAAChE,QAAW,CAAA;YAC5BA;YACA0B,OAAO1B;QACT,CAAA;AACF,EAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../../../src/plugins/test/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,yCAAyC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/plugins/test/setup-tests.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 '@testing-library/jest-dom/extend-expect';\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,OAAO,0CAA0C"}
package/mf-manifest.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "Prometheus",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.53.0",
8
+ "buildVersion": "0.53.2",
9
9
  "buildName": "@perses-dev/prometheus-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/Prometheus.712b445d.js",
12
+ "name": "__mf/js/Prometheus.7d2f1afa.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -356,12 +356,12 @@
356
356
  "__mf/js/async/2675.27451820.js",
357
357
  "__mf/js/async/5724.794828e3.js",
358
358
  "__mf/js/async/537.82230699.js",
359
- "__mf/js/async/8706.9a6f6579.js",
360
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js",
359
+ "__mf/js/async/8706.a36614fb.js",
360
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js",
361
361
  "__mf/js/async/7272.6fa2f127.js",
362
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
363
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
364
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
362
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
363
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
364
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
365
365
  "__mf/js/async/5257.ce463cb7.js",
366
366
  "__mf/js/async/7376.2e948f2b.js",
367
367
  "__mf/js/async/9550.642ce5ad.js",
@@ -400,8 +400,8 @@
400
400
  "__mf/js/async/2675.27451820.js",
401
401
  "__mf/js/async/5724.794828e3.js",
402
402
  "__mf/js/async/537.82230699.js",
403
- "__mf/js/async/8706.9a6f6579.js",
404
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js"
403
+ "__mf/js/async/8706.a36614fb.js",
404
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js"
405
405
  ],
406
406
  "async": [
407
407
  "__mf/js/async/4238.422a1b1c.js",
@@ -415,10 +415,10 @@
415
415
  "__mf/js/async/2675.27451820.js",
416
416
  "__mf/js/async/5724.794828e3.js",
417
417
  "__mf/js/async/537.82230699.js",
418
- "__mf/js/async/8706.9a6f6579.js",
419
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
420
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
421
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
418
+ "__mf/js/async/8706.a36614fb.js",
419
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
420
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
421
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
422
422
  "__mf/js/async/5257.ce463cb7.js",
423
423
  "__mf/js/async/7376.2e948f2b.js",
424
424
  "__mf/js/async/9550.642ce5ad.js",
@@ -460,8 +460,8 @@
460
460
  "__mf/js/async/7272.6fa2f127.js",
461
461
  "__mf/js/async/5724.794828e3.js",
462
462
  "__mf/js/async/537.82230699.js",
463
- "__mf/js/async/8706.9a6f6579.js",
464
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js"
463
+ "__mf/js/async/8706.a36614fb.js",
464
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js"
465
465
  ],
466
466
  "async": [
467
467
  "__mf/js/async/4238.422a1b1c.js",
@@ -513,8 +513,8 @@
513
513
  "__mf/js/async/7272.6fa2f127.js",
514
514
  "__mf/js/async/5724.794828e3.js",
515
515
  "__mf/js/async/537.82230699.js",
516
- "__mf/js/async/8706.9a6f6579.js",
517
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js"
516
+ "__mf/js/async/8706.a36614fb.js",
517
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js"
518
518
  ],
519
519
  "async": [
520
520
  "__mf/js/async/4238.422a1b1c.js",
@@ -566,8 +566,8 @@
566
566
  "__mf/js/async/7272.6fa2f127.js",
567
567
  "__mf/js/async/5724.794828e3.js",
568
568
  "__mf/js/async/537.82230699.js",
569
- "__mf/js/async/8706.9a6f6579.js",
570
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js"
569
+ "__mf/js/async/8706.a36614fb.js",
570
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js"
571
571
  ],
572
572
  "async": [
573
573
  "__mf/js/async/4238.422a1b1c.js",
@@ -635,12 +635,12 @@
635
635
  "__mf/js/async/2675.27451820.js",
636
636
  "__mf/js/async/5724.794828e3.js",
637
637
  "__mf/js/async/537.82230699.js",
638
- "__mf/js/async/8706.9a6f6579.js",
639
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js",
638
+ "__mf/js/async/8706.a36614fb.js",
639
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js",
640
640
  "__mf/js/async/7272.6fa2f127.js",
641
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
642
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
643
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
641
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
642
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
643
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
644
644
  "__mf/js/async/9817.70eae424.js",
645
645
  "__mf/js/async/5876.1976752d.js",
646
646
  "__mf/js/async/212.69f85c2b.js",
package/mf-stats.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "Prometheus",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.53.0",
8
+ "buildVersion": "0.53.2",
9
9
  "buildName": "@perses-dev/prometheus-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/Prometheus.712b445d.js",
12
+ "name": "__mf/js/Prometheus.7d2f1afa.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -115,8 +115,8 @@
115
115
  }
116
116
  },
117
117
  "usedIn": [
118
- "./PrometheusTimeSeriesQuery",
119
- "./PrometheusExplorer"
118
+ "./PrometheusExplorer",
119
+ "./PrometheusTimeSeriesQuery"
120
120
  ]
121
121
  },
122
122
  {
@@ -188,12 +188,12 @@
188
188
  }
189
189
  },
190
190
  "usedIn": [
191
- "./PrometheusTimeSeriesQuery",
191
+ "./PrometheusLabelValuesVariable",
192
192
  "./PrometheusExplorer",
193
193
  "./PrometheusLabelNamesVariable",
194
- "./PrometheusLabelValuesVariable",
195
194
  "./PrometheusPromQLVariable",
196
- "./PrometheusDatasource"
195
+ "./PrometheusDatasource",
196
+ "./PrometheusTimeSeriesQuery"
197
197
  ]
198
198
  },
199
199
  {
@@ -434,12 +434,12 @@
434
434
  "__mf/js/async/2675.27451820.js",
435
435
  "__mf/js/async/5724.794828e3.js",
436
436
  "__mf/js/async/537.82230699.js",
437
- "__mf/js/async/8706.9a6f6579.js",
438
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js",
437
+ "__mf/js/async/8706.a36614fb.js",
438
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js",
439
439
  "__mf/js/async/7272.6fa2f127.js",
440
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
441
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
442
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
440
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
441
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
442
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
443
443
  "__mf/js/async/5257.ce463cb7.js",
444
444
  "__mf/js/async/7376.2e948f2b.js",
445
445
  "__mf/js/async/9550.642ce5ad.js",
@@ -485,8 +485,8 @@
485
485
  "__mf/js/async/2675.27451820.js",
486
486
  "__mf/js/async/5724.794828e3.js",
487
487
  "__mf/js/async/537.82230699.js",
488
- "__mf/js/async/8706.9a6f6579.js",
489
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js"
488
+ "__mf/js/async/8706.a36614fb.js",
489
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js"
490
490
  ],
491
491
  "async": [
492
492
  "__mf/js/async/4238.422a1b1c.js",
@@ -500,10 +500,10 @@
500
500
  "__mf/js/async/2675.27451820.js",
501
501
  "__mf/js/async/5724.794828e3.js",
502
502
  "__mf/js/async/537.82230699.js",
503
- "__mf/js/async/8706.9a6f6579.js",
504
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
505
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
506
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
503
+ "__mf/js/async/8706.a36614fb.js",
504
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
505
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
506
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
507
507
  "__mf/js/async/5257.ce463cb7.js",
508
508
  "__mf/js/async/7376.2e948f2b.js",
509
509
  "__mf/js/async/9550.642ce5ad.js",
@@ -549,8 +549,8 @@
549
549
  "__mf/js/async/7272.6fa2f127.js",
550
550
  "__mf/js/async/5724.794828e3.js",
551
551
  "__mf/js/async/537.82230699.js",
552
- "__mf/js/async/8706.9a6f6579.js",
553
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js"
552
+ "__mf/js/async/8706.a36614fb.js",
553
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js"
554
554
  ],
555
555
  "async": [
556
556
  "__mf/js/async/4238.422a1b1c.js",
@@ -606,8 +606,8 @@
606
606
  "__mf/js/async/7272.6fa2f127.js",
607
607
  "__mf/js/async/5724.794828e3.js",
608
608
  "__mf/js/async/537.82230699.js",
609
- "__mf/js/async/8706.9a6f6579.js",
610
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js"
609
+ "__mf/js/async/8706.a36614fb.js",
610
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js"
611
611
  ],
612
612
  "async": [
613
613
  "__mf/js/async/4238.422a1b1c.js",
@@ -663,8 +663,8 @@
663
663
  "__mf/js/async/7272.6fa2f127.js",
664
664
  "__mf/js/async/5724.794828e3.js",
665
665
  "__mf/js/async/537.82230699.js",
666
- "__mf/js/async/8706.9a6f6579.js",
667
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js"
666
+ "__mf/js/async/8706.a36614fb.js",
667
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js"
668
668
  ],
669
669
  "async": [
670
670
  "__mf/js/async/4238.422a1b1c.js",
@@ -742,12 +742,12 @@
742
742
  "__mf/js/async/2675.27451820.js",
743
743
  "__mf/js/async/5724.794828e3.js",
744
744
  "__mf/js/async/537.82230699.js",
745
- "__mf/js/async/8706.9a6f6579.js",
746
- "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js",
745
+ "__mf/js/async/8706.a36614fb.js",
746
+ "__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js",
747
747
  "__mf/js/async/7272.6fa2f127.js",
748
- "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js",
749
- "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js",
750
- "__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js",
748
+ "__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js",
749
+ "__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js",
750
+ "__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js",
751
751
  "__mf/js/async/9817.70eae424.js",
752
752
  "__mf/js/async/5876.1976752d.js",
753
753
  "__mf/js/async/212.69f85c2b.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/prometheus-plugin",
3
- "version": "0.53.0",
3
+ "version": "0.53.2",
4
4
  "homepage": "https://github.com/perses/plugins/blob/main/README.md",
5
5
  "repository": {
6
6
  "type": "git",
@@ -85,7 +85,7 @@
85
85
  "kind": "Variable",
86
86
  "spec": {
87
87
  "display": {
88
- "name": "Prometheus Label Variable"
88
+ "name": "Prometheus Label Values Variable"
89
89
  },
90
90
  "name": "PrometheusLabelValuesVariable"
91
91
  }
@@ -94,7 +94,7 @@
94
94
  "kind": "Variable",
95
95
  "spec": {
96
96
  "display": {
97
- "name": "Prometheus Names Variable"
97
+ "name": "Prometheus Label Names Variable"
98
98
  },
99
99
  "name": "PrometheusLabelNamesVariable"
100
100
  }
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_Prometheus=self.chunk_Prometheus||[]).push([["8035"],{74081:function(e,a,r){var l;a.default=void 0,a.default=(0,((l=r(30265))&&l.__esModule?l:{default:l}).default)("M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z","TrashCan")},24867:function(e,a,r){r.r(a),r.d(a,{PrometheusLabelNamesVariable:()=>s});var l=r(8887),t=r(99176),n=r(62284);let s={getVariableOptions:async(e,a)=>{let r=await a.datasourceStore.getDatasourceClient(e.datasource??t.Mm),s=e.matchers?e.matchers.map(e=>(0,l.replaceVariables)(e,a.variables)):void 0,o=(0,t.Bf)(a.timeRange),{data:u}=await r.labelNames({"match[]":s,...o});return{data:(0,n.LY)(u)}},dependsOn:e=>{var a;return{variables:(null==(a=e.matchers)?void 0:a.map(e=>(0,l.parseVariables)(e)).flat())||[]}},OptionsEditorComponent:n.g3,createInitialOptions:()=>({})}},62284:function(e,a,r){r.d(a,{gB:()=>x,g3:()=>b,xA:()=>g,qT:()=>f,ik:()=>y,LY:()=>j});var l=r(24246),t=r(25283),n=r(90192),s=r(8695),o=r(8887),u=r(75586),d=r(64001),i=r(99176),c=r(36372),h=r(75094),m=r(48565),v=r(74081);function p(e){let{matchers:a,onChange:r,isReadonly:n}=e;return(0,l.jsxs)(t.Z,{spacing:1,mb:2,children:[a.map((e,t)=>(0,l.jsxs)(c.Z,{display:"flex",children:[(0,l.jsx)(s.Z,{fullWidth:!0,label:"Series Selector",value:e,InputProps:{readOnly:n},onChange:e=>{r((0,u.Uy)(a,a=>{a[t]=e.target.value}))}}),(0,l.jsx)(h.Z,{onClick:()=>{r((0,u.Uy)(a,e=>{e.splice(t,1)}))},disabled:n,children:(0,l.jsx)(v.default,{})})]},t)),(0,l.jsx)(c.Z,{children:(0,l.jsx)(m.Z,{fullWidth:!1,color:"secondary",variant:"outlined",onClick:()=>{r((0,u.Uy)(a,e=>{e.push("")}))},disabled:n,children:"Add Series Selector"})})]})}function g(e){let{onChange:a,value:r}=e,{datasource:d}=r,c=d??i.Mm;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:c,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},readOnly:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,l.jsx)(s.Z,{label:"Label Name",required:!0,value:e.value.labelName,onChange:a=>{e.onChange({...e.value,labelName:a.target.value})},InputProps:{readOnly:e.isReadonly}}),(0,l.jsx)(p,{matchers:e.value.matchers??[],onChange:a=>{e.onChange({...e.value,matchers:a})},isReadonly:e.isReadonly})]})}function b(e){let{onChange:a,value:r}=e,{datasource:s}=r,d=s??i.Mm;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:d,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},disabled:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,l.jsx)(p,{matchers:e.value.matchers??[],isReadonly:e.isReadonly,onChange:a=>{e.onChange({...e.value,matchers:a})}})]})}function f(e){let{onChange:a,value:r}=e,{datasource:c}=r,h=c??i.Mm,{data:m}=(0,o.useDatasourceClient)(h),v=null==m?void 0:m.options.datasourceUrl;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:i.nY,value:h,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},labelId:"prom-datasource-label",label:"Prometheus Datasource",disabled:e.isReadonly})}),(0,l.jsx)(d.P,{completeConfig:{remote:{url:v}},value:r.expr,datasource:h,onBlur:a=>{e.onChange({...e.value,expr:a.target.textContent??""})},readOnly:e.isReadonly,width:"100%"}),(0,l.jsx)(s.Z,{label:"Label Name",value:e.value.labelName,InputProps:{readOnly:e.isReadonly},onChange:a=>{e.onChange({...e.value,labelName:a.target.value})}})]})}function x(e,a){let r=new Set;for(let l of e.result){let e=l.metric[a];void 0!==e&&r.add(e)}return Array.from(r.values())}function y(e,a){let r=new Set;for(let l of e.result){let e=l.metric[a];void 0!==e&&r.add(e)}return Array.from(r.values())}let j=e=>e?e.map(e=>({value:e,label:e})):[]}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_Prometheus=self.chunk_Prometheus||[]).push([["6925"],{74081:function(e,a,l){var r;a.default=void 0,a.default=(0,((r=l(30265))&&r.__esModule?r:{default:r}).default)("M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z","TrashCan")},41233:function(e,a,l){l.r(a),l.d(a,{PrometheusLabelValuesVariable:()=>s});var r=l(8887),t=l(99176),n=l(62284);let s={getVariableOptions:async(e,a)=>{let l=await a.datasourceStore.getDatasourceClient(e.datasource??t.Mm),s=e.matchers?e.matchers.map(e=>(0,r.replaceVariables)(e,a.variables)):void 0,o=(0,t.Bf)(a.timeRange),{data:u}=await l.labelValues({labelName:(0,r.replaceVariables)(e.labelName,a.variables),"match[]":s,...o});return{data:(0,n.LY)(u)}},dependsOn:e=>{var a;return{variables:(null==(a=e.matchers)?void 0:a.map(e=>(0,r.parseVariables)(e)).flat().concat((0,r.parseVariables)(e.labelName)))||[]}},OptionsEditorComponent:n.xA,createInitialOptions:()=>({labelName:""})}},62284:function(e,a,l){l.d(a,{gB:()=>x,g3:()=>g,xA:()=>p,qT:()=>f,ik:()=>y,LY:()=>j});var r=l(24246),t=l(25283),n=l(90192),s=l(8695),o=l(8887),u=l(75586),d=l(64001),i=l(99176),c=l(36372),h=l(75094),m=l(48565),v=l(74081);function b(e){let{matchers:a,onChange:l,isReadonly:n}=e;return(0,r.jsxs)(t.Z,{spacing:1,mb:2,children:[a.map((e,t)=>(0,r.jsxs)(c.Z,{display:"flex",children:[(0,r.jsx)(s.Z,{fullWidth:!0,label:"Series Selector",value:e,InputProps:{readOnly:n},onChange:e=>{l((0,u.Uy)(a,a=>{a[t]=e.target.value}))}}),(0,r.jsx)(h.Z,{onClick:()=>{l((0,u.Uy)(a,e=>{e.splice(t,1)}))},disabled:n,children:(0,r.jsx)(v.default,{})})]},t)),(0,r.jsx)(c.Z,{children:(0,r.jsx)(m.Z,{fullWidth:!1,color:"secondary",variant:"outlined",onClick:()=>{l((0,u.Uy)(a,e=>{e.push("")}))},disabled:n,children:"Add Series Selector"})})]})}function p(e){let{onChange:a,value:l}=e,{datasource:d}=l,c=d??i.Mm;return(0,r.jsxs)(t.Z,{spacing:2,children:[(0,r.jsx)(n.Z,{margin:"dense",children:(0,r.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:c,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(l,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},readOnly:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,r.jsx)(s.Z,{label:"Label Name",required:!0,value:e.value.labelName,onChange:a=>{e.onChange({...e.value,labelName:a.target.value})},InputProps:{readOnly:e.isReadonly}}),(0,r.jsx)(b,{matchers:e.value.matchers??[],onChange:a=>{e.onChange({...e.value,matchers:a})},isReadonly:e.isReadonly})]})}function g(e){let{onChange:a,value:l}=e,{datasource:s}=l,d=s??i.Mm;return(0,r.jsxs)(t.Z,{spacing:2,children:[(0,r.jsx)(n.Z,{margin:"dense",children:(0,r.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:d,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(l,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},disabled:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,r.jsx)(b,{matchers:e.value.matchers??[],isReadonly:e.isReadonly,onChange:a=>{e.onChange({...e.value,matchers:a})}})]})}function f(e){let{onChange:a,value:l}=e,{datasource:c}=l,h=c??i.Mm,{data:m}=(0,o.useDatasourceClient)(h),v=null==m?void 0:m.options.datasourceUrl;return(0,r.jsxs)(t.Z,{spacing:2,children:[(0,r.jsx)(n.Z,{margin:"dense",children:(0,r.jsx)(o.DatasourceSelect,{datasourcePluginKind:i.nY,value:h,onChange:e=>{if((0,i.sv)(e))return void a((0,u.Uy)(l,a=>{a.datasource=(0,i.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},labelId:"prom-datasource-label",label:"Prometheus Datasource",disabled:e.isReadonly})}),(0,r.jsx)(d.P,{completeConfig:{remote:{url:v}},value:l.expr,datasource:h,onBlur:a=>{e.onChange({...e.value,expr:a.target.textContent??""})},readOnly:e.isReadonly,width:"100%"}),(0,r.jsx)(s.Z,{label:"Label Name",value:e.value.labelName,InputProps:{readOnly:e.isReadonly},onChange:a=>{e.onChange({...e.value,labelName:a.target.value})}})]})}function x(e,a){let l=new Set;for(let r of e.result){let e=r.metric[a];void 0!==e&&l.add(e)}return Array.from(l.values())}function y(e,a){let l=new Set;for(let r of e.result){let e=r.metric[a];void 0!==e&&l.add(e)}return Array.from(l.values())}let j=e=>e?e.map(e=>({value:e,label:e})):[]}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_Prometheus=self.chunk_Prometheus||[]).push([["3520"],{74081:function(e,a,r){var l;a.default=void 0,a.default=(0,((l=r(30265))&&l.__esModule?l:{default:l}).default)("M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z","TrashCan")},7909:function(e,a,r){r.r(a),r.d(a,{PrometheusPromQLVariable:()=>s});var l=r(8887),t=r(99176),n=r(62284);let s={getVariableOptions:async(e,a)=>{let r=await a.datasourceStore.getDatasourceClient(e.datasource??t.Mm),{data:s}=await r.instantQuery({query:(0,l.replaceVariables)(e.expr,a.variables)}),o=(0,l.replaceVariables)(e.labelName,a.variables),u=[];return(null==s?void 0:s.resultType)==="matrix"?u=(0,n.gB)(s,o):(null==s?void 0:s.resultType)==="vector"&&(u=(0,n.ik)(s,o)),{data:(0,n.LY)(u)}},dependsOn:e=>({variables:(0,l.parseVariables)(e.expr).concat((0,l.parseVariables)(e.labelName))}),OptionsEditorComponent:n.qT,createInitialOptions:()=>({expr:"",labelName:""})}},62284:function(e,a,r){r.d(a,{gB:()=>y,g3:()=>g,xA:()=>b,qT:()=>x,ik:()=>f,LY:()=>j});var l=r(24246),t=r(25283),n=r(90192),s=r(8695),o=r(8887),u=r(75586),i=r(64001),d=r(99176),c=r(36372),h=r(75094),m=r(48565),v=r(74081);function p(e){let{matchers:a,onChange:r,isReadonly:n}=e;return(0,l.jsxs)(t.Z,{spacing:1,mb:2,children:[a.map((e,t)=>(0,l.jsxs)(c.Z,{display:"flex",children:[(0,l.jsx)(s.Z,{fullWidth:!0,label:"Series Selector",value:e,InputProps:{readOnly:n},onChange:e=>{r((0,u.Uy)(a,a=>{a[t]=e.target.value}))}}),(0,l.jsx)(h.Z,{onClick:()=>{r((0,u.Uy)(a,e=>{e.splice(t,1)}))},disabled:n,children:(0,l.jsx)(v.default,{})})]},t)),(0,l.jsx)(c.Z,{children:(0,l.jsx)(m.Z,{fullWidth:!1,color:"secondary",variant:"outlined",onClick:()=>{r((0,u.Uy)(a,e=>{e.push("")}))},disabled:n,children:"Add Series Selector"})})]})}function b(e){let{onChange:a,value:r}=e,{datasource:i}=r,c=i??d.Mm;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:c,onChange:e=>{if((0,d.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,d.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},readOnly:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,l.jsx)(s.Z,{label:"Label Name",required:!0,value:e.value.labelName,onChange:a=>{e.onChange({...e.value,labelName:a.target.value})},InputProps:{readOnly:e.isReadonly}}),(0,l.jsx)(p,{matchers:e.value.matchers??[],onChange:a=>{e.onChange({...e.value,matchers:a})},isReadonly:e.isReadonly})]})}function g(e){let{onChange:a,value:r}=e,{datasource:s}=r,i=s??d.Mm;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:"PrometheusDatasource",value:i,onChange:e=>{if((0,d.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,d.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},disabled:e.isReadonly,labelId:"prom-datasource-label",label:"Prometheus Datasource"})}),(0,l.jsx)(p,{matchers:e.value.matchers??[],isReadonly:e.isReadonly,onChange:a=>{e.onChange({...e.value,matchers:a})}})]})}function x(e){let{onChange:a,value:r}=e,{datasource:c}=r,h=c??d.Mm,{data:m}=(0,o.useDatasourceClient)(h),v=null==m?void 0:m.options.datasourceUrl;return(0,l.jsxs)(t.Z,{spacing:2,children:[(0,l.jsx)(n.Z,{margin:"dense",children:(0,l.jsx)(o.DatasourceSelect,{datasourcePluginKind:d.nY,value:h,onChange:e=>{if((0,d.sv)(e))return void a((0,u.Uy)(r,a=>{a.datasource=(0,d.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},labelId:"prom-datasource-label",label:"Prometheus Datasource",disabled:e.isReadonly})}),(0,l.jsx)(i.P,{completeConfig:{remote:{url:v}},value:r.expr,datasource:h,onBlur:a=>{e.onChange({...e.value,expr:a.target.textContent??""})},readOnly:e.isReadonly,width:"100%"}),(0,l.jsx)(s.Z,{label:"Label Name",value:e.value.labelName,InputProps:{readOnly:e.isReadonly},onChange:a=>{e.onChange({...e.value,labelName:a.target.value})}})]})}function y(e,a){let r=new Set;for(let l of e.result){let e=l.metric[a];void 0!==e&&r.add(e)}return Array.from(r.values())}function f(e,a){let r=new Set;for(let l of e.result){let e=l.metric[a];void 0!==e&&r.add(e)}return Array.from(r.values())}let j=e=>e?e.map(e=>({value:e,label:e})):[]}}]);