The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/cloudwatch/Search.tsx

34 lines
1.0 KiB

import { debounce } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import { Icon, Input } from '@grafana/ui';
// TODO: consider moving search into grafana/ui, this is mostly the same as that in azure monitor
const Search = ({ searchFn, searchPhrase }: { searchPhrase: string; searchFn: (searchPhrase: string) => void }) => {
const [searchFilter, setSearchFilter] = useState(searchPhrase);
const debouncedSearch = useMemo(() => debounce(searchFn, 600), [searchFn]);
useEffect(() => {
return () => {
// Stop the invocation of the debounced function after unmounting
debouncedSearch?.cancel();
};
}, [debouncedSearch]);
return (
<Input
aria-label="log group search"
prefix={<Icon name="search" />}
value={searchFilter}
onChange={(event) => {
const searchPhrase = event.currentTarget.value;
setSearchFilter(searchPhrase);
debouncedSearch(searchPhrase);
}}
placeholder="search by log group name prefix"
/>
);
};
export default Search;