@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +40 -5
- package/dist/cjs/model/prometheus-selectors.js +12 -4
- 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.js +612 -0
- package/dist/cjs/plugins/prometheus-datasource.js +58 -6
- package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +88 -0
- package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +123 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +48 -50
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +41 -21
- 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/types.js +7 -0
- 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 +4 -0
- package/dist/model/prometheus-client.d.ts.map +1 -1
- package/dist/model/prometheus-client.js +24 -0
- package/dist/model/prometheus-client.js.map +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.d.ts +9 -0
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor.js +560 -0
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +1 -5
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +56 -6
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +80 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +115 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +1 -0
- 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 +43 -47
- 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 -16
- 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 +9 -2
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js +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
|
@@ -16,24 +16,32 @@ 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 , proxy } = 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
|
}
|
|
35
|
+
const specHeaders = proxy === null || proxy === void 0 ? void 0 : proxy.spec.headers;
|
|
32
36
|
// Could think about this becoming a class, although it definitely doesn't have to be
|
|
33
37
|
return {
|
|
34
38
|
options: {
|
|
35
39
|
datasourceUrl
|
|
36
40
|
},
|
|
41
|
+
healthCheck: (0, _model.healthCheck)({
|
|
42
|
+
datasourceUrl,
|
|
43
|
+
headers: specHeaders
|
|
44
|
+
}),
|
|
37
45
|
instantQuery: (params, headers)=>(0, _model.instantQuery)(params, {
|
|
38
46
|
datasourceUrl,
|
|
39
47
|
headers: headers !== null && headers !== void 0 ? headers : specHeaders
|
|
@@ -52,10 +60,54 @@ const _model = require("../model");
|
|
|
52
60
|
})
|
|
53
61
|
};
|
|
54
62
|
};
|
|
63
|
+
const getBuiltinVariableDefinitions = ()=>{
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
kind: 'BuiltinVariable',
|
|
67
|
+
spec: {
|
|
68
|
+
name: '__interval',
|
|
69
|
+
value: ()=>'$__interval',
|
|
70
|
+
source: 'Prometheus',
|
|
71
|
+
display: {
|
|
72
|
+
name: '__interval',
|
|
73
|
+
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.',
|
|
74
|
+
hidden: true
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
kind: 'BuiltinVariable',
|
|
80
|
+
spec: {
|
|
81
|
+
name: '__interval_ms',
|
|
82
|
+
value: ()=>'$__interval_ms',
|
|
83
|
+
source: 'Prometheus',
|
|
84
|
+
display: {
|
|
85
|
+
name: '__interval_ms',
|
|
86
|
+
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.',
|
|
87
|
+
hidden: true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
kind: 'BuiltinVariable',
|
|
93
|
+
spec: {
|
|
94
|
+
name: '__rate_interval',
|
|
95
|
+
value: ()=>'$__rate_interval',
|
|
96
|
+
source: 'Prometheus',
|
|
97
|
+
display: {
|
|
98
|
+
name: '__rate_interval',
|
|
99
|
+
description: "Interval at least four times the value of the scrape interval. It avoids problems specific to Prometheus when using 'rate' and 'increase' functions.",
|
|
100
|
+
hidden: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
};
|
|
55
106
|
const PrometheusDatasource = {
|
|
56
107
|
createClient,
|
|
57
|
-
|
|
108
|
+
getBuiltinVariableDefinitions,
|
|
109
|
+
OptionsEditorComponent: _PrometheusDatasourceEditor.PrometheusDatasourceEditor,
|
|
58
110
|
createInitialOptions: ()=>({
|
|
59
|
-
|
|
111
|
+
directUrl: ''
|
|
60
112
|
})
|
|
61
113
|
};
|
package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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, "DashboardPrometheusTimeSeriesQueryEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return DashboardPrometheusTimeSeriesQueryEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _model = require("../../model");
|
|
27
|
+
const _components = require("../../components");
|
|
28
|
+
function DashboardPrometheusTimeSeriesQueryEditor(props) {
|
|
29
|
+
const { selectedDatasource , handleDatasourceChange , promURL , query , handleQueryChange , handleQueryBlur , format , handleFormatBlur , handleMinStepChange , handleFormatChange , handleMinStepBlur , minStepPlaceholder , minStep } = props;
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
31
|
+
spacing: 2,
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
34
|
+
margin: "dense",
|
|
35
|
+
fullWidth: false,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
|
|
38
|
+
id: "prom-datasource-label",
|
|
39
|
+
children: "Prometheus Datasource"
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
|
|
42
|
+
datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
|
|
43
|
+
value: selectedDatasource,
|
|
44
|
+
onChange: handleDatasourceChange,
|
|
45
|
+
labelId: "prom-datasource-label",
|
|
46
|
+
label: "Prometheus Datasource"
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PromQLEditor, {
|
|
51
|
+
completeConfig: {
|
|
52
|
+
remote: {
|
|
53
|
+
url: promURL
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
value: query,
|
|
57
|
+
onChange: handleQueryChange,
|
|
58
|
+
onBlur: handleQueryBlur
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
61
|
+
direction: "row",
|
|
62
|
+
spacing: 2,
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
65
|
+
fullWidth: true,
|
|
66
|
+
label: "Legend Name",
|
|
67
|
+
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
68
|
+
helperText: "Name for each series in the legend and the tooltip.",
|
|
69
|
+
value: format !== null && format !== void 0 ? format : '',
|
|
70
|
+
onChange: (e)=>handleFormatChange(e.target.value),
|
|
71
|
+
onBlur: handleFormatBlur
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
74
|
+
label: "Min Step",
|
|
75
|
+
placeholder: minStepPlaceholder,
|
|
76
|
+
helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
|
|
77
|
+
value: minStep,
|
|
78
|
+
onChange: (e)=>handleMinStepChange(e.target.value),
|
|
79
|
+
onBlur: handleMinStepBlur,
|
|
80
|
+
sx: {
|
|
81
|
+
width: '250px'
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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, "ExplorePrometheusTimeSeriesQueryEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return ExplorePrometheusTimeSeriesQueryEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _model = require("../../model");
|
|
27
|
+
const _components = require("../../components");
|
|
28
|
+
function ExplorePrometheusTimeSeriesQueryEditor(props) {
|
|
29
|
+
const { selectedDatasource , handleDatasourceChange , promURL , query , handleQueryChange , handleQueryBlur , format , handleFormatBlur , handleMinStepChange , handleFormatChange , handleMinStepBlur , minStepPlaceholder , minStep } = props;
|
|
30
|
+
const { project , setProject } = (0, _pluginsystem.useProjectStore)();
|
|
31
|
+
const handleProjectChange = (next)=>{
|
|
32
|
+
handleDatasourceChange(_model.DEFAULT_PROM);
|
|
33
|
+
return setProject(next);
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
36
|
+
spacing: 2,
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
39
|
+
container: true,
|
|
40
|
+
spacing: 2,
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
43
|
+
item: true,
|
|
44
|
+
xs: 2,
|
|
45
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
46
|
+
margin: "dense",
|
|
47
|
+
fullWidth: true,
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
|
|
50
|
+
id: "project-label",
|
|
51
|
+
children: "Projects"
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.ProjectSelect, {
|
|
54
|
+
labelId: "project-label",
|
|
55
|
+
label: "Projects",
|
|
56
|
+
value: project,
|
|
57
|
+
onChange: handleProjectChange
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
63
|
+
item: true,
|
|
64
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
65
|
+
margin: "dense",
|
|
66
|
+
fullWidth: true,
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
|
|
69
|
+
id: "prom-datasource-label",
|
|
70
|
+
children: "Prometheus Datasource"
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
|
|
73
|
+
datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
|
|
74
|
+
value: selectedDatasource,
|
|
75
|
+
project: project.metadata.name,
|
|
76
|
+
onChange: handleDatasourceChange,
|
|
77
|
+
labelId: "prom-datasource-label",
|
|
78
|
+
label: "Prometheus Datasource"
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PromQLEditor, {
|
|
86
|
+
completeConfig: {
|
|
87
|
+
remote: {
|
|
88
|
+
url: promURL
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
value: query,
|
|
92
|
+
onChange: handleQueryChange,
|
|
93
|
+
onBlur: handleQueryBlur
|
|
94
|
+
}),
|
|
95
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
96
|
+
direction: "row",
|
|
97
|
+
spacing: 2,
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
100
|
+
fullWidth: true,
|
|
101
|
+
label: "Legend Name",
|
|
102
|
+
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
103
|
+
helperText: "Name for each series in the legend and the tooltip.",
|
|
104
|
+
value: format !== null && format !== void 0 ? format : '',
|
|
105
|
+
onChange: (e)=>handleFormatChange(e.target.value),
|
|
106
|
+
onBlur: handleFormatBlur
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
109
|
+
label: "Min Step",
|
|
110
|
+
placeholder: minStepPlaceholder,
|
|
111
|
+
helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
|
|
112
|
+
value: minStep,
|
|
113
|
+
onChange: (e)=>handleMinStepChange(e.target.value),
|
|
114
|
+
onBlur: handleMinStepBlur,
|
|
115
|
+
sx: {
|
|
116
|
+
width: '250px'
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -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,
|
|
@@ -16,23 +16,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "PrometheusTimeSeriesQueryEditor", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return PrometheusTimeSeriesQueryEditor;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
22
24
|
const _immer = require("immer");
|
|
23
|
-
const
|
|
24
|
-
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
26
|
const _model = require("../../model");
|
|
26
|
-
const
|
|
27
|
-
const
|
|
27
|
+
const _types = require("../types");
|
|
28
|
+
const _queryeditormodel = require("./query-editor-model");
|
|
29
|
+
const _DashboardPrometheusTimeSeriesQueryEditor = require("./DashboardPrometheusTimeSeriesQueryEditor");
|
|
30
|
+
const _ExplorePrometheusTimeSeriesQueryEditor = require("./ExplorePrometheusTimeSeriesQueryEditor");
|
|
28
31
|
function PrometheusTimeSeriesQueryEditor(props) {
|
|
29
|
-
const { onChange , value } = props;
|
|
32
|
+
const { onChange , value , isExplore } = props;
|
|
30
33
|
const { datasource } = value;
|
|
31
34
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
32
|
-
const { data: client } = (0,
|
|
35
|
+
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
33
36
|
const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
34
|
-
const {
|
|
35
|
-
const {
|
|
37
|
+
const { data: datasourceResource } = (0, _pluginsystem.useDatasource)(selectedDatasource);
|
|
38
|
+
const { query , handleQueryChange , handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
|
|
39
|
+
const { format , handleFormatChange , handleFormatBlur } = (0, _queryeditormodel.useFormatState)(props);
|
|
40
|
+
const { minStep , handleMinStepChange , handleMinStepBlur } = (0, _queryeditormodel.useMinStepState)(props);
|
|
41
|
+
var _ref;
|
|
42
|
+
const minStepPlaceholder = (_ref = minStep !== null && minStep !== void 0 ? minStep : datasourceResource && (datasourceResource === null || datasourceResource === void 0 ? void 0 : datasourceResource.plugin.spec).scrapeInterval) !== null && _ref !== void 0 ? _ref : _types.DEFAULT_SCRAPE_INTERVAL;
|
|
36
43
|
const handleDatasourceChange = (next)=>{
|
|
37
44
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
38
45
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
@@ -44,45 +51,36 @@ function PrometheusTimeSeriesQueryEditor(props) {
|
|
|
44
51
|
}
|
|
45
52
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
46
53
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fullWidth: true,
|
|
79
|
-
label: "Legend Name",
|
|
80
|
-
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
81
|
-
helperText: "Set the name for each series in the legend and the tooltip.",
|
|
82
|
-
value: format !== null && format !== void 0 ? format : '',
|
|
83
|
-
onChange: (e)=>handleFormatChange(e.target.value),
|
|
84
|
-
onBlur: handleFormatBlur
|
|
85
|
-
})
|
|
86
|
-
]
|
|
54
|
+
if (isExplore) {
|
|
55
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExplorePrometheusTimeSeriesQueryEditor.ExplorePrometheusTimeSeriesQueryEditor, {
|
|
56
|
+
selectedDatasource: selectedDatasource,
|
|
57
|
+
handleDatasourceChange: handleDatasourceChange,
|
|
58
|
+
promURL: promURL,
|
|
59
|
+
query: query,
|
|
60
|
+
handleQueryChange: handleQueryChange,
|
|
61
|
+
handleQueryBlur: handleQueryBlur,
|
|
62
|
+
format: format,
|
|
63
|
+
handleFormatChange: handleFormatChange,
|
|
64
|
+
handleFormatBlur: handleFormatBlur,
|
|
65
|
+
minStepPlaceholder: minStepPlaceholder,
|
|
66
|
+
minStep: minStep,
|
|
67
|
+
handleMinStepChange: handleMinStepChange,
|
|
68
|
+
handleMinStepBlur: handleMinStepBlur
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardPrometheusTimeSeriesQueryEditor.DashboardPrometheusTimeSeriesQueryEditor, {
|
|
72
|
+
selectedDatasource: selectedDatasource,
|
|
73
|
+
handleDatasourceChange: handleDatasourceChange,
|
|
74
|
+
promURL: promURL,
|
|
75
|
+
query: query,
|
|
76
|
+
handleQueryChange: handleQueryChange,
|
|
77
|
+
handleQueryBlur: handleQueryBlur,
|
|
78
|
+
format: format,
|
|
79
|
+
handleFormatChange: handleFormatChange,
|
|
80
|
+
handleFormatBlur: handleFormatBlur,
|
|
81
|
+
minStepPlaceholder: minStepPlaceholder,
|
|
82
|
+
minStep: minStep,
|
|
83
|
+
handleMinStepChange: handleMinStepChange,
|
|
84
|
+
handleMinStepBlur: handleMinStepBlur
|
|
87
85
|
});
|
|
88
86
|
}
|
|
@@ -16,23 +16,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "getTimeSeriesData", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return getTimeSeriesData;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _datefns = require("date-fns");
|
|
23
26
|
const _model = require("../../model");
|
|
24
27
|
const _utils = require("../../utils");
|
|
28
|
+
const _types = require("../types");
|
|
25
29
|
const getTimeSeriesData = async (spec, context)=>{
|
|
26
|
-
var
|
|
30
|
+
var _response_data;
|
|
27
31
|
if (spec.query === undefined || spec.query === null || spec.query === '') {
|
|
28
32
|
// Do not make a request to the backend, instead return an empty TimeSeriesData
|
|
29
33
|
return {
|
|
30
34
|
series: []
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
|
-
|
|
37
|
+
var _spec_datasource;
|
|
38
|
+
const datasource = await context.datasourceStore.getDatasource((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
|
|
39
|
+
var _datasource_plugin_spec_scrapeInterval;
|
|
40
|
+
const datasourceScrapeInterval = Math.trunc((0, _datefns.milliseconds)((0, _core.parseDurationString)((_datasource_plugin_spec_scrapeInterval = datasource.plugin.spec.scrapeInterval) !== null && _datasource_plugin_spec_scrapeInterval !== void 0 ? _datasource_plugin_spec_scrapeInterval : _types.DEFAULT_SCRAPE_INTERVAL)) / 1000);
|
|
41
|
+
var _getDurationStringSeconds;
|
|
42
|
+
const minStep = (_getDurationStringSeconds = (0, _model.getDurationStringSeconds)(// resolve any variable that may have been provided
|
|
43
|
+
// TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here
|
|
44
|
+
(0, _pluginsystem.replaceTemplateVariables)(spec.minStep, context.variableState))) !== null && _getDurationStringSeconds !== void 0 ? _getDurationStringSeconds : datasourceScrapeInterval;
|
|
34
45
|
const timeRange = (0, _model.getPrometheusTimeRange)(context.timeRange);
|
|
35
|
-
const step = (0, _model.getRangeStep)(timeRange, minStep, undefined, context.suggestedStepMs);
|
|
46
|
+
const step = (0, _model.getRangeStep)(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution
|
|
36
47
|
// Align the time range so that it's a multiple of the step
|
|
37
48
|
let { start , end } = timeRange;
|
|
38
49
|
const utcOffsetSec = new Date().getTimezoneOffset() * 60;
|
|
@@ -40,17 +51,26 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
40
51
|
const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;
|
|
41
52
|
start = alignedStart;
|
|
42
53
|
end = alignedEnd;
|
|
54
|
+
var _context_suggestedStepMs;
|
|
43
55
|
// Replace template variable placeholders in PromQL query
|
|
44
|
-
|
|
45
|
-
query = (0,
|
|
46
|
-
|
|
56
|
+
const intervalMs = (_context_suggestedStepMs = context.suggestedStepMs) !== null && _context_suggestedStepMs !== void 0 ? _context_suggestedStepMs : step * 1000; // Step is in seconds
|
|
57
|
+
let query = (0, _pluginsystem.replaceTemplateVariable)(spec.query, '__interval_ms', intervalMs.toString());
|
|
58
|
+
query = (0, _pluginsystem.replaceTemplateVariable)(spec.query, '__interval', (0, _core.formatDuration)((0, _core.msToPrometheusDuration)(intervalMs)));
|
|
59
|
+
const scrapeIntervalMs = minStep * 1000;
|
|
60
|
+
// The $__rate_interval variable is meant to be used in the rate function.
|
|
61
|
+
// It is defined as max($__interval + Scrape interval, 4 * Scrape interval), where Scrape interval is the Min step setting (a setting per PromQL query),
|
|
62
|
+
// if any is set, and otherwise the Scrape interval as set in the Prometheus datasource
|
|
63
|
+
const rateIntervalMs = Math.max(intervalMs + scrapeIntervalMs, 4 * scrapeIntervalMs);
|
|
64
|
+
query = (0, _pluginsystem.replaceTemplateVariable)(query, '__rate_interval', (0, _core.formatDuration)((0, _core.msToPrometheusDuration)(rateIntervalMs)));
|
|
65
|
+
query = (0, _pluginsystem.replaceTemplateVariables)(query, context.variableState);
|
|
66
|
+
let seriesNameFormat = spec.seriesNameFormat;
|
|
47
67
|
// if series name format is defined, replace template variable placeholders in series name format
|
|
48
68
|
if (seriesNameFormat) {
|
|
49
|
-
seriesNameFormat = (0,
|
|
69
|
+
seriesNameFormat = (0, _pluginsystem.replaceTemplateVariables)(seriesNameFormat, context.variableState);
|
|
50
70
|
}
|
|
51
|
-
var
|
|
71
|
+
var _spec_datasource1;
|
|
52
72
|
// Get the datasource, using the default Prom Datasource if one isn't specified in the query
|
|
53
|
-
const client = await context.datasourceStore.getDatasourceClient((
|
|
73
|
+
const client = await context.datasourceStore.getDatasourceClient((_spec_datasource1 = spec.datasource) !== null && _spec_datasource1 !== void 0 ? _spec_datasource1 : _model.DEFAULT_PROM);
|
|
54
74
|
// Make the request to Prom
|
|
55
75
|
const response = await client.rangeQuery({
|
|
56
76
|
query,
|
|
@@ -58,16 +78,16 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
58
78
|
end,
|
|
59
79
|
step
|
|
60
80
|
});
|
|
61
|
-
var
|
|
81
|
+
var _response_data_result;
|
|
62
82
|
// TODO: What about error responses from Prom that have a response body?
|
|
63
|
-
const result = (
|
|
83
|
+
const result = (_response_data_result = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.result) !== null && _response_data_result !== void 0 ? _response_data_result : [];
|
|
64
84
|
// Custom display for response header warnings, configurable error responses display coming next
|
|
65
85
|
const notices = [];
|
|
66
86
|
if (response.status === 'success') {
|
|
67
|
-
var
|
|
68
|
-
const warnings = (
|
|
69
|
-
var
|
|
70
|
-
const warningMessage = (
|
|
87
|
+
var _response_warnings;
|
|
88
|
+
const warnings = (_response_warnings = response.warnings) !== null && _response_warnings !== void 0 ? _response_warnings : [];
|
|
89
|
+
var _warnings_;
|
|
90
|
+
const warningMessage = (_warnings_ = warnings[0]) !== null && _warnings_ !== void 0 ? _warnings_ : '';
|
|
71
91
|
if (warningMessage !== '') {
|
|
72
92
|
notices.push({
|
|
73
93
|
type: 'warning',
|
|
@@ -79,13 +99,13 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
79
99
|
const chartData = {
|
|
80
100
|
// Return the time range and step we actually used for the query
|
|
81
101
|
timeRange: {
|
|
82
|
-
start: (0,
|
|
83
|
-
end: (0,
|
|
102
|
+
start: (0, _datefns.fromUnixTime)(start),
|
|
103
|
+
end: (0, _datefns.fromUnixTime)(end)
|
|
84
104
|
},
|
|
85
105
|
stepMs: step * 1000,
|
|
86
106
|
series: result.map((value)=>{
|
|
87
107
|
const { metric , values } = value;
|
|
88
|
-
// Account for
|
|
108
|
+
// Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.
|
|
89
109
|
const { name , formattedName } = (0, _utils.getFormattedPrometheusSeriesName)(query, metric, seriesNameFormat);
|
|
90
110
|
return {
|
|
91
111
|
name,
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
function
|
|
17
|
+
_export_star(require("./PrometheusTimeSeriesQuery"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
19
|
Object.keys(from).forEach(function(k) {
|
|
20
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
});
|
|
27
29
|
return from;
|
|
28
30
|
}
|