mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
enable active search through dropped targets (#10668)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
2381d7be57
commit
0a30ac3f9b
|
@ -22,11 +22,16 @@ export interface TargetLabels {
|
|||
isDropped: boolean;
|
||||
}
|
||||
|
||||
const kvSearch = new KVSearch<Target>({
|
||||
const activeTargetKVSearch = new KVSearch<Target>({
|
||||
shouldSort: true,
|
||||
indexedKeys: ['labels', 'discoveredLabels', ['discoveredLabels', /.*/], ['labels', /.*/]],
|
||||
});
|
||||
|
||||
const droppedTargetKVSearch = new KVSearch<DroppedTarget>({
|
||||
shouldSort: true,
|
||||
indexedKeys: ['discoveredLabels', ['discoveredLabels', /.*/]],
|
||||
});
|
||||
|
||||
export const processSummary = (
|
||||
activeTargets: Target[],
|
||||
droppedTargets: DroppedTarget[]
|
||||
|
@ -91,6 +96,7 @@ export const processTargets = (activeTargets: Target[], droppedTargets: DroppedT
|
|||
|
||||
export const ServiceDiscoveryContent: FC<ServiceMap> = ({ activeTargets, droppedTargets }) => {
|
||||
const [activeTargetList, setActiveTargetList] = useState(activeTargets);
|
||||
const [droppedTargetList, setDroppedTargetList] = useState(droppedTargets);
|
||||
const [targetList, setTargetList] = useState(processSummary(activeTargets, droppedTargets));
|
||||
const [labelList, setLabelList] = useState(processTargets(activeTargets, droppedTargets));
|
||||
|
||||
|
@ -98,21 +104,23 @@ export const ServiceDiscoveryContent: FC<ServiceMap> = ({ activeTargets, dropped
|
|||
(value: string) => {
|
||||
setQuerySearchFilter(value);
|
||||
if (value !== '') {
|
||||
const result = kvSearch.filter(value.trim(), activeTargets);
|
||||
setActiveTargetList(result.map((value) => value.original));
|
||||
const activeTargetResult = activeTargetKVSearch.filter(value.trim(), activeTargets);
|
||||
const droppedTargetResult = droppedTargetKVSearch.filter(value.trim(), droppedTargets);
|
||||
setActiveTargetList(activeTargetResult.map((value) => value.original));
|
||||
setDroppedTargetList(droppedTargetResult.map((value) => value.original));
|
||||
} else {
|
||||
setActiveTargetList(activeTargets);
|
||||
}
|
||||
},
|
||||
[activeTargets]
|
||||
[activeTargets, droppedTargets]
|
||||
);
|
||||
|
||||
const defaultValue = useMemo(getQuerySearchFilter, []);
|
||||
|
||||
useEffect(() => {
|
||||
setTargetList(processSummary(activeTargetList, droppedTargets));
|
||||
setLabelList(processTargets(activeTargetList, droppedTargets));
|
||||
}, [activeTargetList, droppedTargets]);
|
||||
setTargetList(processSummary(activeTargetList, droppedTargetList));
|
||||
setLabelList(processTargets(activeTargetList, droppedTargetList));
|
||||
}, [activeTargetList, droppedTargetList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Reference in a new issue