@perses-dev/prometheus-plugin 0.38.0 → 0.40.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/components/PromQL.js +9 -7
- package/dist/cjs/components/index.js +10 -8
- package/dist/cjs/index.js +33 -19
- package/dist/cjs/model/index.js +15 -13
- package/dist/cjs/model/parse-sample-values.js +6 -2
- package/dist/cjs/model/prometheus-client.js +24 -5
- package/dist/cjs/model/prometheus-selectors.js +13 -5
- package/dist/cjs/model/templating.js +7 -5
- package/dist/cjs/model/time.js +14 -8
- package/dist/cjs/plugins/MatcherEditor.js +13 -11
- package/dist/cjs/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +456 -0
- package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +31 -0
- package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +23 -0
- package/dist/cjs/plugins/prometheus-datasource.js +53 -6
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +44 -20
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +41 -22
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +42 -9
- package/dist/cjs/plugins/prometheus-variables.js +60 -54
- package/dist/cjs/plugins/variable.js +9 -7
- package/dist/cjs/utils/index.js +10 -8
- package/dist/cjs/utils/utils.js +12 -6
- package/dist/components/PromQL.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/parse-sample-values.js.map +1 -1
- package/dist/model/prometheus-client.d.ts.map +1 -1
- package/dist/model/prometheus-client.js +9 -0
- package/dist/model/prometheus-client.js.map +1 -1
- package/dist/model/prometheus-selectors.js +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/model/templating.js.map +1 -1
- package/dist/model/time.js +1 -1
- package/dist/model/time.js.map +1 -1
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts +9 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +404 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts +3 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.js +16 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.js.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts +22 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.js +15 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +5 -3
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +50 -5
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.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 +32 -10
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +34 -17
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +10 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js +36 -8
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -2
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
- package/dist/plugins/prometheus-variables.js +27 -27
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/types.d.ts +2 -2
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js.map +1 -1
- package/dist/plugins/variable.js +2 -2
- package/dist/plugins/variable.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +3 -3
- package/dist/utils/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "PrometheusDatasourceEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return PrometheusDatasourceEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
27
|
+
const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
|
|
28
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
29
|
+
const _types = require("./types");
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
36
|
+
if (typeof WeakMap !== "function") return null;
|
|
37
|
+
var cacheBabelInterop = new WeakMap();
|
|
38
|
+
var cacheNodeInterop = new WeakMap();
|
|
39
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
40
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
41
|
+
})(nodeInterop);
|
|
42
|
+
}
|
|
43
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
44
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
45
|
+
return obj;
|
|
46
|
+
}
|
|
47
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
48
|
+
return {
|
|
49
|
+
default: obj
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
53
|
+
if (cache && cache.has(obj)) {
|
|
54
|
+
return cache.get(obj);
|
|
55
|
+
}
|
|
56
|
+
var newObj = {};
|
|
57
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
58
|
+
for(var key in obj){
|
|
59
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
60
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
61
|
+
if (desc && (desc.get || desc.set)) {
|
|
62
|
+
Object.defineProperty(newObj, key, desc);
|
|
63
|
+
} else {
|
|
64
|
+
newObj[key] = obj[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
newObj.default = obj;
|
|
69
|
+
if (cache) {
|
|
70
|
+
cache.set(obj, newObj);
|
|
71
|
+
}
|
|
72
|
+
return newObj;
|
|
73
|
+
}
|
|
74
|
+
function PrometheusDatasourceEditor(props) {
|
|
75
|
+
var _value_proxy, _value_proxy1, _value_proxy2, _value_proxy3;
|
|
76
|
+
const { value , onChange , isReadonly } = props;
|
|
77
|
+
const strDirect = 'Direct access';
|
|
78
|
+
const strProxy = 'Proxy';
|
|
79
|
+
// TODO refactor with useImmer to avoid doing so much destructuring? feasibility & performances to be checked
|
|
80
|
+
// utilitary function used for headers when renaming a property
|
|
81
|
+
// -> TODO it would be cleaner to manipulate headers as a list instead, to avoid doing this.
|
|
82
|
+
// This could be a pure frontend trick, but change in the backend datamodel should also be considered
|
|
83
|
+
const buildNewHeaders = (oldHeaders, oldName, newName)=>{
|
|
84
|
+
if (oldHeaders === undefined) return oldHeaders;
|
|
85
|
+
const keys = Object.keys(oldHeaders);
|
|
86
|
+
const newHeaders = keys.reduce((acc, val)=>{
|
|
87
|
+
if (val === oldName) {
|
|
88
|
+
acc[newName] = oldHeaders[oldName] || '';
|
|
89
|
+
} else {
|
|
90
|
+
acc[val] = oldHeaders[val] || '';
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
return {
|
|
95
|
+
...newHeaders
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const tabs = [
|
|
99
|
+
{
|
|
100
|
+
label: strDirect,
|
|
101
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
102
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
103
|
+
fullWidth: true,
|
|
104
|
+
label: "URL",
|
|
105
|
+
value: value.directUrl || '',
|
|
106
|
+
InputProps: {
|
|
107
|
+
readOnly: isReadonly
|
|
108
|
+
},
|
|
109
|
+
InputLabelProps: {
|
|
110
|
+
shrink: isReadonly ? true : undefined
|
|
111
|
+
},
|
|
112
|
+
onChange: (e)=>onChange({
|
|
113
|
+
...value,
|
|
114
|
+
directUrl: e.target.value
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: strProxy,
|
|
121
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
124
|
+
fullWidth: true,
|
|
125
|
+
label: "URL",
|
|
126
|
+
value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.url) || '',
|
|
127
|
+
InputProps: {
|
|
128
|
+
readOnly: isReadonly
|
|
129
|
+
},
|
|
130
|
+
InputLabelProps: {
|
|
131
|
+
shrink: isReadonly ? true : undefined
|
|
132
|
+
},
|
|
133
|
+
onChange: (e)=>onChange({
|
|
134
|
+
...value,
|
|
135
|
+
...value.proxy && {
|
|
136
|
+
proxy: {
|
|
137
|
+
...value.proxy,
|
|
138
|
+
spec: {
|
|
139
|
+
...value.proxy.spec,
|
|
140
|
+
url: e.target.value
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
147
|
+
variant: "h4",
|
|
148
|
+
mt: 2,
|
|
149
|
+
mb: 1,
|
|
150
|
+
children: "Allowed endpoints"
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
153
|
+
container: true,
|
|
154
|
+
spacing: 2,
|
|
155
|
+
mb: 2,
|
|
156
|
+
children: ((_value_proxy1 = value.proxy) === null || _value_proxy1 === void 0 ? void 0 : _value_proxy1.spec.allowedEndpoints) ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern , method }, i)=>{
|
|
157
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
158
|
+
children: [
|
|
159
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
160
|
+
item: true,
|
|
161
|
+
xs: 8,
|
|
162
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
163
|
+
disabled: true,
|
|
164
|
+
fullWidth: true,
|
|
165
|
+
label: "Endpoint pattern",
|
|
166
|
+
value: endpointPattern,
|
|
167
|
+
InputProps: {
|
|
168
|
+
readOnly: isReadonly
|
|
169
|
+
},
|
|
170
|
+
InputLabelProps: {
|
|
171
|
+
shrink: isReadonly ? true : undefined
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
176
|
+
item: true,
|
|
177
|
+
xs: 4,
|
|
178
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
179
|
+
disabled: true,
|
|
180
|
+
fullWidth: true,
|
|
181
|
+
label: "URL",
|
|
182
|
+
value: method,
|
|
183
|
+
InputProps: {
|
|
184
|
+
readOnly: isReadonly
|
|
185
|
+
},
|
|
186
|
+
InputLabelProps: {
|
|
187
|
+
shrink: isReadonly ? true : undefined
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}, i);
|
|
193
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
194
|
+
item: true,
|
|
195
|
+
xs: 4,
|
|
196
|
+
children: [
|
|
197
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
198
|
+
children: "None"
|
|
199
|
+
}),
|
|
200
|
+
" "
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
}),
|
|
204
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
205
|
+
variant: "h4",
|
|
206
|
+
mb: 1,
|
|
207
|
+
children: "Request Headers"
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
210
|
+
container: true,
|
|
211
|
+
spacing: 2,
|
|
212
|
+
mb: 2,
|
|
213
|
+
children: [
|
|
214
|
+
((_value_proxy2 = value.proxy) === null || _value_proxy2 === void 0 ? void 0 : _value_proxy2.spec.headers) && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
|
|
215
|
+
var _value_proxy_spec_headers, _value_proxy;
|
|
216
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
217
|
+
children: [
|
|
218
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
219
|
+
item: true,
|
|
220
|
+
xs: 4,
|
|
221
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
222
|
+
fullWidth: true,
|
|
223
|
+
label: "Header name",
|
|
224
|
+
value: headerName,
|
|
225
|
+
InputProps: {
|
|
226
|
+
readOnly: isReadonly
|
|
227
|
+
},
|
|
228
|
+
InputLabelProps: {
|
|
229
|
+
shrink: isReadonly ? true : undefined
|
|
230
|
+
},
|
|
231
|
+
onChange: (e)=>onChange({
|
|
232
|
+
...value,
|
|
233
|
+
...value.proxy && {
|
|
234
|
+
proxy: {
|
|
235
|
+
...value.proxy,
|
|
236
|
+
spec: {
|
|
237
|
+
...value.proxy.spec,
|
|
238
|
+
headers: buildNewHeaders(value.proxy.spec.headers, headerName, e.target.value)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
}),
|
|
245
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
246
|
+
item: true,
|
|
247
|
+
xs: 7,
|
|
248
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
249
|
+
fullWidth: true,
|
|
250
|
+
label: "Header value",
|
|
251
|
+
value: (_value_proxy_spec_headers = (_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers) === null || _value_proxy_spec_headers === void 0 ? void 0 : _value_proxy_spec_headers[headerName],
|
|
252
|
+
InputProps: {
|
|
253
|
+
readOnly: isReadonly
|
|
254
|
+
},
|
|
255
|
+
InputLabelProps: {
|
|
256
|
+
shrink: isReadonly ? true : undefined
|
|
257
|
+
},
|
|
258
|
+
onChange: (e)=>onChange({
|
|
259
|
+
...value,
|
|
260
|
+
...value.proxy && {
|
|
261
|
+
proxy: {
|
|
262
|
+
...value.proxy,
|
|
263
|
+
spec: {
|
|
264
|
+
...value.proxy.spec,
|
|
265
|
+
headers: {
|
|
266
|
+
...value.proxy.spec.headers,
|
|
267
|
+
[headerName]: e.target.value
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
})
|
|
274
|
+
}),
|
|
275
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
276
|
+
item: true,
|
|
277
|
+
xs: 1,
|
|
278
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
279
|
+
disabled: isReadonly,
|
|
280
|
+
onClick: ()=>{
|
|
281
|
+
var _value_proxy;
|
|
282
|
+
const newHeaders = {
|
|
283
|
+
...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
|
|
284
|
+
};
|
|
285
|
+
delete newHeaders[headerName];
|
|
286
|
+
onChange({
|
|
287
|
+
...value,
|
|
288
|
+
...value.proxy && {
|
|
289
|
+
proxy: {
|
|
290
|
+
...value.proxy,
|
|
291
|
+
spec: {
|
|
292
|
+
...value.proxy.spec,
|
|
293
|
+
headers: newHeaders
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
]
|
|
303
|
+
}, i);
|
|
304
|
+
}),
|
|
305
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
306
|
+
item: true,
|
|
307
|
+
xs: 12,
|
|
308
|
+
sx: {
|
|
309
|
+
paddingTop: '5px !important'
|
|
310
|
+
},
|
|
311
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
312
|
+
disabled: isReadonly,
|
|
313
|
+
onClick: ()=>onChange({
|
|
314
|
+
...value,
|
|
315
|
+
...value.proxy && {
|
|
316
|
+
proxy: {
|
|
317
|
+
...value.proxy,
|
|
318
|
+
spec: {
|
|
319
|
+
...value.proxy.spec,
|
|
320
|
+
headers: {
|
|
321
|
+
...value.proxy.spec.headers,
|
|
322
|
+
'': ''
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}),
|
|
328
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
}),
|
|
333
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
334
|
+
fullWidth: true,
|
|
335
|
+
label: "Secret",
|
|
336
|
+
value: ((_value_proxy3 = value.proxy) === null || _value_proxy3 === void 0 ? void 0 : _value_proxy3.spec.secret) || '',
|
|
337
|
+
InputProps: {
|
|
338
|
+
readOnly: isReadonly
|
|
339
|
+
},
|
|
340
|
+
InputLabelProps: {
|
|
341
|
+
shrink: isReadonly ? true : undefined
|
|
342
|
+
},
|
|
343
|
+
onChange: (e)=>onChange({
|
|
344
|
+
...value,
|
|
345
|
+
...value.proxy && {
|
|
346
|
+
proxy: {
|
|
347
|
+
...value.proxy,
|
|
348
|
+
spec: {
|
|
349
|
+
...value.proxy.spec,
|
|
350
|
+
secret: e.target.value
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
]
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
];
|
|
360
|
+
// Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
|
|
361
|
+
// bug in case the tabs get eventually swapped in the future.
|
|
362
|
+
const directModeId = tabs.findIndex((tab)=>tab.label == strDirect);
|
|
363
|
+
const proxyModeId = tabs.findIndex((tab)=>tab.label == strProxy);
|
|
364
|
+
// In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
|
|
365
|
+
// Otherwise (create datasource), set defaultTab to Direct access.
|
|
366
|
+
const defaultTab = value.proxy ? proxyModeId : directModeId;
|
|
367
|
+
const initialSpecDirect = {
|
|
368
|
+
directUrl: ''
|
|
369
|
+
};
|
|
370
|
+
const initialSpecProxy = {
|
|
371
|
+
proxy: {
|
|
372
|
+
kind: 'HTTPProxy',
|
|
373
|
+
spec: {
|
|
374
|
+
allowedEndpoints: [
|
|
375
|
+
// hardcoded list of allowed endpoints for now since those are enforced by the backend
|
|
376
|
+
{
|
|
377
|
+
endpointPattern: '/api/v1/labels',
|
|
378
|
+
method: 'POST'
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
endpointPattern: '/api/v1/series',
|
|
382
|
+
method: 'POST'
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
endpointPattern: '/api/v1/metadata',
|
|
386
|
+
method: 'GET'
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
endpointPattern: '/api/v1/query',
|
|
390
|
+
method: 'POST'
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
endpointPattern: '/api/v1/query_range',
|
|
394
|
+
method: 'POST'
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
|
|
398
|
+
method: 'GET'
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
url: ''
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
// For better user experience, save previous states in mind for both mode.
|
|
406
|
+
// This avoids losing everything when the user changes their mind back.
|
|
407
|
+
const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
|
|
408
|
+
const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
|
|
409
|
+
// When changing mode, remove previous mode's config + append default values for the new mode.
|
|
410
|
+
const handleModeChange = (v)=>{
|
|
411
|
+
var _tabs_v, _tabs_v1;
|
|
412
|
+
if (((_tabs_v = tabs[v]) === null || _tabs_v === void 0 ? void 0 : _tabs_v.label) == strDirect) {
|
|
413
|
+
setPreviousSpecProxy(value);
|
|
414
|
+
onChange(previousSpecDirect);
|
|
415
|
+
} else if (((_tabs_v1 = tabs[v]) === null || _tabs_v1 === void 0 ? void 0 : _tabs_v1.label) == strProxy) {
|
|
416
|
+
setPreviousSpecDirect(value);
|
|
417
|
+
onChange(previousSpecProxy);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
421
|
+
children: [
|
|
422
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
423
|
+
variant: "h4",
|
|
424
|
+
mb: 1,
|
|
425
|
+
children: "General Settings"
|
|
426
|
+
}),
|
|
427
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
428
|
+
fullWidth: true,
|
|
429
|
+
label: "Scrape Interval",
|
|
430
|
+
value: value.scrapeInterval || '',
|
|
431
|
+
placeholder: `Default: ${_types.DEFAULT_SCRAPE_INTERVAL}`,
|
|
432
|
+
InputProps: {
|
|
433
|
+
readOnly: isReadonly
|
|
434
|
+
},
|
|
435
|
+
InputLabelProps: {
|
|
436
|
+
shrink: isReadonly ? true : undefined
|
|
437
|
+
},
|
|
438
|
+
onChange: (e)=>onChange({
|
|
439
|
+
...value,
|
|
440
|
+
scrapeInterval: e.target.value
|
|
441
|
+
})
|
|
442
|
+
}),
|
|
443
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
444
|
+
variant: "h4",
|
|
445
|
+
mt: 2,
|
|
446
|
+
children: "HTTP Settings"
|
|
447
|
+
}),
|
|
448
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.OptionsEditorRadios, {
|
|
449
|
+
isReadonly: isReadonly,
|
|
450
|
+
tabs: tabs,
|
|
451
|
+
defaultTab: defaultTab,
|
|
452
|
+
onModeChange: handleModeChange
|
|
453
|
+
})
|
|
454
|
+
]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_export_star(require("./PrometheusDatasourceEditor"), exports);
|
|
18
|
+
_export_star(require("./types"), exports);
|
|
19
|
+
function _export_star(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
22
|
+
Object.defineProperty(to, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return from[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_SCRAPE_INTERVAL", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return DEFAULT_SCRAPE_INTERVAL;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const DEFAULT_SCRAPE_INTERVAL = '1m';
|
|
@@ -16,18 +16,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "PrometheusDatasource", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return PrometheusDatasource;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
const _model = require("../model");
|
|
24
|
+
const _PrometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
|
|
22
25
|
/**
|
|
23
26
|
* Creates a PrometheusClient for a specific datasource spec.
|
|
24
27
|
*/ const createClient = (spec, options)=>{
|
|
25
|
-
const {
|
|
28
|
+
const { directUrl , headers: specHeaders } = spec;
|
|
26
29
|
const { proxyUrl } = options;
|
|
27
30
|
// Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
|
|
28
|
-
const datasourceUrl =
|
|
31
|
+
const datasourceUrl = directUrl !== null && directUrl !== void 0 ? directUrl : proxyUrl;
|
|
29
32
|
if (datasourceUrl === undefined) {
|
|
30
|
-
throw new Error('No URL specified for Prometheus client. You can use
|
|
33
|
+
throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');
|
|
31
34
|
}
|
|
32
35
|
// Could think about this becoming a class, although it definitely doesn't have to be
|
|
33
36
|
return {
|
|
@@ -52,10 +55,54 @@ const _model = require("../model");
|
|
|
52
55
|
})
|
|
53
56
|
};
|
|
54
57
|
};
|
|
58
|
+
const getBuiltinVariableDefinitions = ()=>{
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
kind: 'BuiltinVariable',
|
|
62
|
+
spec: {
|
|
63
|
+
name: '__interval',
|
|
64
|
+
value: ()=>'$__interval',
|
|
65
|
+
source: 'Prometheus',
|
|
66
|
+
display: {
|
|
67
|
+
name: '__interval',
|
|
68
|
+
description: 'Interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',
|
|
69
|
+
hidden: true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
kind: 'BuiltinVariable',
|
|
75
|
+
spec: {
|
|
76
|
+
name: '__interval_ms',
|
|
77
|
+
value: ()=>'$__interval_ms',
|
|
78
|
+
source: 'Prometheus',
|
|
79
|
+
display: {
|
|
80
|
+
name: '__interval_ms',
|
|
81
|
+
description: 'Interval in millisecond that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',
|
|
82
|
+
hidden: true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: 'BuiltinVariable',
|
|
88
|
+
spec: {
|
|
89
|
+
name: '__rate_interval',
|
|
90
|
+
value: ()=>'$__rate_interval',
|
|
91
|
+
source: 'Prometheus',
|
|
92
|
+
display: {
|
|
93
|
+
name: '__rate_interval',
|
|
94
|
+
description: "Interval at least four times the value of the scrape interval. It avoids problems specific to Prometheus when using 'rate' and 'increase' functions.",
|
|
95
|
+
hidden: true
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
};
|
|
55
101
|
const PrometheusDatasource = {
|
|
56
102
|
createClient,
|
|
57
|
-
|
|
103
|
+
getBuiltinVariableDefinitions,
|
|
104
|
+
OptionsEditorComponent: _PrometheusDatasourceEditor.PrometheusDatasourceEditor,
|
|
58
105
|
createInitialOptions: ()=>({
|
|
59
|
-
|
|
106
|
+
directUrl: ''
|
|
60
107
|
})
|
|
61
108
|
};
|
|
@@ -16,22 +16,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "PrometheusTimeSeriesQuery", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return PrometheusTimeSeriesQuery;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
23
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
24
|
+
const _gettimeseriesdata = require("./get-time-series-data");
|
|
25
|
+
const _PrometheusTimeSeriesQueryEditor = require("./PrometheusTimeSeriesQueryEditor");
|
|
24
26
|
const PrometheusTimeSeriesQuery = {
|
|
25
|
-
getTimeSeriesData:
|
|
26
|
-
OptionsEditorComponent:
|
|
27
|
+
getTimeSeriesData: _gettimeseriesdata.getTimeSeriesData,
|
|
28
|
+
OptionsEditorComponent: _PrometheusTimeSeriesQueryEditor.PrometheusTimeSeriesQueryEditor,
|
|
27
29
|
createInitialOptions: ()=>({
|
|
28
30
|
query: '',
|
|
29
31
|
datasource: undefined
|
|
30
32
|
}),
|
|
31
33
|
dependsOn: (spec)=>{
|
|
32
34
|
// Variables can be used in the query and/or in the legend format string
|
|
33
|
-
const queryVariables = (0,
|
|
34
|
-
const legendVariables = (0,
|
|
35
|
+
const queryVariables = (0, _pluginsystem.parseTemplateVariables)(spec.query);
|
|
36
|
+
const legendVariables = (0, _pluginsystem.parseTemplateVariables)(spec.seriesNameFormat || '');
|
|
35
37
|
const allVariables = [
|
|
36
38
|
...new Set([
|
|
37
39
|
...queryVariables,
|