Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into validate-total-atta…
Browse files Browse the repository at this point in the history
…chments
  • Loading branch information
adcoelho committed Jul 17, 2023
2 parents e6cfc4d + 48ec52b commit b057087
Show file tree
Hide file tree
Showing 325 changed files with 4,552 additions and 3,847 deletions.
3 changes: 3 additions & 0 deletions docs/management/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ action in the current space.
For out-of-the-box and standardized connectors, refer to
<<pre-configured-connectors,preconfigured connectors>>.

TIP: You can also manage connectors as resources with the https://registry.terraform.io/providers/elastic/elasticstack/latest[Elasticstack provider] for Terraform.
For more details, refer to the https://registry.terraform.io/providers/elastic/elasticstack/latest/docs/resources/kibana_action_connector[elasticstack_kibana_action_connector] resource.

[float]
[[importing-and-exporting-connectors]]
=== Importing and exporting connectors
Expand Down
3 changes: 3 additions & 0 deletions docs/user/alerting/create-and-manage-rules.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ a rule type and configuring its conditions and actions.
After a rule is created, you can open the action menu (…) and select *Edit rule*
to re-open the flyout and change the rule properties.

TIP: You can also manage rules as resources with the https://registry.terraform.io/providers/elastic/elasticstack/latest[Elasticstack provider] for Terraform.
For more details, refer to the https://registry.terraform.io/providers/elastic/elasticstack/latest/docs/resources/kibana_alerting_rule[elasticstack_kibana_alerting_rule] resource.

[float]
[[defining-rules-type-conditions]]
==== Rule type and conditions
Expand Down
10 changes: 5 additions & 5 deletions docs/user/alerting/rule-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ If you create a rule in the {observability} app, its alerts are not visible in
| <<apm-alerts, APM and User Experience>>
| Detect complex conditions in *APM* data and trigger built-in actions when the conditions are met.

| {observability-guide}/create-alerts.html[Logs rules]
| {observability-guide}/logs-threshold-alert.html[Logs rules]
| Detect complex conditions in the {logs-app}.

| {observability-guide}/create-alerts.html[Metrics rules]
| {observability-guide}/metrics-threshold-alert.html[Metrics rules]
| Detect complex conditions in the {metrics-app}.

| <<kibana-alerts,{stack-monitor-app}>>
| Provide {kib} alerting rules out-of-the box to notify you of potential issues in the {stack}.
| {observability-guide}/slo-burn-rate-alert.html[SLO burn rate rule]
| Detect when the burn rate is above a defined threshold.

| {observability-guide}/create-alerts.html[Uptime rules]
| {observability-guide}/monitor-status-alert.html[Uptime rules]
| Detect complex conditions in the {uptime-app}.

