@perses-dev/prometheus-plugin 0.41.1 → 0.42.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-client.js +16 -0
- package/dist/cjs/model/prometheus-selectors.js +1 -1
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +272 -186
- package/dist/cjs/plugins/prometheus-datasource.js +4 -0
- 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/PrometheusTimeSeriesQueryEditor.js +34 -60
- 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 +15 -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/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor.js +272 -186
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -1
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +5 -1
- 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/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +37 -63
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/types.d.ts +1 -15
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js.map +1 -1
- package/package.json +4 -4
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
|
+
}
|
|
@@ -22,14 +22,14 @@ Object.defineProperty(exports, "PrometheusTimeSeriesQueryEditor", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _immer = require("immer");
|
|
25
|
-
const _material = require("@mui/material");
|
|
26
25
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
26
|
const _model = require("../../model");
|
|
28
|
-
const _components = require("../../components");
|
|
29
27
|
const _types = require("../types");
|
|
30
28
|
const _queryeditormodel = require("./query-editor-model");
|
|
29
|
+
const _DashboardPrometheusTimeSeriesQueryEditor = require("./DashboardPrometheusTimeSeriesQueryEditor");
|
|
30
|
+
const _ExplorePrometheusTimeSeriesQueryEditor = require("./ExplorePrometheusTimeSeriesQueryEditor");
|
|
31
31
|
function PrometheusTimeSeriesQueryEditor(props) {
|
|
32
|
-
const { onChange , value } = props;
|
|
32
|
+
const { onChange , value , isExplore } = props;
|
|
33
33
|
const { datasource } = value;
|
|
34
34
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
35
35
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
@@ -51,62 +51,36 @@ function PrometheusTimeSeriesQueryEditor(props) {
|
|
|
51
51
|
}
|
|
52
52
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
53
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
direction: "row",
|
|
86
|
-
spacing: 2,
|
|
87
|
-
children: [
|
|
88
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
89
|
-
fullWidth: true,
|
|
90
|
-
label: "Legend Name",
|
|
91
|
-
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
92
|
-
helperText: "Name for each series in the legend and the tooltip.",
|
|
93
|
-
value: format !== null && format !== void 0 ? format : '',
|
|
94
|
-
onChange: (e)=>handleFormatChange(e.target.value),
|
|
95
|
-
onBlur: handleFormatBlur
|
|
96
|
-
}),
|
|
97
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
98
|
-
label: "Min Step",
|
|
99
|
-
placeholder: minStepPlaceholder,
|
|
100
|
-
helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
|
|
101
|
-
value: minStep,
|
|
102
|
-
onChange: (e)=>handleMinStepChange(e.target.value),
|
|
103
|
-
onBlur: handleMinStepBlur,
|
|
104
|
-
sx: {
|
|
105
|
-
width: '250px'
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
]
|
|
109
|
-
})
|
|
110
|
-
]
|
|
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
|
|
111
85
|
});
|
|
112
86
|
}
|
|
@@ -16,6 +16,10 @@ export interface QueryOptions {
|
|
|
16
16
|
datasourceUrl: string;
|
|
17
17
|
headers?: RequestHeaders;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Calls the `/-/healthy` endpoint to check if the datasource is healthy.
|
|
21
|
+
*/
|
|
22
|
+
export declare function healthCheck(queryOptions: QueryOptions): () => Promise<boolean>;
|
|
19
23
|
/**
|
|
20
24
|
* Calls the `/api/v1/query` endpoint to get metrics data.
|
|
21
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAErB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,OAAO,EAAE,uBAAuB,CAAC;IACjC,YAAY,CAAC,MAAM,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC7G,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC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KAAK,CAAC;;GAI7E"}
|
|
@@ -11,6 +11,21 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { fetch, fetchJson } from '@perses-dev/core';
|
|
14
|
+
/**
|
|
15
|
+
* Calls the `/-/healthy` endpoint to check if the datasource is healthy.
|
|
16
|
+
*/ export function healthCheck(queryOptions) {
|
|
17
|
+
return async ()=>{
|
|
18
|
+
const url = `${queryOptions.datasourceUrl}/-/healthy`;
|
|
19
|
+
try {
|
|
20
|
+
const resp = await fetch(url, {
|
|
21
|
+
headers: queryOptions.headers
|
|
22
|
+
});
|
|
23
|
+
return resp.status === 200;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
14
29
|
/**
|
|
15
30
|
* Calls the `/api/v1/query` endpoint to get metrics data.
|
|
16
31
|
*/ export function instantQuery(params, queryOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/prometheus-client.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 { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(params: InstantQueryRequestParameters, headers?: RequestHeaders): Promise<InstantQueryResponse>;\n rangeQuery(params: RangeQueryRequestParameters, headers?: RequestHeaders): Promise<RangeQueryResponse>;\n labelNames(params: LabelNamesRequestParameters, headers?: RequestHeaders): Promise<LabelNamesResponse>;\n labelValues(params: LabelValuesRequestParameters, headers?: RequestHeaders): Promise<LabelValuesResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(params: InstantQueryRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(params: RangeQueryRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(params: LabelNamesRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(apiURI: string, params: T, queryOptions: QueryOptions) {\n const { datasourceUrl } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = createSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n return fetchJson<TResponse>(url, { method: 'GET' });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(apiURI: string, params: T, queryOptions: QueryOptions) {\n const { datasourceUrl, headers } = queryOptions;\n\n const url = `${datasourceUrl}${apiURI}`;\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T) {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>) {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","
|
|
1
|
+
{"version":3,"sources":["../../src/model/prometheus-client.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 { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(params: InstantQueryRequestParameters, headers?: RequestHeaders): Promise<InstantQueryResponse>;\n rangeQuery(params: RangeQueryRequestParameters, headers?: RequestHeaders): Promise<RangeQueryResponse>;\n labelNames(params: LabelNamesRequestParameters, headers?: RequestHeaders): Promise<LabelNamesResponse>;\n labelValues(params: LabelValuesRequestParameters, headers?: RequestHeaders): Promise<LabelValuesResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\n/**\n * Calls the `/-/healthy` endpoint to check if the datasource is healthy.\n */\nexport function healthCheck(queryOptions: QueryOptions) {\n return async () => {\n const url = `${queryOptions.datasourceUrl}/-/healthy`;\n\n try {\n const resp = await fetch(url, { headers: queryOptions.headers });\n return resp.status === 200;\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(params: InstantQueryRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(params: RangeQueryRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(params: LabelNamesRequestParameters, queryOptions: QueryOptions) {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(apiURI: string, params: T, queryOptions: QueryOptions) {\n const { datasourceUrl } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = createSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n return fetchJson<TResponse>(url, { method: 'GET' });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(apiURI: string, params: T, queryOptions: QueryOptions) {\n const { datasourceUrl, headers } = queryOptions;\n\n const url = `${datasourceUrl}${apiURI}`;\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T) {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>) {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","healthCheck","queryOptions","url","datasourceUrl","resp","headers","status","instantQuery","params","fetchWithPost","rangeQuery","labelNames","labelValues","labelName","searchParams","length","Promise","resolve","data","apiURI","encodeURIComponent","fetchWithGet","urlParams","createSearchParams","toString","method","init","body","fetchResults","URLSearchParams","key","value","undefined","append","val","args","response","json","rawResponse"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,SAAS,QAAwB,mBAAmB;AAgCpE;;CAEC,GACD,OAAO,SAASC,YAAYC,YAA0B;IACpD,OAAO;QACL,MAAMC,MAAM,CAAC,EAAED,aAAaE,cAAc,UAAU,CAAC;QAErD,IAAI;YACF,MAAMC,OAAO,MAAMN,MAAMI,KAAK;gBAAEG,SAASJ,aAAaI;YAAQ;YAC9D,OAAOD,KAAKE,WAAW;QACzB,EAAE,UAAM;YACN,OAAO;QACT;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASC,aAAaC,MAAqC,EAAEP,YAA0B;IAC5F,OAAOQ,cAAmE,iBAAiBD,QAAQP;AACrG;AAEA;;CAEC,GACD,OAAO,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Cf,MAAS;IAC/D,MAAMM,eAAe,IAAIe;IACzB,IAAK,MAAMC,OAAOtB,OAAQ;QACxB,MAAMuB,QAAoBvB,MAAM,CAACsB,IAAI;QACrC,IAAIC,UAAUC,WAAW;QAEzB,IAAI,OAAOD,UAAU,UAAU;YAC7BjB,aAAamB,OAAOH,KAAKC;YACzB;QACF;QAEA,IAAI,OAAOA,UAAU,UAAU;YAC7BjB,aAAamB,OAAOH,KAAKC,MAAMP;YAC/B;QACF;QAEA,KAAK,MAAMU,OAAOH,MAAO;YACvBjB,aAAamB,OAAOH,KAAKI;QAC3B;IACF;IACA,OAAOpB;AACT;AAEA;;CAEC,GACD,OAAO,eAAec,aAAgB,GAAGO,IAAqC;IAC5E,MAAMC,WAAW,MAAMtC,SAASqC;IAChC,MAAME,OAAU,MAAMD,SAASC;IAC/B,OAAO;QAAE,GAAGA,IAAI;QAAEC,aAAaF;IAAS;AAC1C"}
|
|
@@ -19,7 +19,7 @@ export const PROM_DATASOURCE_KIND = 'PrometheusDatasource';
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns true if the provided PrometheusDatasourceSelector is the default one.
|
|
21
21
|
*/ export function isDefaultPromSelector(selector) {
|
|
22
|
-
return selector.name === undefined
|
|
22
|
+
return selector.name === undefined;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Type guard to make sure a DatasourceSelector is a Prometheus one.
|
|
@@ -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\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
|
|
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,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBAAsBC,QAAsC;IAC1E,OAAOA,SAASC,SAASC;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASC,+BAA+BH,QAA4B;IACzE,OAAOA,SAASF,SAASF;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":";AAqBA,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,eAkehF"}
|