Skip to content

Commit

Permalink
Revert "[Backport 2.x][Feature] Support SQL direct query in Observabi…
Browse files Browse the repository at this point in the history
…lity (opensearch-project#988) (opensearch-project#1072)"

This reverts commit cefd57f.
  • Loading branch information
Swiddis committed Oct 5, 2023
1 parent cefd57f commit 7b674e4
Show file tree
Hide file tree
Showing 38 changed files with 423 additions and 1,919 deletions.
20 changes: 0 additions & 20 deletions common/constants/data_connections.ts

This file was deleted.

1 change: 0 additions & 1 deletion common/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const REDUX_EXPL_SLICE_QUERY_TABS = 'queryTabs';
export const REDUX_EXPL_SLICE_VISUALIZATION = 'explorerVisualization';
export const REDUX_EXPL_SLICE_COUNT_DISTRIBUTION = 'countDistributionVisualization';
export const REDUX_EXPL_SLICE_PATTERNS = 'patterns';
export const REDUX_EXPL_SLICE_SEARCH_META_DATA = 'searchMetaData';
export const PLOTLY_GAUGE_COLUMN_NUMBER = 4;
export const APP_ANALYTICS_TAB_ID_REGEX = /application-analytics-tab.+/;
export const DEFAULT_AVAILABILITY_QUERY = 'stats count() by span( timestamp, 1h )';
Expand Down
7 changes: 0 additions & 7 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const DSL_CAT = '/cat.indices';
export const DSL_MAPPING = '/indices.getFieldMapping';
export const OBSERVABILITY_BASE = '/api/observability';
export const INTEGRATIONS_BASE = '/api/integrations';
export const JOBS_BASE = '/query/jobs';
export const DATACONNECTIONS_BASE = '/api/dataconnections';
export const EVENT_ANALYTICS = '/event_analytics';
export const SAVED_OBJECTS = '/saved_objects';
export const SAVED_QUERY = '/query';
Expand All @@ -25,9 +23,6 @@ export const SAVED_VISUALIZATION = '/vis';
export const PPL_ENDPOINT = '/_plugins/_ppl';
export const SQL_ENDPOINT = '/_plugins/_sql';
export const DSL_ENDPOINT = '/_plugins/_dsl';
export const DATACONNECTIONS_ENDPOINT = '/_plugins/_query/_datasources';
export const JOBS_ENDPOINT_BASE = '/_plugins/_async_query';
export const JOB_RESULT_ENDPOINT = '/result';

export const observabilityID = 'observability-logs';
export const observabilityTitle = 'Observability';
Expand Down Expand Up @@ -232,5 +227,3 @@ export const VISUALIZATION_ERROR = {
NO_DATA: 'No data found.',
INVALID_DATA: 'Invalid visualization data',
};

export const S3_DATASOURCE_TYPE = 'S3_DATASOURCE';
2 changes: 0 additions & 2 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const App = ({
timestampUtils,
queryManager,
startPage,
dataSourcePluggables,
}: ObservabilityAppDeps) => {
const { chrome, http, notifications, savedObjects: coreSavedObjects } = CoreStartProp;
const parentBreadcrumb = {
Expand Down Expand Up @@ -86,7 +85,6 @@ export const App = ({
parentBreadcrumb={parentBreadcrumb}
parentBreadcrumbs={[parentBreadcrumb]}
setBreadcrumbs={chrome.setBreadcrumbs}
dataSourcePluggables={dataSourcePluggables}
/>
</MetricsListener>
</I18nProvider>
Expand Down
4 changes: 1 addition & 3 deletions public/components/common/search/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface AutocompleteProps extends IQueryBarProps {
placeholder?: string;
possibleCommands?: Array<{ label: string }>;
append?: any;
isSuggestionDisabled?: boolean;
}

export const Autocomplete = (props: AutocompleteProps) => {
Expand All @@ -46,7 +45,6 @@ export const Autocomplete = (props: AutocompleteProps) => {
placeholder = 'Enter PPL query',
possibleCommands,
append,
isSuggestionDisabled = false,
} = props;

const [autocompleteState, setAutocompleteState] = useState<AutocompleteState<AutocompleteItem>>({
Expand Down Expand Up @@ -145,7 +143,7 @@ export const Autocomplete = (props: AutocompleteProps) => {
{...(panelsFilter && { append, fullWidth: true })}
disabled={isDisabled}
/>
{autocompleteState.isOpen && !isSuggestionDisabled && (
{autocompleteState.isOpen && (
<div
className={[
'aa-Panel',
Expand Down
4 changes: 2 additions & 2 deletions public/components/common/search/search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { Search } from './search';

describe.skip('Search bar', () => {
describe('Search bar', () => {
it('handles query change', () => {
const query = 'rawQuery';
const tempQuery = 'rawQuery';
Expand Down Expand Up @@ -62,7 +62,7 @@ describe.skip('Search bar', () => {
popoverItems={popoverItems}
isLiveTailOn={isLiveTailOn}
countDistribution={countDistribution}
curVisId={'line'}
curVisId={'line'}
spanValue={false}
setSubType={'metric'}
setMetricMeasure={'hours (h)'}
Expand Down
104 changes: 7 additions & 97 deletions public/components/common/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import './search.scss';

import React, { useState, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { isEqual, lowerCase } from 'lodash';
import React, { useState } from 'react';
import { isEqual } from 'lodash';
import {
EuiFlexGroup,
EuiButton,
Expand All @@ -19,26 +18,16 @@ import {
EuiContextMenuPanel,
EuiToolTip,
EuiCallOut,
EuiComboBox,
} from '@elastic/eui';
import { DatePicker } from './date_picker';
import '@algolia/autocomplete-theme-classic';
import { Autocomplete } from './autocomplete';
import { SavePanel } from '../../event_analytics/explorer/save_panel';
import { PPLReferenceFlyout } from '../helpers';
import { uiSettingsService } from '../../../../common/utils';
import { APP_ANALYTICS_TAB_ID_REGEX, RAW_QUERY } from '../../../../common/constants/explorer';
import { APP_ANALYTICS_TAB_ID_REGEX } from '../../../../common/constants/explorer';
import { LiveTailButton, StopLiveButton } from '../live_tail/live_tail_button';
import { PPL_SPAN_REGEX } from '../../../../common/constants/shared';
import { coreRefs } from '../../../framework/core_refs';
import { useFetchEvents } from '../../../components/event_analytics/hooks';
import { SQLService } from '../../../services/requests/sql';
import {
selectSearchMetaData,
update as updateSearchMetaData,
} from '../../event_analytics/redux/slices/search_meta_data_slice';
import { usePolling } from '../../../components/hooks/use_polling';
import { changeQuery } from '../../../components/event_analytics/redux/slices/query_slice';
export interface IQueryBarProps {
query: string;
tempQuery: string;
Expand All @@ -63,6 +52,7 @@ export const Search = (props: any) => {
query,
tempQuery,
handleQueryChange,
handleQuerySearch,
handleTimePickerChange,
dslService,
startTime,
Expand Down Expand Up @@ -95,34 +85,11 @@ export const Search = (props: any) => {
liveTailName,
curVisId,
setSubType,
setIsQueryRunning,
} = props;

const explorerSearchMetadata = useSelector(selectSearchMetaData)[tabId];
const dispatch = useDispatch();
const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX);
const [isSavePanelOpen, setIsSavePanelOpen] = useState(false);
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const [queryLang, setQueryLang] = useState([]);
const [jobId, setJobId] = useState('');
const sqlService = new SQLService(coreRefs.http);
const { application } = coreRefs;

const {
data: pollingResult,
loading: pollingLoading,
error: pollingError,
startPolling,
stopPolling,
} = usePolling<any, any>((params) => {
return sqlService.fetchWithJobId(params);
}, 5000);

const requestParams = { tabId };
const { getLiveTail, getEvents, getAvailableFields, dispatchOnGettingHis } = useFetchEvents({
pplService: new SQLService(coreRefs.http),
requestParams,
});

const closeFlyout = () => {
setIsFlyoutVisible(false);
Expand Down Expand Up @@ -162,50 +129,6 @@ export const Search = (props: any) => {
/>
);

const handleQueryLanguageChange = (lang) => {
if (lang[0].label === 'DQL') {
return application.navigateToUrl(
`../app/data-explorer/discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${explorerSearchMetadata.datasources[0].value}',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_q=(filters:!(),query:(language:kuery,query:''))`
);
}
dispatch(
updateSearchMetaData({
tabId,
data: { lang: lang[0].label },
})
);
setQueryLang(lang);
};

const onQuerySearch = (lang) => {
handleTimeRangePickerRefresh();
};

useEffect(() => {
if (pollingResult && (pollingResult.status === 'SUCCESS' || pollingResult.datarows)) {
// update page with data
dispatchOnGettingHis(pollingResult, '');
// stop polling
stopPolling();
setIsQueryRunning(false);
}
}, [pollingResult, pollingError]);

useEffect(() => {
if (explorerSearchMetadata.datasources?.[0]?.type === 'DEFAULT_INDEX_PATTERNS') {
const queryWithSelectedSource = `source = ${explorerSearchMetadata.datasources[0].label}`;
handleQueryChange(queryWithSelectedSource);
dispatch(
changeQuery({
tabId,
query: {
[RAW_QUERY]: queryWithSelectedSource,
},
})
);
}
}, [explorerSearchMetadata.datasources]);

return (
<div className="globalQueryBar">
<EuiFlexGroup gutterSize="s" justifyContent="flexStart" alignItems="flexStart">
Expand All @@ -218,25 +141,14 @@ export const Search = (props: any) => {
</EuiToolTip>
</EuiFlexItem>
)}
<EuiFlexItem key="lang-selector" className="search-area" grow={1}>
<EuiComboBox
placeholder="No language selected yet"
options={[{ label: 'PPL' }, { label: 'DQL' }]}
selectedOptions={queryLang}
onChange={handleQueryLanguageChange}
singleSelection={{ asPlainText: true }}
/>
</EuiFlexItem>
<EuiFlexItem key="search-bar" className="search-area" grow={5}>
<EuiFlexItem key="search-bar" className="search-area">
<Autocomplete
key={'autocomplete-search-bar'}
query={query}
tempQuery={tempQuery}
baseQuery={baseQuery}
handleQueryChange={handleQueryChange}
handleQuerySearch={() => {
onQuerySearch(queryLang);
}}
handleQuerySearch={handleQuerySearch}
dslService={dslService}
getSuggestions={getSuggestions}
onItemSelect={onItemSelect}
Expand Down Expand Up @@ -266,9 +178,7 @@ export const Search = (props: any) => {
liveStreamChecked={props.liveStreamChecked}
onLiveStreamChange={props.onLiveStreamChange}
handleTimePickerChange={(timeRange: string[]) => handleTimePickerChange(timeRange)}
handleTimeRangePickerRefresh={() => {
onQuerySearch(queryLang);
}}
handleTimeRangePickerRefresh={handleTimeRangePickerRefresh}
/>
)}
</EuiFlexItem>
Expand Down
Loading

0 comments on commit 7b674e4

Please sign in to comment.