|===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ExpressionRenderDefinition } from '@kbn/expressions-plugin/common/expre
import { StartServicesGetter } from '@kbn/kibana-utils-plugin/public';
import { METRIC_TYPE } from '@kbn/analytics';
import { extractContainerType, extractVisualizationType } from '@kbn/chart-expressions-common';
import { I18nProvider } from '@kbn/i18n-react';
import { ExpressionHeatmapPluginStart } from '../plugin';
import {
EXPRESSION_HEATMAP_NAME,
Expand Down Expand Up @@ -79,24 +80,26 @@ export const heatmapRenderer: (

render(
<KibanaThemeProvider theme$={core.theme.theme$}>
<div className="heatmap-container" data-test-subj="heatmapChart">
<HeatmapComponent
{...config}
onClickValue={onClickValue}
onSelectRange={onSelectRange}
timeZone={timeZone}
datatableUtilities={getDatatableUtilities()}
formatFactory={getFormatService().deserialize}
chartsThemeService={plugins.charts.theme}
paletteService={getPaletteService()}
renderComplete={renderComplete}
uiState={handlers.uiState as PersistedState}
interactive={isInteractive()}
chartsActiveCursorService={plugins.charts.activeCursor}
syncTooltips={config.syncTooltips}
syncCursor={config.syncCursor}
/>
</div>
<I18nProvider>
<div className="heatmap-container" data-test-subj="heatmapChart">
<HeatmapComponent
{...config}
onClickValue={onClickValue}
onSelectRange={onSelectRange}
timeZone={timeZone}
datatableUtilities={getDatatableUtilities()}
formatFactory={getFormatService().deserialize}
chartsThemeService={plugins.charts.theme}
paletteService={getPaletteService()}
renderComplete={renderComplete}
uiState={handlers.uiState as PersistedState}
interactive={isInteractive()}
chartsActiveCursorService={plugins.charts.activeCursor}
syncTooltips={config.syncTooltips}
syncCursor={config.syncCursor}
/>
</div>
</I18nProvider>
</KibanaThemeProvider>,
domNode
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@kbn/kibana-react-plugin",
"@kbn/analytics",
"@kbn/chart-expressions-common",
"@kbn/i18n-react",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { getRawRecordType } from '../../utils/get_raw_record_type';
import { SavedSearchURLConflictCallout } from '../../../../components/saved_search_url_conflict_callout/saved_search_url_conflict_callout';
import { DiscoverHistogramLayout } from './discover_histogram_layout';
import { ErrorCallout } from '../../../../components/common/error_callout';
import { addLog } from '../../../../utils/add_log';

/**
* Local storage key for sidebar persistence state
Expand Down Expand Up @@ -209,6 +210,7 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
}

if (resultState === 'uninitialized') {
addLog('[DiscoverLayout] uninitialized triggers data fetching');
return <DiscoverUninitialized onRefresh={() => stateContainer.dataState.fetch()} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getHeaderActionMenuMounter } from '../../../../kibana_services';
import { DiscoverStateContainer } from '../../services/discover_state';
import { onSaveSearch } from './on_save_search';
import { useDiscoverCustomization } from '../../../../customizations';
import { addLog } from '../../../../utils/add_log';

export interface DiscoverTopNavProps {
onOpenInspector: () => void;
Expand Down Expand Up @@ -143,6 +144,7 @@ export const DiscoverTopNav = ({
await stateContainer.actions.updateAdHocDataViewId();
}
stateContainer.actions.loadDataViewList();
addLog('[DiscoverTopNav] onEditDataView triggers data fetching');
stateContainer.dataState.fetch();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useSavedSearchAliasMatchRedirect } from '../../hooks/saved_search_alias
import { useSavedSearchInitial } from './services/discover_state_provider';
import { useAdHocDataViews } from './hooks/use_adhoc_data_views';
import { useTextBasedQueryLanguage } from './hooks/use_text_based_query_language';
import { addLog } from '../../utils/add_log';

const DiscoverLayoutMemoized = React.memo(DiscoverLayout);

Expand Down Expand Up @@ -53,6 +54,7 @@ export function DiscoverMainApp(props: DiscoverMainProps) {
*/
useEffect(() => {
const unsubscribe = stateContainer.actions.initializeAndSync();
addLog('[DiscoverMainApp] state container initialization triggers data fetching');
stateContainer.actions.fetchData(true);
return () => unsubscribe();
}, [stateContainer]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,13 @@ export function DiscoverMainRoute({ customizationCallbacks, isDev }: MainRoutePr
}
try {
await stateContainer.actions.loadDataViewList();
// reset appState in case a saved search with id is loaded and the url is empty
// so the saved search is loaded in a clean state
// else it might be updated by the previous app state
const useAppState = !stateContainer.appState.isEmptyURL();

const currentSavedSearch = await stateContainer.actions.loadSavedSearch({
savedSearchId,
dataView: nextDataView,
dataViewSpec: historyLocationState?.dataViewSpec,
useAppState,
});

if (currentSavedSearch?.id) {
chrome.recentlyAccessed.add(
getSavedSearchFullPathUrl(currentSavedSearch.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('buildStateSubscribe', () => {
it('should not call refetch$ if nothing changes', async () => {
await getSubscribeFn()(stateContainer.appState.getState());

expect(stateContainer.dataState.refetch$.next).toHaveBeenCalled();
expect(stateContainer.dataState.refetch$.next).not.toHaveBeenCalled();
});

it('should call refetch$ if the chart is hidden', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,30 @@ export const buildStateSubscribe =
dataViewChanged ||
queryChanged
) {
addLog('[appstate] subscribe triggers data fetching');
const logData = {
chartDisplayChanged: logEntry(chartDisplayChanged, hideChart, nextState.hideChart),
chartIntervalChanged: logEntry(chartIntervalChanged, interval, nextState.interval),
breakdownFieldChanged: logEntry(
breakdownFieldChanged,
breakdownField,
nextState.breakdownField
),
docTableSortChanged: logEntry(docTableSortChanged, sort, nextState.sort),
dataViewChanged: logEntry(dataViewChanged, index, nextState.index),
queryChanged: logEntry(queryChanged, prevQuery, nextQuery),
};

addLog(
'[buildStateSubscribe] state changes triggers data fetching',
JSON.stringify(logData, null, 2)
);

dataState.fetch();
}
};

const logEntry = <T>(changed: boolean, prevState: T, nextState: T) => ({
changed,
prevState,
nextState,
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import { SavedSearch, VIEW_MODE } from '@kbn/saved-search-plugin/public';
import { IKbnUrlStateStorage, ISyncStateRef, syncState } from '@kbn/kibana-utils-plugin/public';
import { isEqual } from 'lodash';
import { connectToQueryState, syncGlobalQueryStateWithUrl } from '@kbn/data-plugin/public';
import { DiscoverServices } from '../../../build_services';
import type { DiscoverServices } from '../../../build_services';
import { addLog } from '../../../utils/add_log';
import { cleanupUrlState } from '../utils/cleanup_url_state';
import { getStateDefaults } from '../utils/get_state_defaults';
import { handleSourceColumnState } from '../../../utils/state_helpers';
import { DiscoverGridSettings } from '../../../components/discover_grid/types';
import type { DiscoverGridSettings } from '../../../components/discover_grid/types';

export const APP_STATE_URL_KEY = '_a';
export interface DiscoverAppStateContainer extends ReduxLikeStateContainer<DiscoverAppState> {
Expand All @@ -55,6 +55,10 @@ export interface DiscoverAppStateContainer extends ReduxLikeStateContainer<Disco
* @param merge if true, the given state is merged with the current state
*/
replaceUrlState: (newPartial: DiscoverAppState, merge?: boolean) => Promise<void>;
/**
* Resets the state container to a given state, clearing the previous state
*/
resetToState: (state: DiscoverAppState) => void;
/**
* Resets the current state to the initial state
*/
Expand Down Expand Up @@ -148,8 +152,8 @@ export const getDiscoverAppStateContainer = ({
savedSearch: SavedSearch;
services: DiscoverServices;
}): DiscoverAppStateContainer => {
let previousState: DiscoverAppState = {};
let initialState = getInitialState(stateStorage, savedSearch, services);
let previousState = initialState;
const appStateContainer = createStateContainer<DiscoverAppState>(initialState);

const enhancedAppContainer = {
Expand All @@ -166,6 +170,12 @@ export const getDiscoverAppStateContainer = ({
return !isEqualState(initialState, appStateContainer.getState());
};

const resetToState = (state: DiscoverAppState) => {
addLog('[appState] reset state to', state);
previousState = state;
appStateContainer.set(state);
};

const resetInitialState = () => {
addLog('[appState] reset initial state to the current state');
initialState = appStateContainer.getState();
Expand Down Expand Up @@ -245,6 +255,7 @@ export const getDiscoverAppStateContainer = ({
getPrevious,
hasChanged,
initAndSync: initializeAndSync,
resetToState,
resetInitialState,
replaceUrlState,
syncState: startAppStateUrlSync,
Expand Down
Loading

0 comments on commit b057087

Please sign in to comment.