@perses-dev/explore 0.47.1 → 0.48.0-rc0
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/ExploreManager/ExplorerManagerProvider.js +9 -23
- package/dist/cjs/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +1 -2
- package/dist/cjs/components/ExploreManager/MetricsExplorer.js +59 -14
- package/dist/cjs/components/ExploreManager/TracesExplorer.js +4 -2
- package/dist/cjs/components/ExploreManager/query-params.js +49 -0
- package/dist/cjs/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js +209 -0
- package/dist/cjs/components/PrometheusMetricsFinder/display/MetricChip.js +61 -0
- package/dist/cjs/components/PrometheusMetricsFinder/display/list/MetricList.js +156 -0
- package/dist/cjs/components/PrometheusMetricsFinder/filter/FilterInputs.js +232 -0
- package/dist/cjs/components/PrometheusMetricsFinder/filter/FinderFilters.js +139 -0
- package/dist/cjs/components/PrometheusMetricsFinder/index.js +30 -0
- package/dist/cjs/components/PrometheusMetricsFinder/overview/MetricOverview.js +235 -0
- package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/JobTab.js +146 -0
- package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +413 -0
- package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +54 -0
- package/dist/cjs/components/PrometheusMetricsFinder/types.js +25 -0
- package/dist/cjs/components/PrometheusMetricsFinder/utils.js +202 -0
- package/dist/cjs/components/index.js +32 -0
- package/dist/cjs/index.js +1 -0
- package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts +7 -11
- package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts.map +1 -1
- package/dist/components/ExploreManager/ExplorerManagerProvider.js +9 -23
- package/dist/components/ExploreManager/ExplorerManagerProvider.js.map +1 -1
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.d.ts.map +1 -1
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +2 -3
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js.map +1 -1
- package/dist/components/ExploreManager/MetricsExplorer.d.ts.map +1 -1
- package/dist/components/ExploreManager/MetricsExplorer.js +59 -14
- package/dist/components/ExploreManager/MetricsExplorer.js.map +1 -1
- package/dist/components/ExploreManager/TracesExplorer.d.ts.map +1 -1
- package/dist/components/ExploreManager/TracesExplorer.js +4 -2
- package/dist/components/ExploreManager/TracesExplorer.js.map +1 -1
- package/dist/components/ExploreManager/query-params.d.ts +17 -0
- package/dist/components/ExploreManager/query-params.d.ts.map +1 -0
- package/dist/components/ExploreManager/query-params.js +34 -0
- package/dist/components/ExploreManager/query-params.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts +30 -0
- package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js +185 -0
- package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/display/MetricChip.d.ts +3 -0
- package/dist/components/PrometheusMetricsFinder/display/MetricChip.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/display/MetricChip.js +53 -0
- package/dist/components/PrometheusMetricsFinder/display/MetricChip.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/display/list/MetricList.d.ts +20 -0
- package/dist/components/PrometheusMetricsFinder/display/list/MetricList.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/display/list/MetricList.js +135 -0
- package/dist/components/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.d.ts +23 -0
- package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.js +210 -0
- package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.d.ts +12 -0
- package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.js +85 -0
- package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/index.d.ts +2 -0
- package/dist/components/PrometheusMetricsFinder/index.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/index.js +15 -0
- package/dist/components/PrometheusMetricsFinder/index.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.d.ts +21 -0
- package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.js +214 -0
- package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts +27 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.js +127 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts +24 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +389 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts +11 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +46 -0
- package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/types.d.ts +21 -0
- package/dist/components/PrometheusMetricsFinder/types.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/types.js +17 -0
- package/dist/components/PrometheusMetricsFinder/types.js.map +1 -0
- package/dist/components/PrometheusMetricsFinder/utils.d.ts +18 -0
- package/dist/components/PrometheusMetricsFinder/utils.d.ts.map +1 -0
- package/dist/components/PrometheusMetricsFinder/utils.js +184 -0
- package/dist/components/PrometheusMetricsFinder/utils.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +17 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -9
|
@@ -78,53 +78,39 @@ function ExplorerManagerProvider({ children, store: externalStore }) {
|
|
|
78
78
|
// local store in case external store is not provided by prop
|
|
79
79
|
const localStore = (0, _react.useState)({
|
|
80
80
|
explorer: 'metrics',
|
|
81
|
-
|
|
82
|
-
queries: []
|
|
81
|
+
data: {}
|
|
83
82
|
});
|
|
84
83
|
// use store provided by 'store' prop if available, otherwise use local store
|
|
85
84
|
const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;
|
|
86
|
-
const { explorer,
|
|
85
|
+
const { explorer, data } = explorerState;
|
|
87
86
|
function setExplorer(newExplorer) {
|
|
88
87
|
// store current explorer state
|
|
89
88
|
explorerStateCache[explorer] = {
|
|
90
|
-
|
|
91
|
-
queries
|
|
89
|
+
data
|
|
92
90
|
};
|
|
93
91
|
setExplorerStateCache(explorerStateCache);
|
|
94
92
|
var _explorerStateCache_newExplorer;
|
|
95
93
|
// restore previous explorer state (if any)
|
|
96
94
|
const state = (_explorerStateCache_newExplorer = explorerStateCache[newExplorer]) !== null && _explorerStateCache_newExplorer !== void 0 ? _explorerStateCache_newExplorer : {
|
|
97
|
-
|
|
98
|
-
queries: []
|
|
95
|
+
data: {}
|
|
99
96
|
};
|
|
100
97
|
setExplorerState({
|
|
101
98
|
explorer: newExplorer,
|
|
102
|
-
|
|
103
|
-
queries: state.queries
|
|
99
|
+
data: state.data
|
|
104
100
|
});
|
|
105
101
|
}
|
|
106
|
-
function
|
|
102
|
+
function setData(newData) {
|
|
107
103
|
setExplorerState({
|
|
108
104
|
explorer,
|
|
109
|
-
|
|
110
|
-
queries
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function setQueries(newQueries) {
|
|
114
|
-
setExplorerState({
|
|
115
|
-
explorer,
|
|
116
|
-
tab,
|
|
117
|
-
queries: newQueries
|
|
105
|
+
data: newData
|
|
118
106
|
});
|
|
119
107
|
}
|
|
120
108
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ExplorerManagerContext.Provider, {
|
|
121
109
|
value: {
|
|
122
110
|
explorer,
|
|
123
|
-
|
|
124
|
-
queries,
|
|
111
|
+
data,
|
|
125
112
|
setExplorer,
|
|
126
|
-
|
|
127
|
-
setQueries
|
|
113
|
+
setData
|
|
128
114
|
},
|
|
129
115
|
children: children
|
|
130
116
|
});
|
|
@@ -34,8 +34,7 @@ const exploreQueryConfig = {
|
|
|
34
34
|
'metrics',
|
|
35
35
|
'traces'
|
|
36
36
|
]), 'metrics'),
|
|
37
|
-
|
|
38
|
-
queries: (0, _usequeryparams.withDefault)(_usequeryparams.JsonParam, [])
|
|
37
|
+
data: (0, _usequeryparams.withDefault)(_usequeryparams.JsonParam, {})
|
|
39
38
|
};
|
|
40
39
|
function ExplorerManagerProviderWithQueryParams({ children }) {
|
|
41
40
|
const [queryParams, setQueryParams] = (0, _usequeryparams.useQueryParams)(exploreQueryConfig);
|
|
@@ -25,6 +25,8 @@ const _material = require("@mui/material");
|
|
|
25
25
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
26
|
const _useresizeobserver = /*#__PURE__*/ _interop_require_default(require("use-resize-observer"));
|
|
27
27
|
const _dashboards = require("@perses-dev/dashboards");
|
|
28
|
+
const _prometheusplugin = require("@perses-dev/prometheus-plugin");
|
|
29
|
+
const _PrometheusMetricsFinder = require("../PrometheusMetricsFinder");
|
|
28
30
|
const _constants = require("./constants");
|
|
29
31
|
const _ExplorerManagerProvider = require("./ExplorerManagerProvider");
|
|
30
32
|
function _interop_require_default(obj) {
|
|
@@ -76,7 +78,7 @@ function TimeSeriesPanel({ queries }) {
|
|
|
76
78
|
function MetricDataTable({ queries }) {
|
|
77
79
|
const height = _constants.PANEL_PREVIEW_HEIGHT;
|
|
78
80
|
// map TimeSeriesQueryDefinition to Definition<UnknownSpec>
|
|
79
|
-
const definitions =
|
|
81
|
+
const definitions = queries.map((query)=>{
|
|
80
82
|
return {
|
|
81
83
|
kind: query.spec.plugin.kind,
|
|
82
84
|
spec: query.spec.plugin.spec
|
|
@@ -111,23 +113,19 @@ function MetricDataTable({ queries }) {
|
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
function MetricsExplorer() {
|
|
114
|
-
const { tab, queries,
|
|
116
|
+
const { data: { tab = 'table', queries = [], datasource = _prometheusplugin.DEFAULT_PROM, filters = [], exploredMetric = undefined }, setData } = (0, _ExplorerManagerProvider.useExplorerManagerContext)();
|
|
115
117
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
116
118
|
gap: 2,
|
|
117
119
|
sx: {
|
|
118
120
|
width: '100%'
|
|
119
121
|
},
|
|
120
122
|
children: [
|
|
121
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.MultiQueryEditor, {
|
|
122
|
-
queryTypes: [
|
|
123
|
-
'TimeSeriesQuery'
|
|
124
|
-
],
|
|
125
|
-
onChange: setQueries,
|
|
126
|
-
queries: queries
|
|
127
|
-
}),
|
|
128
123
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Tabs, {
|
|
129
124
|
value: tab,
|
|
130
|
-
onChange: (_, state)=>
|
|
125
|
+
onChange: (_, state)=>setData({
|
|
126
|
+
tab: state,
|
|
127
|
+
queries
|
|
128
|
+
}),
|
|
131
129
|
variant: "scrollable",
|
|
132
130
|
sx: {
|
|
133
131
|
borderBottom: 1,
|
|
@@ -135,21 +133,68 @@ function MetricsExplorer() {
|
|
|
135
133
|
},
|
|
136
134
|
children: [
|
|
137
135
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
|
|
136
|
+
value: "table",
|
|
138
137
|
label: "Table"
|
|
139
138
|
}),
|
|
140
139
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
|
|
140
|
+
value: "graph",
|
|
141
141
|
label: "Graph"
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
|
|
144
|
+
value: "finder",
|
|
145
|
+
label: "Finder"
|
|
142
146
|
})
|
|
143
147
|
]
|
|
144
148
|
}),
|
|
145
149
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
146
150
|
gap: 1,
|
|
147
151
|
children: [
|
|
148
|
-
tab ===
|
|
149
|
-
|
|
152
|
+
tab === 'table' && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.MultiQueryEditor, {
|
|
155
|
+
queryTypes: [
|
|
156
|
+
'TimeSeriesQuery'
|
|
157
|
+
],
|
|
158
|
+
onChange: (state)=>setData({
|
|
159
|
+
tab,
|
|
160
|
+
queries: state
|
|
161
|
+
}),
|
|
162
|
+
queries: queries
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(MetricDataTable, {
|
|
165
|
+
queries: queries
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}),
|
|
169
|
+
tab === 'graph' && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
170
|
+
children: [
|
|
171
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.MultiQueryEditor, {
|
|
172
|
+
queryTypes: [
|
|
173
|
+
'TimeSeriesQuery'
|
|
174
|
+
],
|
|
175
|
+
onChange: (state)=>setData({
|
|
176
|
+
tab,
|
|
177
|
+
queries: state
|
|
178
|
+
}),
|
|
179
|
+
queries: queries
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TimeSeriesPanel, {
|
|
182
|
+
queries: queries
|
|
183
|
+
})
|
|
184
|
+
]
|
|
150
185
|
}),
|
|
151
|
-
tab ===
|
|
152
|
-
|
|
186
|
+
tab === 'finder' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
187
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PrometheusMetricsFinder.PrometheusMetricsFinder, {
|
|
188
|
+
onChange: (state)=>setData({
|
|
189
|
+
tab,
|
|
190
|
+
...state
|
|
191
|
+
}),
|
|
192
|
+
value: {
|
|
193
|
+
datasource,
|
|
194
|
+
filters,
|
|
195
|
+
exploredMetric
|
|
196
|
+
}
|
|
197
|
+
})
|
|
153
198
|
})
|
|
154
199
|
]
|
|
155
200
|
})
|
|
@@ -127,7 +127,7 @@ function TracingGanttChartPanel({ queries }) {
|
|
|
127
127
|
}
|
|
128
128
|
function TracesExplorer() {
|
|
129
129
|
var _queries_, _queries_1, _queries_2;
|
|
130
|
-
const { queries,
|
|
130
|
+
const { data: { queries = [] }, setData } = (0, _ExplorerManagerProvider.useExplorerManagerContext)();
|
|
131
131
|
// map TraceQueryDefinition to Definition<UnknownSpec>
|
|
132
132
|
const definitions = queries.length ? queries.map((query)=>{
|
|
133
133
|
return {
|
|
@@ -148,7 +148,9 @@ function TracesExplorer() {
|
|
|
148
148
|
queryTypes: [
|
|
149
149
|
'TraceQuery'
|
|
150
150
|
],
|
|
151
|
-
onChange:
|
|
151
|
+
onChange: (newQueries)=>setData({
|
|
152
|
+
queries: newQueries
|
|
153
|
+
}),
|
|
152
154
|
queries: queries
|
|
153
155
|
}),
|
|
154
156
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
explorerQueryConfig: function() {
|
|
25
|
+
return explorerQueryConfig;
|
|
26
|
+
},
|
|
27
|
+
useExplorerQueryParams: function() {
|
|
28
|
+
return useExplorerQueryParams;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _usequeryparams = require("use-query-params");
|
|
32
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
33
|
+
const _qs = require("qs");
|
|
34
|
+
const explorerQueryConfig = {
|
|
35
|
+
refresh: _pluginsystem.TimeRangeParam,
|
|
36
|
+
start: _pluginsystem.TimeRangeParam,
|
|
37
|
+
end: _pluginsystem.TimeRangeParam,
|
|
38
|
+
explorer: _usequeryparams.StringParam,
|
|
39
|
+
data: _usequeryparams.JsonParam
|
|
40
|
+
};
|
|
41
|
+
function useExplorerQueryParams(inputs) {
|
|
42
|
+
const [query] = (0, _usequeryparams.useQueryParams)(explorerQueryConfig, {
|
|
43
|
+
updateType: 'replaceIn'
|
|
44
|
+
});
|
|
45
|
+
return (0, _qs.stringify)((0, _usequeryparams.encodeQueryParams)(explorerQueryConfig, {
|
|
46
|
+
...query,
|
|
47
|
+
...inputs
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
MetricNameExplorer: function() {
|
|
25
|
+
return MetricNameExplorer;
|
|
26
|
+
},
|
|
27
|
+
PrometheusMetricsFinder: function() {
|
|
28
|
+
return PrometheusMetricsFinder;
|
|
29
|
+
},
|
|
30
|
+
SettingsMenu: function() {
|
|
31
|
+
return SettingsMenu;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
35
|
+
const _material = require("@mui/material");
|
|
36
|
+
const _prometheusplugin = require("@perses-dev/prometheus-plugin");
|
|
37
|
+
const _react = require("react");
|
|
38
|
+
const _ArrowLeft = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ArrowLeft"));
|
|
39
|
+
const _Cog = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Cog"));
|
|
40
|
+
const _reactrouterdom = require("react-router-dom");
|
|
41
|
+
const _queryparams = require("../ExploreManager/query-params");
|
|
42
|
+
const _FinderFilters = require("./filter/FinderFilters");
|
|
43
|
+
const _MetricList = require("./display/list/MetricList");
|
|
44
|
+
const _MetricOverview = require("./overview/MetricOverview");
|
|
45
|
+
const _utils = require("./utils");
|
|
46
|
+
function _interop_require_default(obj) {
|
|
47
|
+
return obj && obj.__esModule ? obj : {
|
|
48
|
+
default: obj
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const PERSES_METRICS_FINDER_SETTINGS = 'PERSES_METRICS_FINDER_SETTINGS';
|
|
52
|
+
function SettingsMenu({ value, onChange }) {
|
|
53
|
+
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
54
|
+
const open = Boolean(anchorEl);
|
|
55
|
+
const handleClick = (event)=>{
|
|
56
|
+
setAnchorEl(event.currentTarget);
|
|
57
|
+
};
|
|
58
|
+
const handleClose = ()=>{
|
|
59
|
+
setAnchorEl(null);
|
|
60
|
+
};
|
|
61
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
64
|
+
"aria-label": "settings",
|
|
65
|
+
size: "large",
|
|
66
|
+
onClick: handleClick,
|
|
67
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Cog.default, {})
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Menu, {
|
|
70
|
+
id: "finder-settings-menu",
|
|
71
|
+
anchorEl: anchorEl,
|
|
72
|
+
open: open,
|
|
73
|
+
onClose: handleClose,
|
|
74
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
75
|
+
onClick: (e)=>e.preventDefault(),
|
|
76
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
77
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {}),
|
|
78
|
+
label: "Enable Metadata",
|
|
79
|
+
checked: value.isMetadataEnabled,
|
|
80
|
+
onClick: ()=>onChange({
|
|
81
|
+
isMetadataEnabled: !value.isMetadataEnabled
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function MetricNameExplorer({ datasource, filters, isMetadataEnabled, onExplore, ...props }) {
|
|
90
|
+
const { data, isLoading } = (0, _utils.useLabelValues)('__name__', filters, datasource);
|
|
91
|
+
if (isLoading) {
|
|
92
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
93
|
+
width: "100%",
|
|
94
|
+
sx: {
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
justifyContent: 'center'
|
|
97
|
+
},
|
|
98
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
var _data_data;
|
|
102
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_MetricList.MetricList, {
|
|
103
|
+
metricNames: (_data_data = data === null || data === void 0 ? void 0 : data.data) !== null && _data_data !== void 0 ? _data_data : [],
|
|
104
|
+
datasource: datasource,
|
|
105
|
+
filters: filters,
|
|
106
|
+
isMetadataEnabled: isMetadataEnabled,
|
|
107
|
+
onExplore: onExplore,
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function PrometheusMetricsFinder({ value: { datasource = _prometheusplugin.DEFAULT_PROM, filters = [], exploredMetric }, onChange, onExplore, ...props }) {
|
|
112
|
+
const settingsStored = localStorage.getItem(PERSES_METRICS_FINDER_SETTINGS);
|
|
113
|
+
const [settings, setSettings] = (0, _react.useState)(settingsStored ? JSON.parse(settingsStored) : {
|
|
114
|
+
isMetadataEnabled: true
|
|
115
|
+
});
|
|
116
|
+
function handleSettingsUpdate(value) {
|
|
117
|
+
setSettings(value);
|
|
118
|
+
localStorage.setItem(PERSES_METRICS_FINDER_SETTINGS, JSON.stringify(value));
|
|
119
|
+
}
|
|
120
|
+
const isMobileSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.down('md'));
|
|
121
|
+
// Remove duplicated filters and filters without label or labelValues
|
|
122
|
+
const filteredFilters = (0, _react.useMemo)(()=>{
|
|
123
|
+
return filters.filter((filter)=>filter.label && filter.labelValues.length > 0);
|
|
124
|
+
}, [
|
|
125
|
+
filters
|
|
126
|
+
]);
|
|
127
|
+
const searchParams = (0, _queryparams.useExplorerQueryParams)({
|
|
128
|
+
data: {
|
|
129
|
+
tab: 'finder',
|
|
130
|
+
datasource,
|
|
131
|
+
filters,
|
|
132
|
+
exploredMetric: undefined
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
function setDatasource(value) {
|
|
136
|
+
onChange({
|
|
137
|
+
datasource: value,
|
|
138
|
+
filters,
|
|
139
|
+
exploredMetric
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function setFilters(value) {
|
|
143
|
+
onChange({
|
|
144
|
+
datasource,
|
|
145
|
+
filters: value,
|
|
146
|
+
exploredMetric
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
150
|
+
...props,
|
|
151
|
+
gap: 1,
|
|
152
|
+
children: [
|
|
153
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
154
|
+
direction: isMobileSize ? 'column' : 'row',
|
|
155
|
+
gap: 2,
|
|
156
|
+
justifyContent: "space-between",
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_FinderFilters.FinderFilters, {
|
|
159
|
+
datasource: datasource !== null && datasource !== void 0 ? datasource : _prometheusplugin.DEFAULT_PROM,
|
|
160
|
+
filters: filters !== null && filters !== void 0 ? filters : [],
|
|
161
|
+
filteredFilters: filteredFilters,
|
|
162
|
+
onDatasourceChange: setDatasource,
|
|
163
|
+
onFiltersChange: setFilters
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
166
|
+
direction: "row",
|
|
167
|
+
gap: 1,
|
|
168
|
+
alignItems: "center",
|
|
169
|
+
children: [
|
|
170
|
+
exploredMetric && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
171
|
+
variant: "contained",
|
|
172
|
+
"aria-label": "back to metric explorer",
|
|
173
|
+
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ArrowLeft.default, {}),
|
|
174
|
+
component: _reactrouterdom.Link,
|
|
175
|
+
to: `?${searchParams}`,
|
|
176
|
+
children: "Back"
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
179
|
+
direction: "row",
|
|
180
|
+
sx: {
|
|
181
|
+
width: isMobileSize ? '100%' : 'unset'
|
|
182
|
+
},
|
|
183
|
+
justifyContent: isMobileSize ? 'end' : 'unset',
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingsMenu, {
|
|
186
|
+
value: settings,
|
|
187
|
+
onChange: handleSettingsUpdate
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
}),
|
|
194
|
+
exploredMetric ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_MetricOverview.MetricOverview, {
|
|
195
|
+
metricName: exploredMetric,
|
|
196
|
+
datasource: datasource !== null && datasource !== void 0 ? datasource : _prometheusplugin.DEFAULT_PROM,
|
|
197
|
+
filters: filteredFilters,
|
|
198
|
+
isMetadataEnabled: settings.isMetadataEnabled,
|
|
199
|
+
onFiltersChange: setFilters,
|
|
200
|
+
onExplore: onExplore
|
|
201
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(MetricNameExplorer, {
|
|
202
|
+
datasource: datasource !== null && datasource !== void 0 ? datasource : _prometheusplugin.DEFAULT_PROM,
|
|
203
|
+
filters: filteredFilters,
|
|
204
|
+
isMetadataEnabled: settings.isMetadataEnabled,
|
|
205
|
+
onExplore: onExplore
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright 2024 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, "MetricChip", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return MetricChip;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
function MetricChip({ label, ...props }) {
|
|
26
|
+
if (label === 'gauge') {
|
|
27
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
28
|
+
label: label,
|
|
29
|
+
color: "success",
|
|
30
|
+
...props
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (label === 'counter') {
|
|
34
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
35
|
+
label: label,
|
|
36
|
+
color: "primary",
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (label === 'histogram') {
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
42
|
+
label: label,
|
|
43
|
+
color: "warning",
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (label === 'summary') {
|
|
48
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
49
|
+
label: label,
|
|
50
|
+
color: "secondary",
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
55
|
+
label: label,
|
|
56
|
+
sx: {
|
|
57
|
+
fontStyle: label === 'unknown' ? 'italic' : 'initial'
|
|
58
|
+
},
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|