Skip to content

Commit

Permalink
Merge Application Analytics into main (#454)
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Lee <[email protected]>
  • Loading branch information
eugenesk24 authored Feb 15, 2022
1 parent 3a6942d commit 08b84c8
Show file tree
Hide file tree
Showing 98 changed files with 29,101 additions and 2,082 deletions.
19 changes: 19 additions & 0 deletions dashboards-observability/common/constants/application_analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const TAB_OVERVIEW_ID_TXT_PFX = 'app-analytics-overview-';
export const TAB_SERVICE_ID_TXT_PFX = 'app-analytics-service-';
export const TAB_TRACE_ID_TXT_PFX = 'app-analytics-trace-';
export const TAB_LOG_ID_TXT_PFX = 'app-analytics-log-';
export const TAB_PANEL_ID_TXT_PFX = 'app-analytics-panel-'
export const TAB_CONFIG_ID_TXT_PFX = 'app-analytics-config-';
export const TAB_OVERVIEW_TITLE = 'Overview';
export const TAB_SERVICE_TITLE = 'Services';
export const TAB_TRACE_TITLE = 'Traces & Spans';
export const TAB_LOG_TITLE = 'Log Events';
export const TAB_PANEL_TITLE = 'Panels';
export const TAB_CONFIG_TITLE = 'Configuration';

export const APP_ANALYTICS_API_PREFIX = '/api/observability/application';
122 changes: 78 additions & 44 deletions dashboards-observability/common/constants/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,95 @@
export const firstCommand = [{ label: 'source' }];

export const pipeCommands = [
{ label: 'dedup' },
{ label: 'eval' },
{ label: 'fields' },
{ label: 'head' },
{ label: 'parse' },
{ label: 'rare' },
{ label: 'rename' },
{ label: 'sort' },
{ label: 'stats' },
{ label: 'top' },
{ label: 'where' },
{ label: 'dedup' },
{ label: 'eval' },
{ label: 'fields' },
{ label: 'head' },
{ label: 'rare' },
{ label: 'rename' },
{ label: 'sort' },
{ label: 'stats' },
{ label: 'top' },
{ label: 'where' },
];

export const statsCommands = [
{ label: 'count()' },
{ label: 'sum(' },
{ label: 'avg(' },
{ label: 'max(' },
{ label: 'min(' },
{ label: 'var_samp(' },
{ label: 'var_pop(' },
{ label: 'stddev_samp(' },
{ label: 'stddev_pop(' },
{ label: 'count()' },
{ label: 'sum(' },
{ label: 'avg(' },
{ label: 'max(' },
{ label: 'min(' },
{ label: 'var_samp(' },
{ label: 'var_pop(' },
{ label: 'stddev_samp(' },
{ label: 'stddev_pop(' },
];

export const numberTypes = [
'long',
'integer',
'short',
'byte',
'double',
'float',
'half_float',
'scaled_float',
'unsigned_long'
'long',
'integer',
'short',
'byte',
'double',
'float',
'half_float',
'scaled_float',
'unsigned_long',
];

export type AutocompleteItem = {
input: string;
itemName: string;
label: string;
suggestion: string;
__autocomplete_id?: number;
};
export interface AutocompleteItem {
input: string;
itemName: string;
label: string;
suggestion: string;
__autocomplete_id?: number;
}

export type fieldItem = {
label: string;
type: string;
export interface FieldItem {
label: string;
type: string;
}

export type indexItem = {
label: string;
export interface IndexItem {
label: string;
}

export type dataItem = {
label: string;
doc_count: any;
export interface DataItem {
label: string;
doc_count: any;
}

const JUST_SOURCE_REGEX = new RegExp('source = (\\S+)');
const SOURCE_WHERE_REGEX = new RegExp('source = (\\S+) \\| where \\S+ = \\S+');
const SOURCE_MATCH_REGEX = new RegExp('source = (\\S+) \\| where match\\(\\S+, \\S+\\)');
export const EMPTY_REGEX = new RegExp('\\s+');
export const MATCH_FIELD_AFTER_WHERE = new RegExp('\\s*where\\s*\\S*');
export const EQUAL_AFTER_FIELD = new RegExp('\\s*where\\s*(\\S+)\\s+');
export const DATA_AFTER_EQUAL = new RegExp('\\s*where\\s*\\S+\\s*=\\s*\\S*');
export const PIPE_AFTER_WHERE = new RegExp('\\s*where\\s*\\S+\\s*=\\s*\\S+\\s+');
export const FIELD_AFTER_MATCH = new RegExp('\\s*where\\s*match\\(\\s*\\S*');
export const COMMA_AFTER_FIELD = new RegExp('\\s*where\\s*match\\(\\s*(\\S+)\\s+');
export const DATA_AFTER_COMMA = new RegExp('\\s*where\\s*match\\(\\s*\\S+\\s*,\\s*');
export const CLOSE_AFTER_DATA = new RegExp('\\s*where\\s*match\\(\\s*\\S+\\s*,\\s*\\S+\\s+');
export const PIPE_AFTER_MATCH = new RegExp(
'\\s*where\\s*match\\(\\s*\\S+\\s*,\\s*\\S+\\s*\\S+\\s*\\)\\s*'
);
export const FIELD_AFTER_DEDUP = new RegExp('\\s*dedup\\s*\\S*');
export const PIPE_AFTER_FIELD = new RegExp('\\s*dedup\\s*\\S+\\s+');

export const regexForSuggestion = [
PIPE_AFTER_FIELD,
FIELD_AFTER_DEDUP,
PIPE_AFTER_MATCH,
CLOSE_AFTER_DATA,
DATA_AFTER_COMMA,
COMMA_AFTER_FIELD,
FIELD_AFTER_MATCH,
PIPE_AFTER_WHERE,
DATA_AFTER_EQUAL,
EQUAL_AFTER_FIELD,
MATCH_FIELD_AFTER_WHERE,
EMPTY_REGEX,
];

export const regexForIndex = [JUST_SOURCE_REGEX, SOURCE_WHERE_REGEX, SOURCE_MATCH_REGEX];
10 changes: 6 additions & 4 deletions dashboards-observability/common/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

export const EVENT_ANALYTICS_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest/observability/event-analytics/'
export const EVENT_ANALYTICS_DOCUMENTATION_URL =
'https://opensearch.org/docs/latest/observability/event-analytics/';
export const RAW_QUERY = 'rawQuery';
export const FINAL_QUERY = 'finalQuery';
export const SELECTED_DATE_RANGE = 'selectedDateRange';
Expand All @@ -19,6 +20,8 @@ export const TAB_CHART_TITLE = 'Visualizations';
export const TAB_EVENT_TITLE = 'Events';
export const TAB_EVENT_ID_TXT_PFX = 'main-content-events-';
export const TAB_CHART_ID_TXT_PFX = 'main-content-vis-';
export const TAB_EVENT_ID = 'main-content-events';
export const TAB_CHART_ID = 'main-content-vis';
export const HAS_SAVED_TIMESTAMP = 'hasSavedTimestamp';
export const FILTER_OPTIONS = ['Visualization', 'Query'];
export const SAVED_QUERY = 'savedQuery';
Expand All @@ -33,7 +36,7 @@ export const PAGE_SIZE = 50;
export const DATE_PICKER_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const TIME_INTERVAL_OPTIONS = [
{
text: 'Minute',
text: 'Minute',
value: 'm',
},
{
Expand Down Expand Up @@ -67,5 +70,4 @@ export const REDUX_EXPL_SLICE_QUERY_RESULT = 'queryResults';
export const REDUX_EXPL_SLICE_FIELDS = 'fields';
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_COUNT_DISTRIBUTION = 'countDistributionVisualization';
8 changes: 8 additions & 0 deletions dashboards-observability/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import CSS from 'csstype';

// Client route
export const PPL_BASE = '/api/ppl';
export const PPL_SEARCH = '/search';
Expand Down Expand Up @@ -59,3 +61,9 @@ export const PLOTLY_COLOR = [
];

export const LONG_CHART_COLOR = PLOTLY_COLOR[1];

export const pageStyles: CSS.Properties = {
float: 'left',
width: '100%',
maxWidth: '1130px',
};
24 changes: 24 additions & 0 deletions dashboards-observability/common/types/app_analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export interface OptionType {
label: string;
}

export interface ApplicationListType {
name: string;
id: string;
dateCreated: string;
dateModified: string;
}

export interface ApplicationType {
name: string;
description: string;
baseQuery: string;
servicesEntities: string[];
traceGroups: string[];
panelId: string;
}
3 changes: 3 additions & 0 deletions dashboards-observability/common/types/custom_panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type CustomPanelListType = {
id: string;
dateCreated: number;
dateModified: number;
applicationId?: string;
};

export type VisualizationType = {
Expand All @@ -24,6 +25,7 @@ export type PanelType = {
visualizations: VisualizationType[];
timeRange: { to: string; from: string };
queryFilter: { query: string; language: string };
applicationId?: string;
};

export type SavedVisualizationType = {
Expand All @@ -32,6 +34,7 @@ export type SavedVisualizationType = {
query: string;
type: string;
timeField: string;
application_id?: string;
};

export type pplResponse = {
Expand Down
61 changes: 36 additions & 25 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
import { History } from 'history';
import {
RAW_QUERY,
SELECTED_FIELDS,
UNSELECTED_FIELDS,
Expand All @@ -12,58 +13,57 @@ import {
INDEX,
FINAL_QUERY,
SELECTED_TIMESTAMP,
SELECTED_DATE_RANGE
} from '../constants/explorer';
import { HttpStart, NotificationsStart } from '../../../../src/core/public';
import SavedObjects from '../../public/services/saved_objects/event_analytics/saved_objects';
import TimestampUtils from '../../public/services/timestamp/timestamp';
import PPLService from '../../public/services/requests/ppl';
import DSLService from '../../public/services/requests/dsl';
import { History } from 'history';
SELECTED_DATE_RANGE,
} from '../constants/explorer';
import { CoreStart, HttpStart, NotificationsStart } from '../../../../src/core/public';
import SavedObjects from '../../public/services/saved_objects/event_analytics/saved_objects';
import TimestampUtils from '../../public/services/timestamp/timestamp';
import PPLService from '../../public/services/requests/ppl';
import DSLService from '../../public/services/requests/dsl';

export interface IQueryTab {
id: string;
name: React.ReactNode | string;
content: React.ReactNode
content: React.ReactNode;
}

export interface IField {
name: string;
type: string
type: string;
}

export interface ITabQueryResults {
[tabId: string]: any
[tabId: string]: any;
}

export interface ITabQueries {
[tabId: string]: IQuery
[tabId: string]: IQuery;
}

export interface IQuery {
[RAW_QUERY]: string;
[FINAL_QUERY]: string;
[INDEX]: string;
[SELECTED_DATE_RANGE]: Array<string>;
[SELECTED_DATE_RANGE]: string[];
[SELECTED_TIMESTAMP]: string;
}

export interface IExplorerTabFields {
[tabId: string]: IExplorerFields
[tabId: string]: IExplorerFields;
}

export interface IExplorerFields {
[SELECTED_FIELDS]: Array<IField>;
[UNSELECTED_FIELDS]: Array<IField>;
[AVAILABLE_FIELDS]: Array<IField>;
[QUERIED_FIELDS]: Array<IField>;
[SELECTED_FIELDS]: IField[];
[UNSELECTED_FIELDS]: IField[];
[AVAILABLE_FIELDS]: IField[];
[QUERIED_FIELDS]: IField[];
}

export type EmptyTabParams = {
tabIds: Array<string> | undefined,
queries: any | undefined,
explorerData: any | undefined
};
export interface EmptyTabParams {
tabIds: string[] | undefined;
queries: any | undefined;
explorerData: any | undefined;
}

export interface ILogExplorerProps {
pplService: PPLService;
Expand Down Expand Up @@ -98,4 +98,15 @@ export interface IExplorerProps {
text?: React.ReactChild | undefined,
side?: string | undefined
) => void;
}
http: CoreStart['http'];
tabCreatedTypes?: any;
searchBarConfigs?: any;
appId?: string;
baseQuery?: string;
addVisualizationToPanel?: any;
startTime?: string;
endTime?: string;
setStartTime?: any;
setEndTime?: any;
appBaseQuery: string;
}
Loading

0 comments on commit 08b84c8

Please sign in to comment.