@perses-dev/prometheus-plugin 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/prometheus-selectors.js +1 -0
- package/dist/cjs/plugins/MatcherEditor.js +1 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -17
- package/dist/cjs/plugins/prometheus-variables.js +117 -28
- package/dist/cjs/plugins/variable.js +24 -35
- package/dist/model/prometheus-selectors.d.ts +1 -2
- package/dist/model/prometheus-selectors.d.ts.map +1 -1
- package/dist/model/prometheus-selectors.js +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/plugins/MatcherEditor.js +1 -0
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +18 -18
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/prometheus-variables.d.ts.map +1 -1
- package/dist/plugins/prometheus-variables.js +120 -31
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/variable.d.ts.map +1 -1
- package/dist/plugins/variable.js +26 -37
- package/dist/plugins/variable.js.map +1 -1
- package/package.json +4 -4
|
@@ -21,6 +21,7 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
PROM_DATASOURCE_KIND: ()=>PROM_DATASOURCE_KIND,
|
|
24
25
|
DEFAULT_PROM: ()=>DEFAULT_PROM,
|
|
25
26
|
isDefaultPromSelector: ()=>isDefaultPromSelector,
|
|
26
27
|
isPrometheusDatasourceSelector: ()=>isPrometheusDatasourceSelector
|
|
@@ -30,6 +30,7 @@ function _interopRequireDefault(obj) {
|
|
|
30
30
|
function MatcherEditor({ matchers , onChange }) {
|
|
31
31
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
32
32
|
spacing: 1,
|
|
33
|
+
mb: 2,
|
|
33
34
|
children: [
|
|
34
35
|
matchers.map((matcher, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
35
36
|
display: "flex",
|
|
@@ -47,6 +47,23 @@ function PrometheusTimeSeriesQueryEditor(props) {
|
|
|
47
47
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
48
48
|
spacing: 2,
|
|
49
49
|
children: [
|
|
50
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
51
|
+
margin: "dense",
|
|
52
|
+
fullWidth: false,
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
55
|
+
id: "prom-datasource-label",
|
|
56
|
+
children: "Prometheus Datasource"
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
|
|
59
|
+
datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
|
|
60
|
+
value: selectedDatasource,
|
|
61
|
+
onChange: handleDatasourceChange,
|
|
62
|
+
labelId: "prom-datasource-label",
|
|
63
|
+
label: "Prometheus Datasource"
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
50
67
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.PromQLEditor, {
|
|
51
68
|
completeConfig: {
|
|
52
69
|
remote: {
|
|
@@ -65,23 +82,6 @@ function PrometheusTimeSeriesQueryEditor(props) {
|
|
|
65
82
|
value: format !== null && format !== void 0 ? format : '',
|
|
66
83
|
onChange: (e)=>handleFormatChange(e.target.value),
|
|
67
84
|
onBlur: handleFormatBlur
|
|
68
|
-
}),
|
|
69
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
70
|
-
margin: "dense",
|
|
71
|
-
fullWidth: false,
|
|
72
|
-
children: [
|
|
73
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
74
|
-
id: "prom-datasource-label",
|
|
75
|
-
children: "Prometheus Datasource"
|
|
76
|
-
}),
|
|
77
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
|
|
78
|
-
datasourcePluginKind: "PrometheusDatasource",
|
|
79
|
-
value: selectedDatasource,
|
|
80
|
-
onChange: handleDatasourceChange,
|
|
81
|
-
labelId: "prom-datasource-label",
|
|
82
|
-
label: "Prometheus Datasource"
|
|
83
|
-
})
|
|
84
|
-
]
|
|
85
85
|
})
|
|
86
86
|
]
|
|
87
87
|
});
|
|
@@ -26,19 +26,48 @@ _export(exports, {
|
|
|
26
26
|
PrometheusPromQLVariable: ()=>PrometheusPromQLVariable
|
|
27
27
|
});
|
|
28
28
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
29
30
|
const _material = require("@mui/material");
|
|
31
|
+
const _immer = require("immer");
|
|
30
32
|
const _model = require("../model");
|
|
31
33
|
const _utils = require("../utils");
|
|
34
|
+
const _components = require("../components");
|
|
32
35
|
const _matcherEditor = require("./MatcherEditor");
|
|
33
36
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
37
|
+
const { onChange , value } = props;
|
|
38
|
+
const { datasource } = value;
|
|
39
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
40
|
+
const handleDatasourceChange = (next)=>{
|
|
41
|
+
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
42
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
43
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
44
|
+
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
45
|
+
}));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
49
|
+
};
|
|
34
50
|
var _matchers;
|
|
35
51
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
36
|
-
spacing:
|
|
52
|
+
spacing: 2,
|
|
37
53
|
children: [
|
|
54
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
55
|
+
margin: "dense",
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
58
|
+
id: "prom-datasource-label",
|
|
59
|
+
children: "Prometheus Datasource"
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
|
|
62
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
63
|
+
value: selectedDatasource,
|
|
64
|
+
onChange: handleDatasourceChange,
|
|
65
|
+
labelId: "prom-datasource-label",
|
|
66
|
+
label: "Prometheus Datasource"
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
38
70
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
39
|
-
sx: {
|
|
40
|
-
mb: 1
|
|
41
|
-
},
|
|
42
71
|
label: "Label Name",
|
|
43
72
|
required: true,
|
|
44
73
|
value: props.value.label_name,
|
|
@@ -62,42 +91,102 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
62
91
|
});
|
|
63
92
|
}
|
|
64
93
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
94
|
+
const { onChange , value } = props;
|
|
95
|
+
const { datasource } = value;
|
|
96
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
97
|
+
const handleDatasourceChange = (next)=>{
|
|
98
|
+
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
99
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
100
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
101
|
+
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
102
|
+
}));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
106
|
+
};
|
|
65
107
|
var _matchers;
|
|
66
|
-
return /*#__PURE__*/ (0, _jsxRuntime.
|
|
67
|
-
spacing:
|
|
68
|
-
children:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
109
|
+
spacing: 2,
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
112
|
+
margin: "dense",
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
115
|
+
id: "prom-datasource-label",
|
|
116
|
+
children: "Prometheus Datasource"
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
|
|
119
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
120
|
+
value: selectedDatasource,
|
|
121
|
+
onChange: handleDatasourceChange,
|
|
122
|
+
labelId: "prom-datasource-label",
|
|
123
|
+
label: "Prometheus Datasource"
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
|
|
128
|
+
matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
|
|
129
|
+
onChange: (e)=>{
|
|
130
|
+
props.onChange({
|
|
131
|
+
...props.value,
|
|
132
|
+
matchers: e
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
]
|
|
77
137
|
});
|
|
78
138
|
}
|
|
79
139
|
function PrometheusPromQLVariableEditor(props) {
|
|
140
|
+
const { onChange , value } = props;
|
|
141
|
+
const { datasource } = value;
|
|
142
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
143
|
+
const { data: client } = (0, _pluginSystem.useDatasourceClient)(selectedDatasource);
|
|
144
|
+
const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
145
|
+
const handleDatasourceChange = (next)=>{
|
|
146
|
+
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
147
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
148
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
149
|
+
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
150
|
+
}));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
154
|
+
};
|
|
80
155
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
81
|
-
spacing:
|
|
156
|
+
spacing: 2,
|
|
82
157
|
children: [
|
|
83
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
158
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
159
|
+
margin: "dense",
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
162
|
+
id: "prom-datasource-label",
|
|
163
|
+
children: "Prometheus Datasource"
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceSelect, {
|
|
166
|
+
datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
|
|
167
|
+
value: selectedDatasource,
|
|
168
|
+
onChange: handleDatasourceChange,
|
|
169
|
+
labelId: "prom-datasource-label",
|
|
170
|
+
label: "Prometheus Datasource"
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.PromQLEditor, {
|
|
175
|
+
completeConfig: {
|
|
176
|
+
remote: {
|
|
177
|
+
url: promURL
|
|
178
|
+
}
|
|
87
179
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onChange: (e)=>{
|
|
180
|
+
value: value.expr,
|
|
181
|
+
onChange: (query)=>{
|
|
91
182
|
props.onChange({
|
|
92
183
|
...props.value,
|
|
93
|
-
expr:
|
|
184
|
+
expr: query
|
|
94
185
|
});
|
|
95
|
-
}
|
|
186
|
+
},
|
|
187
|
+
width: "100%"
|
|
96
188
|
}),
|
|
97
189
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
98
|
-
sx: {
|
|
99
|
-
mb: 1
|
|
100
|
-
},
|
|
101
190
|
label: "Label Name",
|
|
102
191
|
value: props.value.label_name,
|
|
103
192
|
onChange: (e)=>{
|
|
@@ -38,41 +38,30 @@ function StaticListVariableOptionEditor(props) {
|
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
-
return /*#__PURE__*/ (0, _jsxRuntime.
|
|
42
|
-
children:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
66
|
-
variant: "caption",
|
|
67
|
-
children: [
|
|
68
|
-
"Type new value then press ",
|
|
69
|
-
`"`,
|
|
70
|
-
"Enter",
|
|
71
|
-
`"`,
|
|
72
|
-
" to add."
|
|
73
|
-
]
|
|
74
|
-
})
|
|
75
|
-
]
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
42
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
43
|
+
onPaste: (e)=>{
|
|
44
|
+
// Append new values on paste
|
|
45
|
+
const v = e.clipboardData.getData('text/plain');
|
|
46
|
+
if (v) {
|
|
47
|
+
const values = v.split(',');
|
|
48
|
+
onChange(null, value.concat(values));
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
multiple: true,
|
|
53
|
+
value: value,
|
|
54
|
+
onChange: onChange,
|
|
55
|
+
options: [],
|
|
56
|
+
freeSolo: true,
|
|
57
|
+
clearOnBlur: true,
|
|
58
|
+
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
59
|
+
...params,
|
|
60
|
+
label: "Values",
|
|
61
|
+
placeholder: "Values",
|
|
62
|
+
helperText: 'Type new value then press "Enter" to add.'
|
|
63
|
+
})
|
|
64
|
+
})
|
|
76
65
|
});
|
|
77
66
|
}
|
|
78
67
|
const StaticListVariable = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatasourceSelector } from '@perses-dev/core';
|
|
2
|
-
declare const PROM_DATASOURCE_KIND: "PrometheusDatasource";
|
|
2
|
+
export declare const PROM_DATASOURCE_KIND: "PrometheusDatasource";
|
|
3
3
|
/**
|
|
4
4
|
* DatasourceSelector for Prom Datasources.
|
|
5
5
|
*/
|
|
@@ -18,5 +18,4 @@ export declare function isDefaultPromSelector(selector: PrometheusDatasourceSele
|
|
|
18
18
|
* Type guard to make sure a DatasourceSelector is a Prometheus one.
|
|
19
19
|
*/
|
|
20
20
|
export declare function isPrometheusDatasourceSelector(selector: DatasourceSelector): selector is PrometheusDatasourceSelector;
|
|
21
|
-
export {};
|
|
22
21
|
//# sourceMappingURL=prometheus-selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,wBAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,IAAI,EAAE,OAAO,oBAAoB,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,4BAA6D,CAAC;AAEzF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,4BAA4B,WAE3E;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,IAAI,4BAA4B,CAErH"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
const PROM_DATASOURCE_KIND = 'PrometheusDatasource';
|
|
13
|
+
export const PROM_DATASOURCE_KIND = 'PrometheusDatasource';
|
|
14
14
|
/**
|
|
15
15
|
* A default selector that asks for the default Prom Datasource.
|
|
16
16
|
*/ export const DEFAULT_PROM = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\n\
|
|
1
|
+
{"version":3,"sources":["../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided PrometheusDatasourceSelector is the default one.\n */\nexport function isDefaultPromSelector(selector: PrometheusDatasourceSelector) {\n return selector.name === undefined;\n}\n\n/**\n * Type guard to make sure a DatasourceSelector is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(selector: DatasourceSelector): selector is PrometheusDatasourceSelector {\n return selector.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","selector","name","undefined","isPrometheusDatasourceSelector"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,oBAAoB,GAAG,sBAAsB,AAAS,CAAC;AASpE;;CAEC,GACD,OAAO,MAAMC,YAAY,GAAiC;IAAEC,IAAI,EAAEF,oBAAoB;CAAE,CAAC;AAEzF;;CAEC,GACD,OAAO,SAASG,qBAAqB,CAACC,QAAsC,EAAE;IAC5E,OAAOA,QAAQ,CAACC,IAAI,KAAKC,SAAS,CAAC;AACrC,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,8BAA8B,CAACH,QAA4B,EAA4C;IACrH,OAAOA,QAAQ,CAACF,IAAI,KAAKF,oBAAoB,CAAC;AAChD,CAAC"}
|
|
@@ -17,6 +17,7 @@ import TrashIcon from 'mdi-material-ui/TrashCan';
|
|
|
17
17
|
export function MatcherEditor({ matchers , onChange }) {
|
|
18
18
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
19
19
|
spacing: 1,
|
|
20
|
+
mb: 2,
|
|
20
21
|
children: [
|
|
21
22
|
matchers.map((matcher, index)=>/*#__PURE__*/ _jsxs(Box, {
|
|
22
23
|
display: "flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n};\n\nexport function MatcherEditor({ matchers, onChange }: MatcherEditorProps) {\n return (\n <Stack spacing={1}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","spacing","map","matcher","index","display","fullWidth","label","value","e","newMatchers","draft","target","onClick","splice","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,OAAOC,SAAS,MAAM,0BAA0B,CAAC;AAOjD,OAAO,SAASC,aAAa,CAAC,EAAEC,QAAQ,CAAA,EAAEC,QAAQ,CAAA,EAAsB,EAAE;IACxE,qBACE,MAACT,KAAK;QAACU,OAAO,EAAE,CAAC;;
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n};\n\nexport function MatcherEditor({ matchers, onChange }: MatcherEditorProps) {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","spacing","mb","map","matcher","index","display","fullWidth","label","value","e","newMatchers","draft","target","onClick","splice","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AAC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D,MAAM;oBACLc,SAAS,EAAE,KAAK;oBAChBS,KAAK,EAAC,WAAW;oBACjBC,OAAO,EAAC,UAAU;oBAClBH,OAAO,EAAE,IAAM;wBACb,MAAMH,WAAW,GAAGf,OAAO,CAACG,QAAQ,EAAE,CAACa,KAAK,GAAK;4BAC/CA,KAAK,CAACM,IAAI,CAAC,EAAE,CAAC,CAAC;wBACjB,CAAC,CAAC,AAAC;wBACHlB,QAAQ,CAACW,WAAW,CAAC,CAAC;oBACxB,CAAC;8BACF,qBAED;kBAAS;cACL;;MACA,CACR;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";AAwBA,OAAO,EAAE,oCAAoC,EAAiC,MAAM,sBAAsB,CAAC;AAE3G;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,eAyD1F"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { produce } from 'immer';
|
|
15
15
|
import { Stack, TextField, FormControl, InputLabel } from '@mui/material';
|
|
16
16
|
import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
|
|
17
|
-
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../../model';
|
|
17
|
+
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
|
|
18
18
|
import { PromQLEditor } from '../../components';
|
|
19
19
|
import { useQueryState, useFormatState } from './query-editor-model';
|
|
20
20
|
/**
|
|
@@ -41,6 +41,23 @@ import { useQueryState, useFormatState } from './query-editor-model';
|
|
|
41
41
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
42
42
|
spacing: 2,
|
|
43
43
|
children: [
|
|
44
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
45
|
+
margin: "dense",
|
|
46
|
+
fullWidth: false,
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
49
|
+
id: "prom-datasource-label",
|
|
50
|
+
children: "Prometheus Datasource"
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
53
|
+
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
54
|
+
value: selectedDatasource,
|
|
55
|
+
onChange: handleDatasourceChange,
|
|
56
|
+
labelId: "prom-datasource-label",
|
|
57
|
+
label: "Prometheus Datasource"
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
}),
|
|
44
61
|
/*#__PURE__*/ _jsx(PromQLEditor, {
|
|
45
62
|
completeConfig: {
|
|
46
63
|
remote: {
|
|
@@ -59,23 +76,6 @@ import { useQueryState, useFormatState } from './query-editor-model';
|
|
|
59
76
|
value: format !== null && format !== void 0 ? format : '',
|
|
60
77
|
onChange: (e)=>handleFormatChange(e.target.value),
|
|
61
78
|
onBlur: handleFormatBlur
|
|
62
|
-
}),
|
|
63
|
-
/*#__PURE__*/ _jsxs(FormControl, {
|
|
64
|
-
margin: "dense",
|
|
65
|
-
fullWidth: false,
|
|
66
|
-
children: [
|
|
67
|
-
/*#__PURE__*/ _jsx(InputLabel, {
|
|
68
|
-
id: "prom-datasource-label",
|
|
69
|
-
children: "Prometheus Datasource"
|
|
70
|
-
}),
|
|
71
|
-
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
72
|
-
datasourcePluginKind: "PrometheusDatasource",
|
|
73
|
-
value: selectedDatasource,
|
|
74
|
-
onChange: handleDatasourceChange,
|
|
75
|
-
labelId: "prom-datasource-label",
|
|
76
|
-
label: "Prometheus Datasource"
|
|
77
|
-
})
|
|
78
|
-
]
|
|
79
79
|
})
|
|
80
80
|
]
|
|
81
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect, DatasourceSelectProps, useDatasourceClient } from '@perses-dev/plugin-system';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect, DatasourceSelectProps, useDatasourceClient } from '@perses-dev/plugin-system';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n} from '../../model';\nimport { PromQLEditor } from '../../components';\nimport { PrometheusTimeSeriesQueryEditorProps, useQueryState, useFormatState } from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps) {\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 { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={query}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n <TextField\n fullWidth\n label=\"Legend Name\"\n placeholder=\"Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.\"\n helperText=\"Set the name for each series in the legend and the tooltip.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n />\n </Stack>\n );\n}\n"],"names":["produce","Stack","TextField","FormControl","InputLabel","DatasourceSelect","useDatasourceClient","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","PromQLEditor","useQueryState","useFormatState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","selectedDatasource","data","client","promURL","options","datasourceUrl","query","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","id","datasourcePluginKind","labelId","label","completeConfig","remote","url","onBlur","placeholder","helperText","e","target"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,gBAAgB,EAAyBC,mBAAmB,QAAQ,2BAA2B,CAAC;AACzG,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAEf,aAAa,CAAC;AACrB,SAASC,YAAY,QAAQ,kBAAkB,CAAC;AAChD,SAA+CC,aAAa,EAAEC,cAAc,QAAQ,sBAAsB,CAAC;AAE3G;;CAEC,GACD,OAAO,SAASC,+BAA+B,CAACC,KAA2C,EAAE;IAC3F,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,MAAM,EAAEG,UAAU,CAAA,EAAE,GAAGD,KAAK,AAAC;IAC7B,MAAME,kBAAkB,GAAGD,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIX,YAAY,AAAC;IAEtD,MAAM,EAAEa,IAAI,EAAEC,MAAM,CAAA,EAAE,GAAGf,mBAAmB,CA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cAAc,EAAE;oBAAEC,MAAM,EAAE;wBAAEC,GAAG,EAAExB,OAAO;qBAAE;iBAAE;gBAC5CL,KAAK,EAAEQ,KAAK;gBACZT,QAAQ,EAAEU,iBAAiB;gBAC3BqB,MAAM,EAAEpB,eAAe;cACvB;0BACF,KAACzB,SAAS;gBACRqC,SAAS;gBACTI,KAAK,EAAC,aAAa;gBACnBK,WAAW,EAAC,0HAA0H;gBACtIC,UAAU,EAAC,6DAA6D;gBACxEhC,KAAK,EAAEW,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,EAAE;gBACnBZ,QAAQ,EAAE,CAACkC,CAAC,GAAKrB,kBAAkB,CAACqB,CAAC,CAACC,MAAM,CAAClC,KAAK,CAAC;gBACnD8B,MAAM,EAAEjB,gBAAgB;cACxB;;MACI,CACR;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAYA,OAAO,
|
|
1
|
+
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAYA,OAAO,EAML,cAAc,EACf,MAAM,2BAA2B,CAAC;AAenC,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAmLjB,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAgB5F,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CA8B9F,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAwBpF,CAAC"}
|
|
@@ -11,19 +11,48 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
|
|
15
|
+
import { FormControl, InputLabel, Stack, TextField } from '@mui/material';
|
|
16
|
+
import { produce } from 'immer';
|
|
17
|
+
import { DEFAULT_PROM, getPrometheusTimeRange, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model';
|
|
18
|
+
import { parseTemplateVariables, replaceTemplateVariables } from '../utils';
|
|
19
|
+
import { PromQLEditor } from '../components';
|
|
17
20
|
import { MatcherEditor } from './MatcherEditor';
|
|
18
21
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
22
|
+
const { onChange , value } = props;
|
|
23
|
+
const { datasource } = value;
|
|
24
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM;
|
|
25
|
+
const handleDatasourceChange = (next)=>{
|
|
26
|
+
if (isPrometheusDatasourceSelector(next)) {
|
|
27
|
+
onChange(produce(value, (draft)=>{
|
|
28
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
29
|
+
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
30
|
+
}));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
34
|
+
};
|
|
19
35
|
var _matchers;
|
|
20
36
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
21
|
-
spacing:
|
|
37
|
+
spacing: 2,
|
|
22
38
|
children: [
|
|
39
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
40
|
+
margin: "dense",
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
43
|
+
id: "prom-datasource-label",
|
|
44
|
+
children: "Prometheus Datasource"
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
47
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
48
|
+
value: selectedDatasource,
|
|
49
|
+
onChange: handleDatasourceChange,
|
|
50
|
+
labelId: "prom-datasource-label",
|
|
51
|
+
label: "Prometheus Datasource"
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
23
55
|
/*#__PURE__*/ _jsx(TextField, {
|
|
24
|
-
sx: {
|
|
25
|
-
mb: 1
|
|
26
|
-
},
|
|
27
56
|
label: "Label Name",
|
|
28
57
|
required: true,
|
|
29
58
|
value: props.value.label_name,
|
|
@@ -47,42 +76,102 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
47
76
|
});
|
|
48
77
|
}
|
|
49
78
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
79
|
+
const { onChange , value } = props;
|
|
80
|
+
const { datasource } = value;
|
|
81
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM;
|
|
82
|
+
const handleDatasourceChange = (next)=>{
|
|
83
|
+
if (isPrometheusDatasourceSelector(next)) {
|
|
84
|
+
onChange(produce(value, (draft)=>{
|
|
85
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
86
|
+
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
87
|
+
}));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
91
|
+
};
|
|
50
92
|
var _matchers;
|
|
51
|
-
return /*#__PURE__*/
|
|
52
|
-
spacing:
|
|
53
|
-
children:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
94
|
+
spacing: 2,
|
|
95
|
+
children: [
|
|
96
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
97
|
+
margin: "dense",
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
100
|
+
id: "prom-datasource-label",
|
|
101
|
+
children: "Prometheus Datasource"
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
104
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
105
|
+
value: selectedDatasource,
|
|
106
|
+
onChange: handleDatasourceChange,
|
|
107
|
+
labelId: "prom-datasource-label",
|
|
108
|
+
label: "Prometheus Datasource"
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ _jsx(MatcherEditor, {
|
|
113
|
+
matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
|
|
114
|
+
onChange: (e)=>{
|
|
115
|
+
props.onChange({
|
|
116
|
+
...props.value,
|
|
117
|
+
matchers: e
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
]
|
|
62
122
|
});
|
|
63
123
|
}
|
|
64
124
|
function PrometheusPromQLVariableEditor(props) {
|
|
125
|
+
const { onChange , value } = props;
|
|
126
|
+
const { datasource } = value;
|
|
127
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM;
|
|
128
|
+
const { data: client } = useDatasourceClient(selectedDatasource);
|
|
129
|
+
const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
130
|
+
const handleDatasourceChange = (next)=>{
|
|
131
|
+
if (isPrometheusDatasourceSelector(next)) {
|
|
132
|
+
onChange(produce(value, (draft)=>{
|
|
133
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
134
|
+
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
135
|
+
}));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
139
|
+
};
|
|
65
140
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
66
|
-
spacing:
|
|
141
|
+
spacing: 2,
|
|
67
142
|
children: [
|
|
68
|
-
/*#__PURE__*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
143
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
144
|
+
margin: "dense",
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
147
|
+
id: "prom-datasource-label",
|
|
148
|
+
children: "Prometheus Datasource"
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
151
|
+
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
152
|
+
value: selectedDatasource,
|
|
153
|
+
onChange: handleDatasourceChange,
|
|
154
|
+
labelId: "prom-datasource-label",
|
|
155
|
+
label: "Prometheus Datasource"
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ _jsx(PromQLEditor, {
|
|
160
|
+
completeConfig: {
|
|
161
|
+
remote: {
|
|
162
|
+
url: promURL
|
|
163
|
+
}
|
|
72
164
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
onChange: (e)=>{
|
|
165
|
+
value: value.expr,
|
|
166
|
+
onChange: (query)=>{
|
|
76
167
|
props.onChange({
|
|
77
168
|
...props.value,
|
|
78
|
-
expr:
|
|
169
|
+
expr: query
|
|
79
170
|
});
|
|
80
|
-
}
|
|
171
|
+
},
|
|
172
|
+
width: "100%"
|
|
81
173
|
}),
|
|
82
174
|
/*#__PURE__*/ _jsx(TextField, {
|
|
83
|
-
sx: {
|
|
84
|
-
mb: 1
|
|
85
|
-
},
|
|
86
175
|
label: "Label Name",
|
|
87
176
|
value: props.value.label_name,
|
|
88
177
|
onChange: (e)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/prometheus-variables.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.\nimport { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Stack, TextField } from '@mui/material';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange, MatrixData, VectorData } from '../model';\nimport { replaceTemplateVariables, parseTemplateVariables } from '../utils';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\nimport { MatcherEditor } from './MatcherEditor';\n\nfunction PrometheusLabelValuesVariableEditor(props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <TextField\n sx={{ mb: 1 }}\n label=\"Label Name\"\n required\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusLabelNamesVariableEditor(props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusPromQLVariableEditor(props: OptionsEditorProps<PrometheusPromQLVariableOptions>) {\n return (\n <Stack spacing={1}>\n <TextField\n required\n sx={{ mb: 1 }}\n label=\"PromQL Expression\"\n value={props.value.expr}\n onChange={(e) => {\n props.onChange({ ...props.value, expr: e.target.value });\n }}\n />\n <TextField\n sx={{ mb: 1 }}\n label=\"Label Name\"\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n </Stack>\n );\n}\n\nfunction capturingMatrix(matrix: MatrixData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[label_name];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nfunction capturingVector(vector: VectorData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[label_name];\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 */\nconst stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceTemplateVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return { variables: spec.matchers?.map((m) => parseTemplateVariables(m)).flat() || [] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers\n ? pluginDef.matchers.map((m) => replaceTemplateVariables(m, ctx.variables))\n : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceTemplateVariables(pluginDef.label_name, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return {\n variables:\n spec.matchers\n ?.map((m) => parseTemplateVariables(m))\n .flat()\n .concat(parseTemplateVariables(spec.label_name)) || [],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ label_name: '' }),\n};\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceTemplateVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceTemplateVariables(spec.label_name, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec) => {\n return { variables: parseTemplateVariables(spec.expr).concat(parseTemplateVariables(spec.label_name)) };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', label_name: '' }),\n};\n"],"names":["Stack","TextField","DEFAULT_PROM","getPrometheusTimeRange","replaceTemplateVariables","parseTemplateVariables","MatcherEditor","PrometheusLabelValuesVariableEditor","props","spacing","sx","mb","label","required","value","label_name","onChange","e","target","matchers","PrometheusLabelNamesVariableEditor","PrometheusPromQLVariableEditor","expr","capturingMatrix","matrix","captured","Set","sample","result","metric","undefined","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","m","variables","timeRange","data","options","labelNames","dependsOn","flat","OptionsEditorComponent","createInitialOptions","PrometheusLabelValuesVariable","pluginDef","labelValues","labelName","concat","PrometheusPromQLVariable","instantQuery","query","resultType"],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sB,CAACoC,IAAI,CAAC1B,UAAU,CAAC,CAAC;SAAE,CAAC;IAC1G,CAAC;IACDyC,sBAAsB,EAAEnC,8BAA8B;IACtDoC,oBAAoB,EAAE,IAAO,CAAA;YAAEnC,IAAI,EAAE,EAAE;YAAEP,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CAC3D,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/prometheus-variables.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.\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n OptionsEditorProps,\n useDatasourceClient,\n VariableOption,\n VariablePlugin,\n} from '@perses-dev/plugin-system';\nimport { FormControl, InputLabel, Stack, TextField } from '@mui/material';\nimport { produce } from 'immer';\nimport {\n DEFAULT_PROM,\n getPrometheusTimeRange,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n VectorData,\n} from '../model';\nimport { parseTemplateVariables, replaceTemplateVariables } from '../utils';\nimport { PromQLEditor } from '../components';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\nimport { MatcherEditor } from './MatcherEditor';\n\nfunction PrometheusLabelValuesVariableEditor(props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>) {\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 <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <TextField\n label=\"Label Name\"\n required\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusLabelNamesVariableEditor(props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>) {\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 <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusPromQLVariableEditor(props: OptionsEditorProps<PrometheusPromQLVariableOptions>) {\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 <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.expr}\n onChange={(query) => {\n props.onChange({ ...props.value, expr: query });\n }}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n </Stack>\n );\n}\n\nfunction capturingMatrix(matrix: MatrixData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[label_name];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nfunction capturingVector(vector: VectorData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[label_name];\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 */\nconst stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceTemplateVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return { variables: spec.matchers?.map((m) => parseTemplateVariables(m)).flat() || [] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers\n ? pluginDef.matchers.map((m) => replaceTemplateVariables(m, ctx.variables))\n : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceTemplateVariables(pluginDef.label_name, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return {\n variables:\n spec.matchers\n ?.map((m) => parseTemplateVariables(m))\n .flat()\n .concat(parseTemplateVariables(spec.label_name)) || [],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ label_name: '' }),\n};\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceTemplateVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceTemplateVariables(spec.label_name, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec) => {\n return { variables: parseTemplateVariables(spec.expr).concat(parseTemplateVariables(spec.label_name)) };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', label_name: '' }),\n};\n"],"names":["DatasourceSelect","useDatasourceClient","FormControl","InputLabel","Stack","TextField","produce","DEFAULT_PROM","getPrometheusTimeRange","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","parseTemplateVariables","replaceTemplateVariables","PromQLEditor","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","selectedDatasource","handleDatasourceChange","next","draft","undefined","Error","spacing","margin","id","datasourcePluginKind","labelId","label","required","label_name","e","target","matchers","PrometheusLabelNamesVariableEditor","PrometheusPromQLVariableEditor","data","client","promURL","options","datasourceUrl","completeConfig","remote","url","expr","query","width","capturingMatrix","matrix","captured","Set","sample","result","metric","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","datasourceStore","getDatasourceClient","match","m","variables","timeRange","labelNames","dependsOn","flat","OptionsEditorComponent","createInitialOptions","PrometheusLabelValuesVariable","pluginDef","labelValues","labelName","concat","PrometheusPromQLVariable","instantQuery","resultType"],"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;AAAA,SACEA,gBAAgB,EAGhBC,mBAAmB,QAGd,2BAA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SAAS,CAAC,CAAC;QAC/C,OAAO,IAAIzC,CAAAA,OAAO,aAAPA,OAAO,WAAY,GAAnBA,KAAAA,CAAmB,GAAnBA,OAAO,CAAE6C,UAAU,CAAA,KAAK,QAAQ,EAAE;YAC3C3B,MAAM,GAAGC,eAAe,CAACnB,OAAO,EAAEyC,SAAS,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO;YACL5C,IAAI,EAAEwB,4BAA4B,CAACH,MAAM,CAAC;SAC3C,CAAC;IACJ,CAAC;IACDgB,SAAS,EAAE,CAACT,IAAI,GAAK;QACnB,OAAO;YAAEM,SAAS,EAAE9D,sBAAsB,CAACwD,IAAI,CAACpB,IAAI,CAAC,CAACqC,MAAM,CAACzE,sBAAsB,CAACwD,IAAI,CAAClC,UAAU,CAAC,CAAC;SAAE,CAAC;IAC1G,CAAC;IACD6C,sBAAsB,EAAExC,8BAA8B;IACtDyC,oBAAoB,EAAE,IAAO,CAAA;YAAEhC,IAAI,EAAE,EAAE;YAAEd,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CAC3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/plugins/variable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAG/F,aAAK,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEhD,aAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/plugins/variable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAG/F,aAAK,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEhD,aAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAkDF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAiBxE,CAAC"}
|
package/dist/plugins/variable.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx
|
|
14
|
-
import { Autocomplete, TextField
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { Autocomplete, TextField } from '@mui/material';
|
|
15
15
|
function StaticListVariableOptionEditor(props) {
|
|
16
16
|
const value = props.value.values.map((v)=>{
|
|
17
17
|
if (typeof v === 'string') {
|
|
@@ -30,41 +30,30 @@ function StaticListVariableOptionEditor(props) {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
return /*#__PURE__*/
|
|
34
|
-
children:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/*#__PURE__*/ _jsxs(Typography, {
|
|
58
|
-
variant: "caption",
|
|
59
|
-
children: [
|
|
60
|
-
"Type new value then press ",
|
|
61
|
-
`"`,
|
|
62
|
-
"Enter",
|
|
63
|
-
`"`,
|
|
64
|
-
" to add."
|
|
65
|
-
]
|
|
66
|
-
})
|
|
67
|
-
]
|
|
33
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
34
|
+
children: /*#__PURE__*/ _jsx(Autocomplete, {
|
|
35
|
+
onPaste: (e)=>{
|
|
36
|
+
// Append new values on paste
|
|
37
|
+
const v = e.clipboardData.getData('text/plain');
|
|
38
|
+
if (v) {
|
|
39
|
+
const values = v.split(',');
|
|
40
|
+
onChange(null, value.concat(values));
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
multiple: true,
|
|
45
|
+
value: value,
|
|
46
|
+
onChange: onChange,
|
|
47
|
+
options: [],
|
|
48
|
+
freeSolo: true,
|
|
49
|
+
clearOnBlur: true,
|
|
50
|
+
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
51
|
+
...params,
|
|
52
|
+
label: "Values",
|
|
53
|
+
placeholder: "Values",
|
|
54
|
+
helperText: 'Type new value then press "Enter" to add.'
|
|
55
|
+
})
|
|
56
|
+
})
|
|
68
57
|
});
|
|
69
58
|
}
|
|
70
59
|
export const StaticListVariable = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/variable.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 { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Autocomplete, TextField
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/variable.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 { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Autocomplete, TextField } from '@mui/material';\n\ntype StaticListOption = string | VariableOption;\n\ntype StaticListVariableOptions = {\n values: StaticListOption[];\n};\n\nfunction StaticListVariableOptionEditor(props: OptionsEditorProps<StaticListVariableOptions>) {\n const value = props.value.values.map((v) => {\n if (typeof v === 'string') {\n return v;\n } else {\n return v.value;\n }\n });\n\n const onChange = (__: unknown, value: string[]) => {\n props.onChange({\n values: value.map((v) => {\n return { value: v, label: v };\n }),\n });\n };\n\n return (\n <div>\n <Autocomplete\n onPaste={(e) => {\n // Append new values on paste\n const v = e.clipboardData.getData('text/plain');\n if (v) {\n const values = v.split(',');\n onChange(null, value.concat(values));\n e.preventDefault();\n }\n }}\n multiple\n value={value}\n onChange={onChange}\n options={[]}\n freeSolo\n clearOnBlur\n renderInput={(params) => (\n <TextField\n {...params}\n label=\"Values\"\n placeholder=\"Values\"\n helperText='Type new value then press \"Enter\" to add.'\n />\n )}\n />\n </div>\n );\n}\n\nexport const StaticListVariable: VariablePlugin<StaticListVariableOptions> = {\n getVariableOptions: async (spec) => {\n const values = spec.values?.map((v) => {\n if (typeof v === 'string') {\n return { label: v, value: v };\n }\n return v;\n });\n return {\n data: values,\n };\n },\n dependsOn: () => {\n return { variables: [] };\n },\n OptionsEditorComponent: StaticListVariableOptionEditor,\n createInitialOptions: () => ({ values: [] }),\n};\n"],"names":["Autocomplete","TextField","StaticListVariableOptionEditor","props","value","values","map","v","onChange","__","label","div","onPaste","e","clipboardData","getData","split","concat","preventDefault","multiple","options","freeSolo","clearOnBlur","renderInput","params","placeholder","helperText","StaticListVariable","getVariableOptions","spec","data","dependsOn","variables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,s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WAAW;YACXC,WAAW,EAAE,CAACC,MAAM,iBAClB,KAACvB,SAAS;oBACP,GAAGuB,MAAM;oBACVd,KAAK,EAAC,QAAQ;oBACde,WAAW,EAAC,QAAQ;oBACpBC,UAAU,EAAC,2CAA2C;kBACtD,AACH;UACD;MACE,CACN;AACJ,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAA8C;IAC3EC,kBAAkB,EAAE,OAAOC,IAAI,GAAK;YACnBA,GAAW;QAA1B,MAAMxB,MAAM,GAAGwB,CAAAA,GAAW,GAAXA,IAAI,CAACxB,MAAM,cAAXwB,GAAW,WAAK,GAAhBA,KAAAA,CAAgB,GAAhBA,GAAW,CAAEvB,GAAG,CAAC,CAACC,CAAC,GAAK;YACrC,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;gBACzB,OAAO;oBAAEG,KAAK,EAAEH,CAAC;oBAAEH,KAAK,EAAEG,CAAC;iBAAE,CAAC;YAChC,CAAC;YACD,OAAOA,CAAC,CAAC;QACX,CAAC,CAAC,AAAC;QACH,OAAO;YACLuB,IAAI,EAAEzB,MAAM;SACb,CAAC;IACJ,CAAC;IACD0B,SAAS,EAAE,IAAM;QACf,OAAO;YAAEC,SAAS,EAAE,EAAE;SAAE,CAAC;IAC3B,CAAC;IACDC,sBAAsB,EAAE/B,8BAA8B;IACtDgC,oBAAoB,EAAE,IAAO,CAAA;YAAE7B,MAAM,EAAE,EAAE;SAAE,CAAA,AAAC;CAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/prometheus-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Prometheus plugin for Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@lezer/highlight": "^1.0.0",
|
|
33
33
|
"@lezer/lr": "^1.2.0",
|
|
34
|
-
"@perses-dev/components": "0.
|
|
35
|
-
"@perses-dev/core": "0.
|
|
36
|
-
"@perses-dev/plugin-system": "0.
|
|
34
|
+
"@perses-dev/components": "0.31.0",
|
|
35
|
+
"@perses-dev/core": "0.31.0",
|
|
36
|
+
"@perses-dev/plugin-system": "0.31.0",
|
|
37
37
|
"@prometheus-io/codemirror-promql": "^0.43.0",
|
|
38
38
|
"@uiw/react-codemirror": "^4.19.1",
|
|
39
39
|
"date-fns": "^2.28.0",
|