@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterInputs.d.ts","sourceRoot":"","sources":["../../../../src/components/PrometheusMetricsFinder/filter/FilterInputs.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,cAAc,EAMf,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAGD,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CAwBzG;AAGD,eAAO,MAAM,gBAAgB,+HAiC5B,CAAC;AAGF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,QAAQ,EACR,QAAQ,GACT,EAAE,mBAAmB,2CAqGrB"}
|
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { cloneElement, forwardRef, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import { Autocomplete, CircularProgress, IconButton, InputAdornment, TextField } from '@mui/material';
|
|
16
|
+
import CheckIcon from 'mdi-material-ui/Check';
|
|
17
|
+
import DeleteIcon from 'mdi-material-ui/Delete';
|
|
18
|
+
import { Virtuoso } from 'react-virtuoso';
|
|
19
|
+
import { useLabels, useLabelValues } from '../utils';
|
|
20
|
+
// TODO: fix when a filter is deleted => refresh data
|
|
21
|
+
export function LabelFilterInput({ datasource, value, filters, onChange, onDelete }) {
|
|
22
|
+
const filtersWithoutCurrent = useMemo(()=>filters.filter((filter)=>filter.label !== value.label), [
|
|
23
|
+
filters,
|
|
24
|
+
value.label
|
|
25
|
+
]);
|
|
26
|
+
const { data: labelOptions, isLoading: isLabelOptionsLoading } = useLabels(filtersWithoutCurrent, datasource);
|
|
27
|
+
const { data: labelValuesOptions, isLoading: isLabelValuesOptionsLoading } = useLabelValues(value.label, filtersWithoutCurrent, datasource);
|
|
28
|
+
var _labelOptions_data, _labelValuesOptions_data;
|
|
29
|
+
return /*#__PURE__*/ _jsx(RawFilterInput, {
|
|
30
|
+
value: value,
|
|
31
|
+
labelOptions: (_labelOptions_data = labelOptions === null || labelOptions === void 0 ? void 0 : labelOptions.data) !== null && _labelOptions_data !== void 0 ? _labelOptions_data : [],
|
|
32
|
+
labelValuesOptions: (_labelValuesOptions_data = labelValuesOptions === null || labelValuesOptions === void 0 ? void 0 : labelValuesOptions.data) !== null && _labelValuesOptions_data !== void 0 ? _labelValuesOptions_data : [],
|
|
33
|
+
isLabelOptionsLoading: isLabelOptionsLoading,
|
|
34
|
+
isLabelValuesOptionsLoading: isLabelValuesOptionsLoading,
|
|
35
|
+
onChange: onChange,
|
|
36
|
+
onDelete: onDelete
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// https://stackoverflow.com/questions/69060738/material-ui-autocomplete-virtualization-w-react-virtuoso
|
|
40
|
+
export const ListboxComponent = /*#__PURE__*/ forwardRef(({ children, ...rest }, ref)=>{
|
|
41
|
+
const data = children;
|
|
42
|
+
const localRef = useRef('500px');
|
|
43
|
+
const [height, setHeight] = useState(0);
|
|
44
|
+
return /*#__PURE__*/ _jsx("ul", {
|
|
45
|
+
style: {
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
padding: '0',
|
|
48
|
+
height: height ? `min(40vh, ${height}px)` : '40vh'
|
|
49
|
+
},
|
|
50
|
+
ref: (reference)=>{
|
|
51
|
+
const maxHeight = reference ? getComputedStyle(reference).maxHeight : null;
|
|
52
|
+
if (maxHeight && maxHeight !== localRef.current) {
|
|
53
|
+
localRef.current = maxHeight;
|
|
54
|
+
}
|
|
55
|
+
if (typeof ref === 'function') {
|
|
56
|
+
ref(reference);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
...rest,
|
|
60
|
+
children: /*#__PURE__*/ _jsx(Virtuoso, {
|
|
61
|
+
style: {
|
|
62
|
+
height: localRef.current,
|
|
63
|
+
padding: '10px 0'
|
|
64
|
+
},
|
|
65
|
+
data: data,
|
|
66
|
+
totalListHeightChanged: setHeight,
|
|
67
|
+
itemContent: (index, child)=>{
|
|
68
|
+
return /*#__PURE__*/ cloneElement(child, {
|
|
69
|
+
index,
|
|
70
|
+
title: child.props.children
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
ListboxComponent.displayName = 'ListboxComponent';
|
|
77
|
+
export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabelOptionsLoading, isLabelValuesOptionsLoading, onChange, onDelete }) {
|
|
78
|
+
const [isEditingLabelName, setIsEditingLabelName] = useState(value.labelValues.length === 0);
|
|
79
|
+
const [labelName, setLabelName] = useState(value.label);
|
|
80
|
+
function handleLabelConfirmation() {
|
|
81
|
+
setIsEditingLabelName(false);
|
|
82
|
+
onChange({
|
|
83
|
+
label: labelName,
|
|
84
|
+
labelValues: value.labelValues,
|
|
85
|
+
operator: value.operator
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function handleKeyPress(event) {
|
|
89
|
+
if (isEditingLabelName && event.key === 'Enter') {
|
|
90
|
+
handleLabelConfirmation();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ _jsx(Autocomplete, {
|
|
96
|
+
freeSolo: true,
|
|
97
|
+
disableClearable: true,
|
|
98
|
+
options: labelOptions !== null && labelOptions !== void 0 ? labelOptions : [],
|
|
99
|
+
value: value.label,
|
|
100
|
+
sx: {
|
|
101
|
+
minWidth: 250,
|
|
102
|
+
display: isEditingLabelName ? 'block' : 'none'
|
|
103
|
+
},
|
|
104
|
+
ListboxComponent: ListboxComponent,
|
|
105
|
+
loading: isLabelOptionsLoading,
|
|
106
|
+
renderInput: (params)=>{
|
|
107
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
108
|
+
...params,
|
|
109
|
+
label: "Label Name",
|
|
110
|
+
variant: "outlined",
|
|
111
|
+
fullWidth: true,
|
|
112
|
+
size: "medium",
|
|
113
|
+
InputProps: {
|
|
114
|
+
...params.InputProps,
|
|
115
|
+
endAdornment: /*#__PURE__*/ _jsxs(InputAdornment, {
|
|
116
|
+
position: "end",
|
|
117
|
+
children: [
|
|
118
|
+
isLabelOptionsLoading ? /*#__PURE__*/ _jsx(CircularProgress, {
|
|
119
|
+
color: "inherit",
|
|
120
|
+
size: 20
|
|
121
|
+
}) : null,
|
|
122
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
123
|
+
"aria-label": "validate label name",
|
|
124
|
+
onClick: ()=>handleLabelConfirmation(),
|
|
125
|
+
edge: "end",
|
|
126
|
+
children: /*#__PURE__*/ _jsx(CheckIcon, {})
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
onKeyDown: handleKeyPress,
|
|
134
|
+
onInputChange: (_, newValue)=>{
|
|
135
|
+
setLabelName(newValue !== null && newValue !== void 0 ? newValue : '');
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(Autocomplete, {
|
|
139
|
+
freeSolo: true,
|
|
140
|
+
multiple: value.operator === '=~' || value.operator === '!~',
|
|
141
|
+
limitTags: 1,
|
|
142
|
+
disableClearable: true,
|
|
143
|
+
options: labelValuesOptions !== null && labelValuesOptions !== void 0 ? labelValuesOptions : [],
|
|
144
|
+
value: value.labelValues,
|
|
145
|
+
ListboxComponent: ListboxComponent,
|
|
146
|
+
sx: {
|
|
147
|
+
minWidth: 250,
|
|
148
|
+
display: isEditingLabelName ? 'none' : 'block'
|
|
149
|
+
},
|
|
150
|
+
loading: isLabelValuesOptionsLoading,
|
|
151
|
+
renderInput: (params)=>{
|
|
152
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
153
|
+
...params,
|
|
154
|
+
label: value.label,
|
|
155
|
+
variant: "outlined",
|
|
156
|
+
fullWidth: true,
|
|
157
|
+
size: "medium",
|
|
158
|
+
InputProps: {
|
|
159
|
+
...params.InputProps,
|
|
160
|
+
startAdornment: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
161
|
+
children: [
|
|
162
|
+
/*#__PURE__*/ _jsx(InputAdornment, {
|
|
163
|
+
position: "start",
|
|
164
|
+
children: value.operator
|
|
165
|
+
}),
|
|
166
|
+
params.InputProps.startAdornment
|
|
167
|
+
]
|
|
168
|
+
}),
|
|
169
|
+
endAdornment: /*#__PURE__*/ _jsxs(InputAdornment, {
|
|
170
|
+
position: "end",
|
|
171
|
+
children: [
|
|
172
|
+
isLabelValuesOptionsLoading ? /*#__PURE__*/ _jsx(CircularProgress, {
|
|
173
|
+
color: "inherit",
|
|
174
|
+
size: 20
|
|
175
|
+
}) : null,
|
|
176
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
177
|
+
"aria-label": "delete label filter",
|
|
178
|
+
onClick: ()=>onDelete(),
|
|
179
|
+
edge: "end",
|
|
180
|
+
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
onChange: (_, newValue)=>{
|
|
188
|
+
if (typeof newValue === 'string') {
|
|
189
|
+
onChange({
|
|
190
|
+
label: value.label,
|
|
191
|
+
labelValues: [
|
|
192
|
+
newValue
|
|
193
|
+
],
|
|
194
|
+
operator: value.operator
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (Array.isArray(newValue)) {
|
|
198
|
+
onChange({
|
|
199
|
+
label: value.label,
|
|
200
|
+
labelValues: newValue,
|
|
201
|
+
operator: value.operator
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//# sourceMappingURL=FilterInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/PrometheusMetricsFinder/filter/FilterInputs.tsx"],"sourcesContent":["// Copyright 2024 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 {\n cloneElement,\n forwardRef,\n HTMLAttributes,\n ReactElement,\n SyntheticEvent,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Autocomplete, CircularProgress, IconButton, InputAdornment, TextField } from '@mui/material';\nimport CheckIcon from 'mdi-material-ui/Check';\nimport DeleteIcon from 'mdi-material-ui/Delete';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { Virtuoso } from 'react-virtuoso';\nimport { LabelFilter } from '../types';\nimport { useLabels, useLabelValues } from '../utils';\n\nexport interface LabelFilterInputProps {\n datasource: DatasourceSelector;\n value: LabelFilter;\n filters: LabelFilter[];\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\n// TODO: fix when a filter is deleted => refresh data\nexport function LabelFilterInput({ datasource, value, filters, onChange, onDelete }: LabelFilterInputProps) {\n const filtersWithoutCurrent = useMemo(\n () => filters.filter((filter) => filter.label !== value.label),\n [filters, value.label]\n );\n\n const { data: labelOptions, isLoading: isLabelOptionsLoading } = useLabels(filtersWithoutCurrent, datasource);\n const { data: labelValuesOptions, isLoading: isLabelValuesOptionsLoading } = useLabelValues(\n value.label,\n filtersWithoutCurrent,\n datasource\n );\n\n return (\n <RawFilterInput\n value={value}\n labelOptions={labelOptions?.data ?? []}\n labelValuesOptions={labelValuesOptions?.data ?? []}\n isLabelOptionsLoading={isLabelOptionsLoading}\n isLabelValuesOptionsLoading={isLabelValuesOptionsLoading}\n onChange={onChange}\n onDelete={onDelete}\n />\n );\n}\n\n// https://stackoverflow.com/questions/69060738/material-ui-autocomplete-virtualization-w-react-virtuoso\nexport const ListboxComponent = forwardRef<HTMLUListElement, HTMLAttributes<HTMLUListElement>>(\n ({ children, ...rest }, ref) => {\n const data = children as ReactElement[];\n const localRef = useRef<string>('500px');\n\n const [height, setHeight] = useState(0);\n\n return (\n <ul\n style={{ overflow: 'hidden', padding: '0', height: height ? `min(40vh, ${height}px)` : '40vh' }}\n ref={(reference) => {\n const maxHeight = reference ? getComputedStyle(reference).maxHeight : null;\n if (maxHeight && maxHeight !== localRef.current) {\n localRef.current = maxHeight;\n }\n\n if (typeof ref === 'function') {\n ref(reference);\n }\n }}\n {...rest}\n >\n <Virtuoso\n style={{ height: localRef.current, padding: '10px 0' }}\n data={data}\n totalListHeightChanged={setHeight}\n itemContent={(index, child) => {\n return cloneElement(child, { index, title: child.props.children });\n }}\n />\n </ul>\n );\n }\n);\nListboxComponent.displayName = 'ListboxComponent';\n\nexport interface RawFilterInputProps {\n value: LabelFilter;\n labelOptions?: string[];\n labelValuesOptions?: string[];\n isLabelOptionsLoading?: boolean;\n isLabelValuesOptionsLoading?: boolean;\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\nexport function RawFilterInput({\n value,\n labelOptions,\n labelValuesOptions,\n isLabelOptionsLoading,\n isLabelValuesOptionsLoading,\n onChange,\n onDelete,\n}: RawFilterInputProps) {\n const [isEditingLabelName, setIsEditingLabelName] = useState(value.labelValues.length === 0);\n const [labelName, setLabelName] = useState(value.label);\n\n function handleLabelConfirmation() {\n setIsEditingLabelName(false);\n onChange({ label: labelName, labelValues: value.labelValues, operator: value.operator });\n }\n\n function handleKeyPress(event: { key: string }) {\n if (isEditingLabelName && event.key === 'Enter') {\n handleLabelConfirmation();\n }\n }\n\n return (\n <>\n <Autocomplete\n freeSolo\n disableClearable\n options={labelOptions ?? []}\n value={value.label}\n sx={{ minWidth: 250, display: isEditingLabelName ? 'block' : 'none' }}\n ListboxComponent={ListboxComponent}\n loading={isLabelOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label=\"Label Name\"\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <InputAdornment position=\"end\">\n {isLabelOptionsLoading ? <CircularProgress color=\"inherit\" size={20} /> : null}\n <IconButton aria-label=\"validate label name\" onClick={() => handleLabelConfirmation()} edge=\"end\">\n <CheckIcon />\n </IconButton>\n </InputAdornment>\n ),\n }}\n />\n );\n }}\n onKeyDown={handleKeyPress}\n onInputChange={(_: SyntheticEvent, newValue: string | null) => {\n setLabelName(newValue ?? '');\n }}\n />\n <Autocomplete\n freeSolo\n multiple={value.operator === '=~' || value.operator === '!~'}\n limitTags={1}\n disableClearable\n options={labelValuesOptions ?? []}\n value={value.labelValues}\n ListboxComponent={ListboxComponent}\n sx={{ minWidth: 250, display: isEditingLabelName ? 'none' : 'block' }}\n loading={isLabelValuesOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label={value.label}\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <>\n <InputAdornment position=\"start\">{value.operator}</InputAdornment>\n {params.InputProps.startAdornment}\n </>\n ),\n endAdornment: (\n <InputAdornment position=\"end\">\n {isLabelValuesOptionsLoading ? <CircularProgress color=\"inherit\" size={20} /> : null}\n <IconButton aria-label=\"delete label filter\" onClick={() => onDelete()} edge=\"end\">\n <DeleteIcon />\n </IconButton>\n </InputAdornment>\n ),\n }}\n />\n );\n }}\n onChange={(_: SyntheticEvent, newValue: string[] | string | null) => {\n if (typeof newValue === 'string') {\n onChange({ label: value.label, labelValues: [newValue], operator: value.operator });\n }\n if (Array.isArray(newValue)) {\n onChange({ label: value.label, labelValues: newValue, operator: value.operator });\n }\n }}\n />\n </>\n );\n}\n"],"names":["cloneElement","forwardRef","useMemo","useRef","useState","Autocomplete","CircularProgress","IconButton","InputAdornment","TextField","CheckIcon","DeleteIcon","Virtuoso","useLabels","useLabelValues","LabelFilterInput","datasource","value","filters","onChange","onDelete","filtersWithoutCurrent","filter","label","data","labelOptions","isLoading","isLabelOptionsLoading","labelValuesOptions","isLabelValuesOptionsLoading","RawFilterInput","ListboxComponent","children","rest","ref","localRef","height","setHeight","ul","style","overflow","padding","reference","maxHeight","getComputedStyle","current","totalListHeightChanged","itemContent","index","child","title","props","displayName","isEditingLabelName","setIsEditingLabelName","labelValues","length","labelName","setLabelName","handleLabelConfirmation","operator","handleKeyPress","event","key","freeSolo","disableClearable","options","sx","minWidth","display","loading","renderInput","params","variant","fullWidth","size","InputProps","endAdornment","position","color","aria-label","onClick","edge","onKeyDown","onInputChange","_","newValue","multiple","limitTags","startAdornment","Array","isArray"],"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,SACEA,YAAY,EACZC,UAAU,EAIVC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,cAAc,EAAEC,SAAS,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,gBAAgB,yBAA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wBAIT;;gBAGN;gBACAQ,UAAU,CAACkE,GAAmBC;oBAC5B,IAAI,OAAOA,aAAa,UAAU;wBAChCnE,SAAS;4BAAEI,OAAON,MAAMM,KAAK;4BAAEgC,aAAa;gCAAC+B;6BAAS;4BAAE1B,UAAU3C,MAAM2C,QAAQ;wBAAC;oBACnF;oBACA,IAAI8B,MAAMC,OAAO,CAACL,WAAW;wBAC3BnE,SAAS;4BAAEI,OAAON,MAAMM,KAAK;4BAAEgC,aAAa+B;4BAAU1B,UAAU3C,MAAM2C,QAAQ;wBAAC;oBACjF;gBACF;;;;AAIR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StackProps } from '@mui/material';
|
|
2
|
+
import { DatasourceSelector } from '@perses-dev/core';
|
|
3
|
+
import { LabelFilter } from '../types';
|
|
4
|
+
export interface ExplorerFiltersProps extends StackProps {
|
|
5
|
+
datasource: DatasourceSelector;
|
|
6
|
+
filters: LabelFilter[];
|
|
7
|
+
filteredFilters: LabelFilter[];
|
|
8
|
+
onDatasourceChange: (next: DatasourceSelector) => void;
|
|
9
|
+
onFiltersChange: (next: LabelFilter[]) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function FinderFilters({ datasource, filters, filteredFilters, onDatasourceChange, onFiltersChange, ...props }: ExplorerFiltersProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=FinderFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FinderFilters.d.ts","sourceRoot":"","sources":["../../../../src/components/PrometheusMetricsFinder/filter/FinderFilters.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0C,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKtD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,EAAE,WAAW,EAAE,CAAC;IAC/B,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACvD,eAAe,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;CAChD;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,GAAG,KAAK,EACT,EAAE,oBAAoB,2CA6CtB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Button, FormControl, InputLabel, Stack } from '@mui/material';
|
|
15
|
+
import { DatasourceSelect } from '@perses-dev/plugin-system';
|
|
16
|
+
import { PROM_DATASOURCE_KIND } from '@perses-dev/prometheus-plugin';
|
|
17
|
+
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { LabelFilterInput } from './FilterInputs';
|
|
20
|
+
export function FinderFilters({ datasource, filters, filteredFilters, onDatasourceChange, onFiltersChange, ...props }) {
|
|
21
|
+
function handleDatasourceChange(next) {
|
|
22
|
+
onDatasourceChange(next);
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
25
|
+
...props,
|
|
26
|
+
direction: "row",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
flexWrap: "wrap",
|
|
29
|
+
gap: 1,
|
|
30
|
+
sx: {
|
|
31
|
+
width: '100%'
|
|
32
|
+
},
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
37
|
+
children: "Prometheus Datasource"
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
40
|
+
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
41
|
+
value: datasource,
|
|
42
|
+
onChange: handleDatasourceChange,
|
|
43
|
+
label: "Prometheus Datasource"
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
}),
|
|
47
|
+
filters.map((filter, index)=>/*#__PURE__*/ _jsx(LabelFilterInput, {
|
|
48
|
+
datasource: datasource,
|
|
49
|
+
filters: filteredFilters,
|
|
50
|
+
value: filter,
|
|
51
|
+
onChange: (next)=>{
|
|
52
|
+
const nextFilters = [
|
|
53
|
+
...filters
|
|
54
|
+
];
|
|
55
|
+
nextFilters[index] = next;
|
|
56
|
+
onFiltersChange(nextFilters);
|
|
57
|
+
},
|
|
58
|
+
onDelete: ()=>{
|
|
59
|
+
const nextFilters = [
|
|
60
|
+
...filters
|
|
61
|
+
];
|
|
62
|
+
nextFilters.splice(index, 1);
|
|
63
|
+
onFiltersChange(nextFilters);
|
|
64
|
+
}
|
|
65
|
+
}, index)),
|
|
66
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
67
|
+
startIcon: /*#__PURE__*/ _jsx(PlusIcon, {}),
|
|
68
|
+
"aria-label": "add filter",
|
|
69
|
+
onClick: ()=>{
|
|
70
|
+
onFiltersChange([
|
|
71
|
+
...filters,
|
|
72
|
+
{
|
|
73
|
+
label: '',
|
|
74
|
+
labelValues: [],
|
|
75
|
+
operator: '=~'
|
|
76
|
+
}
|
|
77
|
+
]);
|
|
78
|
+
},
|
|
79
|
+
children: "Add filter"
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=FinderFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/PrometheusMetricsFinder/filter/FinderFilters.tsx"],"sourcesContent":["// Copyright 2024 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 { Button, FormControl, InputLabel, Stack, StackProps } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceSelect } from '@perses-dev/plugin-system';\nimport { PROM_DATASOURCE_KIND } from '@perses-dev/prometheus-plugin';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport * as React from 'react';\nimport { LabelFilter } from '../types';\nimport { LabelFilterInput } from './FilterInputs';\n\nexport interface ExplorerFiltersProps extends StackProps {\n datasource: DatasourceSelector;\n filters: LabelFilter[];\n filteredFilters: LabelFilter[];\n onDatasourceChange: (next: DatasourceSelector) => void;\n onFiltersChange: (next: LabelFilter[]) => void;\n}\n\nexport function FinderFilters({\n datasource,\n filters,\n filteredFilters,\n onDatasourceChange,\n onFiltersChange,\n ...props\n}: ExplorerFiltersProps) {\n function handleDatasourceChange(next: DatasourceSelector) {\n onDatasourceChange(next);\n }\n\n return (\n <Stack {...props} direction=\"row\" alignItems=\"center\" flexWrap=\"wrap\" gap={1} sx={{ width: '100%' }}>\n <FormControl>\n <InputLabel>Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasource}\n onChange={handleDatasourceChange}\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n {filters.map((filter, index) => (\n <LabelFilterInput\n key={index}\n datasource={datasource}\n filters={filteredFilters}\n value={filter}\n onChange={(next) => {\n const nextFilters = [...filters];\n nextFilters[index] = next;\n onFiltersChange(nextFilters);\n }}\n onDelete={() => {\n const nextFilters = [...filters];\n nextFilters.splice(index, 1);\n onFiltersChange(nextFilters);\n }}\n />\n ))}\n <Button\n startIcon={<PlusIcon />}\n aria-label=\"add filter\"\n onClick={() => {\n onFiltersChange([...filters, { label: '', labelValues: [], operator: '=~' }]);\n }}\n >\n Add filter\n </Button>\n </Stack>\n );\n}\n"],"names":["Button","FormControl","InputLabel","Stack","DatasourceSelect","PROM_DATASOURCE_KIND","PlusIcon","React","LabelFilterInput","FinderFilters","datasource","filters","filteredFilters","onDatasourceChange","onFiltersChange","props","handleDatasourceChange","next","direction","alignItems","flexWrap","gap","sx","width","datasourcePluginKind","value","onChange","label","map","filter","index","nextFilters","onDelete","splice","startIcon","aria-label","onClick","labelValues","operator"],"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,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,KAAK,QAAoB,gBAAgB;AAEnF,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,OAAOC,cAAc,uBAAuB;AAC5C,YAAYC,WAAW,QAAQ;AAE/B,SAASC,gBAAgB,QAAQ,iBAAiB;AAUlD,OAAO,SAASC,cAAc,EAC5BC,UAAU,EACVC,OAAO,EACPC,eAAe,EACfC,kBAAkB,EAClBC,eAAe,EACf,GAAGC,OACkB;IACrB,SAASC,uBAAuBC,IAAwB;QACtDJ,mBAAmBI;IACrB;IAEA,qBACE,MAACd;QAAO,GAAGY,KAAK;QAAEG,WAAU;QAAMC,YAAW;QAASC,UAAS;QAAOC,KAAK;QAAGC,IAAI;YAAEC,OAAO;QAAO;;0BAChG,MAACtB;;kCACC,KAACC;kCAAW;;kCACZ,KAACE;wBACCoB,sBAAsBnB;wBACtBoB,OAAOf;wBACPgB,UAAUV;wBACVW,OAAM;;;;YAGThB,QAAQiB,GAAG,CAAC,CAACC,QAAQC,sBACpB,KAACtB;oBAECE,YAAYA;oBACZC,SAASC;oBACTa,OAAOI;oBACPH,UAAU,CAACT;wBACT,MAAMc,cAAc;+BAAIpB;yBAAQ;wBAChCoB,WAAW,CAACD,MAAM,GAAGb;wBACrBH,gBAAgBiB;oBAClB;oBACAC,UAAU;wBACR,MAAMD,cAAc;+BAAIpB;yBAAQ;wBAChCoB,YAAYE,MAAM,CAACH,OAAO;wBAC1BhB,gBAAgBiB;oBAClB;mBAbKD;0BAgBT,KAAC9B;gBACCkC,yBAAW,KAAC5B;gBACZ6B,cAAW;gBACXC,SAAS;oBACPtB,gBAAgB;2BAAIH;wBAAS;4BAAEgB,OAAO;4BAAIU,aAAa,EAAE;4BAAEC,UAAU;wBAAK;qBAAE;gBAC9E;0BACD;;;;AAKP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PrometheusMetricsFinder/index.ts"],"names":[],"mappings":"AAaA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from './PrometheusMetricsFinder';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PrometheusMetricsFinder/index.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\nexport * from './PrometheusMetricsFinder';\n"],"names":[],"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,cAAc,4BAA4B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StackProps } from '@mui/material';
|
|
2
|
+
import { DatasourceSelector } from '@perses-dev/core';
|
|
3
|
+
import { LabelFilter } from '../types';
|
|
4
|
+
export interface OverviewPanelProps extends StackProps {
|
|
5
|
+
metricName: string;
|
|
6
|
+
datasource: DatasourceSelector;
|
|
7
|
+
filters: LabelFilter[];
|
|
8
|
+
type?: string;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function OverviewPanel({ metricName, datasource, filters, type, isLoading, ...props }: OverviewPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export interface MetricOverviewProps extends StackProps {
|
|
13
|
+
metricName: string;
|
|
14
|
+
datasource: DatasourceSelector;
|
|
15
|
+
filters: LabelFilter[];
|
|
16
|
+
isMetadataEnabled?: boolean;
|
|
17
|
+
onExplore?: (metricName: string) => void;
|
|
18
|
+
onFiltersChange: (filters: LabelFilter[]) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function MetricOverview({ metricName, datasource, filters, isMetadataEnabled, onExplore, onFiltersChange, ...props }: MetricOverviewProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=MetricOverview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricOverview.d.ts","sourceRoot":"","sources":["../../../../src/components/PrometheusMetricsFinder/overview/MetricOverview.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA+C,UAAU,EAAsB,MAAM,eAAe,CAAC;AAE5G,OAAO,EAAE,kBAAkB,EAA4C,MAAM,kBAAkB,CAAC;AAKhG,OAAO,EAAqB,WAAW,EAAE,MAAM,UAAU,CAAC;AAM1D,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CAyE/G;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;CACnD;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,GAAG,KAAK,EACT,EAAE,mBAAmB,2CAqFrB"}
|
|
@@ -0,0 +1,214 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Checkbox, FormControlLabel, Skeleton, Stack, Tab, Tabs, Tooltip } from '@mui/material';
|
|
15
|
+
import { useMemo, useState } from 'react';
|
|
16
|
+
import { Panel } from '@perses-dev/dashboards';
|
|
17
|
+
import useResizeObserver from 'use-resize-observer';
|
|
18
|
+
import { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';
|
|
19
|
+
import HelpCircleOutlineIcon from 'mdi-material-ui/HelpCircleOutline';
|
|
20
|
+
import { computeFilterExpr } from '../types';
|
|
21
|
+
import { useMetricMetadata } from '../utils';
|
|
22
|
+
import { OverviewTab } from './tabs/OverviewTab';
|
|
23
|
+
import { JobTab } from './tabs/JobTab';
|
|
24
|
+
import { SimilarTab } from './tabs/SimilarTab';
|
|
25
|
+
export function OverviewPanel({ metricName, datasource, filters, type, isLoading, ...props }) {
|
|
26
|
+
const { width, ref: panelRef } = useResizeObserver();
|
|
27
|
+
const suggestedStepMs = useSuggestedStepMs(width);
|
|
28
|
+
const [rateEnabled, setRateEnabled] = useState(true);
|
|
29
|
+
const { queries, definitions } = useMemo(()=>{
|
|
30
|
+
const expr = type === 'counter' || rateEnabled && (type === undefined || type === 'summary' || type === 'histogram') ? `rate({__name__="${metricName}", ${computeFilterExpr(filters)}}[5m])` : `{__name__="${metricName}", ${computeFilterExpr(filters)}}`;
|
|
31
|
+
const queries = [
|
|
32
|
+
{
|
|
33
|
+
kind: 'TimeSeriesQuery',
|
|
34
|
+
spec: {
|
|
35
|
+
plugin: {
|
|
36
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
37
|
+
spec: {
|
|
38
|
+
datasource: datasource,
|
|
39
|
+
query: expr
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
const definitions = queries.map((query)=>{
|
|
46
|
+
return {
|
|
47
|
+
kind: query.spec.plugin.kind,
|
|
48
|
+
spec: query.spec.plugin.spec
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
queries,
|
|
53
|
+
definitions
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
datasource,
|
|
57
|
+
filters,
|
|
58
|
+
metricName,
|
|
59
|
+
rateEnabled,
|
|
60
|
+
type
|
|
61
|
+
]);
|
|
62
|
+
if (isLoading) {
|
|
63
|
+
return /*#__PURE__*/ _jsx(Stack, {
|
|
64
|
+
...props,
|
|
65
|
+
children: /*#__PURE__*/ _jsx(Skeleton, {
|
|
66
|
+
variant: "rectangular",
|
|
67
|
+
height: "100%"
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
72
|
+
ref: panelRef,
|
|
73
|
+
alignItems: "end",
|
|
74
|
+
...props,
|
|
75
|
+
children: [
|
|
76
|
+
(type === undefined || type === 'summary' || type === 'histogram') && /*#__PURE__*/ _jsx(FormControlLabel, {
|
|
77
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
78
|
+
size: "small"
|
|
79
|
+
}),
|
|
80
|
+
label: "Enable rate",
|
|
81
|
+
checked: rateEnabled,
|
|
82
|
+
onChange: (_, checked)=>setRateEnabled(checked)
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
85
|
+
definitions: definitions,
|
|
86
|
+
options: {
|
|
87
|
+
suggestedStepMs,
|
|
88
|
+
mode: 'range'
|
|
89
|
+
},
|
|
90
|
+
children: /*#__PURE__*/ _jsx(Panel, {
|
|
91
|
+
panelOptions: {
|
|
92
|
+
hideHeader: true
|
|
93
|
+
},
|
|
94
|
+
definition: {
|
|
95
|
+
kind: 'Panel',
|
|
96
|
+
spec: {
|
|
97
|
+
queries: queries,
|
|
98
|
+
display: {
|
|
99
|
+
name: ''
|
|
100
|
+
},
|
|
101
|
+
plugin: {
|
|
102
|
+
kind: 'TimeSeriesChart',
|
|
103
|
+
spec: {}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function MetricOverview({ metricName, datasource, filters, isMetadataEnabled, onExplore, onFiltersChange, ...props }) {
|
|
113
|
+
const [tab, setTab] = useState(0);
|
|
114
|
+
const { metadata, isLoading: isMetadataLoading } = useMetricMetadata(metricName, datasource);
|
|
115
|
+
const filtersWithMetricName = useMemo(()=>{
|
|
116
|
+
const result = filters.filter((filter)=>filter.label !== '__name__');
|
|
117
|
+
result.push({
|
|
118
|
+
label: '__name__',
|
|
119
|
+
labelValues: [
|
|
120
|
+
metricName
|
|
121
|
+
],
|
|
122
|
+
operator: '='
|
|
123
|
+
});
|
|
124
|
+
return result;
|
|
125
|
+
}, [
|
|
126
|
+
filters,
|
|
127
|
+
metricName
|
|
128
|
+
]);
|
|
129
|
+
function handleFilterAdd(filter) {
|
|
130
|
+
onFiltersChange([
|
|
131
|
+
...filters,
|
|
132
|
+
filter
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
135
|
+
function handleExplore(metricName, tab) {
|
|
136
|
+
onExplore === null || onExplore === void 0 ? void 0 : onExplore(metricName);
|
|
137
|
+
if (tab !== undefined) {
|
|
138
|
+
setTab(tab);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
142
|
+
sx: {
|
|
143
|
+
width: '100%'
|
|
144
|
+
},
|
|
145
|
+
...props,
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ _jsx(OverviewPanel, {
|
|
148
|
+
metricName: metricName,
|
|
149
|
+
filters: filters,
|
|
150
|
+
datasource: datasource,
|
|
151
|
+
type: metadata === null || metadata === void 0 ? void 0 : metadata.type,
|
|
152
|
+
height: "250px",
|
|
153
|
+
isLoading: isMetadataEnabled && isMetadataLoading
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ _jsxs(Tabs, {
|
|
156
|
+
value: tab,
|
|
157
|
+
onChange: (_, state)=>setTab(state),
|
|
158
|
+
variant: "scrollable",
|
|
159
|
+
sx: {
|
|
160
|
+
borderBottom: 1,
|
|
161
|
+
borderColor: 'divider'
|
|
162
|
+
},
|
|
163
|
+
children: [
|
|
164
|
+
/*#__PURE__*/ _jsx(Tab, {
|
|
165
|
+
label: "Overview"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ _jsx(Tab, {
|
|
168
|
+
label: "Job related metrics",
|
|
169
|
+
icon: /*#__PURE__*/ _jsx(Tooltip, {
|
|
170
|
+
title: "All metrics scraped from the same job",
|
|
171
|
+
placement: "top",
|
|
172
|
+
children: /*#__PURE__*/ _jsx(HelpCircleOutlineIcon, {})
|
|
173
|
+
}),
|
|
174
|
+
iconPosition: "end"
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ _jsx(Tab, {
|
|
177
|
+
label: "Similar metrics",
|
|
178
|
+
icon: /*#__PURE__*/ _jsx(Tooltip, {
|
|
179
|
+
title: "All metrics matching current filters",
|
|
180
|
+
placement: "top",
|
|
181
|
+
children: /*#__PURE__*/ _jsx(HelpCircleOutlineIcon, {})
|
|
182
|
+
}),
|
|
183
|
+
iconPosition: "end"
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
}),
|
|
187
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
188
|
+
gap: 1,
|
|
189
|
+
children: [
|
|
190
|
+
tab === 0 && /*#__PURE__*/ _jsx(OverviewTab, {
|
|
191
|
+
metricName: metricName,
|
|
192
|
+
datasource: datasource,
|
|
193
|
+
filters: filtersWithMetricName,
|
|
194
|
+
onFilterAdd: handleFilterAdd
|
|
195
|
+
}),
|
|
196
|
+
tab === 1 && /*#__PURE__*/ _jsx(JobTab, {
|
|
197
|
+
filters: filtersWithMetricName,
|
|
198
|
+
datasource: datasource,
|
|
199
|
+
isMetadataEnabled: isMetadataEnabled,
|
|
200
|
+
onExplore: (metricName)=>handleExplore(metricName, 0)
|
|
201
|
+
}),
|
|
202
|
+
tab === 2 && /*#__PURE__*/ _jsx(SimilarTab, {
|
|
203
|
+
filters: filtersWithMetricName,
|
|
204
|
+
datasource: datasource,
|
|
205
|
+
isMetadataEnabled: isMetadataEnabled,
|
|
206
|
+
onExplore: (metricName)=>handleExplore(metricName, 0)
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
//# sourceMappingURL=MetricOverview.js.map
|