Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export { ElapsedTimestampTooltip } from './components/elapsed_timestamp_tooltip'

export {
enableInspectEsQueries,
searchExcludedDataTiers,
maxSuggestions,
enableComparisonByDefault,
defaultApmServiceEnvironment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export const uiSettings: Record<string, UiSettingsParams<boolean | number | stri
'xpack.observability.advancedSettings.searchExcludedDataTiersDesc',
{
defaultMessage: `Specify the data tiers to exclude from search, such as data_cold and/or data_frozen.
When configured, indices allocated in the selected tiers will be ignored from search requests. Affected apps: APM, Infrastructure`,
When configured, indices allocated in the selected tiers will be ignored from search requests. Affected apps: APM, Infrastructure, Synthetics`,
}
),
value: [],
Expand Down
1 change: 1 addition & 0 deletions x-pack/solutions/observability/plugins/synthetics/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dependsOn:
- '@kbn/alerts-as-data-utils'
- '@kbn/exploratory-view-plugin'
- '@kbn/observability-shared-plugin'
- '@kbn/observability-utils-common'
- '@kbn/core-http-server'
- '@kbn/std'
- '@kbn/core-saved-objects-server-mocks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { createEsParams, useEsSearch } from '@kbn/observability-shared-plugin/public';
import { createEsParams } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import type { Ping } from '../../../../../../common/runtime_types';
import { getSyntheticsCcsIndex } from '../../../../../../common/get_synthetics_indices';

Expand All @@ -18,7 +19,7 @@ export const useStdErrorLogs = ({
}) => {
const index = !checkGroup ? '' : getSyntheticsCcsIndex(remoteName);

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
createEsParams({
index,
size: 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useParams } from 'react-router-dom';
import { useMemo } from 'react';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { STEP_END_FILTER } from '../../../../../../common/constants/data_filters';
import { asMutableArray } from '../../../../../../common/utils/as_mutable_array';
import type { Ping } from '../../../../../../common/runtime_types';
Expand All @@ -25,7 +25,7 @@ export function useErrorFailedStep(checkGroups: string[]) {

const indexPattern = getSyntheticsCcsIndex(remoteName);

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
{
index: checkGroups?.length > 0 ? indexPattern : '',
size: checkGroups.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { getSyntheticsCcsIndex } from '../../../../../../common/get_synthetics_indices';
import {
ConfigKey,
Expand Down Expand Up @@ -107,7 +107,7 @@ const useRemoteMonitorLatestPing = ({
const canQuery = Boolean(remoteName && monitorId);
const index = canQuery ? getSyntheticsCcsIndex(remoteName) : '';

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
{
index,
size: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useMemo } from 'react';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { getSyntheticsCcsIndex } from '../../../../../../common/get_synthetics_indices';
import {
ConfigKey,
Expand Down Expand Up @@ -87,7 +87,7 @@ export const useRemoteMonitor = ({
// params.index truthiness), so the query is only issued when remoteName is set.
const index = remoteName ? getSyntheticsCcsIndex(remoteName) : '';

const { data, loading, error } = useEsSearch(
const { data, loading, error } = useSyntheticsEsSearch(
{
index,
size: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useSelector } from 'react-redux';
import { useMemo } from 'react';
import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { selectEncryptedSyntheticsSavedMonitors } from '../../../state';
import type { Ping } from '../../../../../../common/runtime_types';
import { ConfigKey } from '../../../../../../common/runtime_types';
Expand Down Expand Up @@ -75,7 +75,7 @@ export function useInlineErrors({

const doFetch = configIds.length > 0 || onlyInvalidMonitors;

const { data } = useEsSearch(
const { data } = useSyntheticsEsSearch(
{
index: doFetch ? SYNTHETICS_INDEX_PATTERN : '',
size: 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useSelector } from 'react-redux';
import { useMemo } from 'react';
import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { selectEncryptedSyntheticsSavedMonitors } from '../../../state';
import { useSyntheticsRefreshContext } from '../../../contexts/synthetics_refresh_context';
import { getInlineErrorFilters } from './use_inline_errors';
Expand All @@ -18,7 +18,7 @@ export function useInlineErrorsCount() {

const { lastRefresh } = useSyntheticsRefreshContext();

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
{
index: SYNTHETICS_INDEX_PATTERN,
size: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { createEsParams, useEsSearch } from '@kbn/observability-shared-plugin/public';
import { createEsParams } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { getSyntheticsCcsIndex } from '../../../../../../common/get_synthetics_indices';
import { useGetUrlParams } from '../../../hooks';
import type { MarkerItems } from './waterfall/context/waterfall_context';
Expand All @@ -24,7 +25,7 @@ export const useStepWaterfallMetrics = ({ checkGroup, hasNavigationRequest, step
const { remoteName } = useGetUrlParams();
const index = getSyntheticsCcsIndex(remoteName);

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
hasNavigationRequest
? createEsParams({
index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/
import { useEffect, useState, useRef } from 'react';
import { createEsParams, useEsSearch, useFetcher } from '@kbn/observability-shared-plugin/public';
import { createEsParams, useFetcher } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { useTickTick } from './use_tick_tick';
import { isStepEnd } from '../../common/monitor_test_result/browser_steps_list';
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants';
Expand All @@ -29,7 +30,7 @@ export const useBrowserEsResults = ({
testRunId: string;
lastRefresh: number;
}) => {
return useEsSearch(
return useSyntheticsEsSearch(
createEsParams({
index: SYNTHETICS_INDEX_PATTERN,
sort: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import { useEffect, useMemo, useRef, useState } from 'react';
import { createEsParams, useEsSearch } from '@kbn/observability-shared-plugin/public';
import { createEsParams } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from '../../../hooks/use_synthetics_es_search';
import { FINAL_SUMMARY_FILTER } from '../../../../../../common/constants/client_defaults';
import type { Ping } from '../../../../../../common/runtime_types';
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants';
Expand All @@ -24,7 +25,7 @@ export const useSimpleRunOnceMonitors = ({
const { refreshTimer, lastRefresh } = useTickTick(2 * 1000);
const [numberOfRetries, setNumberOfRetries] = useState(0);

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
createEsParams({
index: SYNTHETICS_INDEX_PATTERN,
sort: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { SearchRequest } from '@elastic/elasticsearch/lib/api/types';
import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useSyntheticsEsSearch } from './use_synthetics_es_search';
import { getSyntheticsCcsIndex } from '../../../../common/get_synthetics_indices';
import type { Ping } from '../../../../common/runtime_types';

Expand Down Expand Up @@ -43,13 +43,12 @@ export const useMonitorDetail = (
},
sort: [{ '@timestamp': 'desc' as const }],
};
const { data: result, loading } = useEsSearch<Ping & { '@timestamp': string }, SearchRequest>(
params,
[configId, location, remoteName],
{
name: 'getMonitorStatusByLocation',
}
);
const { data: result, loading } = useSyntheticsEsSearch<
Ping & { '@timestamp': string },
SearchRequest
>(params, [configId, location, remoteName], {
name: 'getMonitorStatusByLocation',
});

if (!result || result.hits.hits.length !== 1) return { data: undefined, loading };
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { useMemo } from 'react';
import { useSyntheticsEsSearch } from './use_synthetics_es_search';
import { MONITOR_STATUS_ENUM } from '../../../../common/constants/monitor_management';
import { useMonitorHealthColor } from '../components/monitors_page/hooks/use_monitor_health_color';
import { UNNAMED_LOCATION } from '../../../../common/constants';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function useStatusByLocation({

const { locations: allLocations } = useLocations();

const { data, loading } = useEsSearch(
const { data, loading } = useSyntheticsEsSearch(
{
index: getSyntheticsCcsIndex(remoteName),
size: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { estypes } from '@elastic/elasticsearch';
import type { IInspectorInfo } from '@kbn/data-plugin/common';
import { useEsSearch } from '@kbn/observability-shared-plugin/public';
import { applyExcludedDataTiersToParams } from '../utils/excluded_data_tiers';

/**
* Synthetics-aware wrapper around the shared `useEsSearch` hook that injects the
* `observability:searchExcludedDataTiers` exclusion into every browser-issued
* query, matching the server-side `SyntheticsEsClient`. Use this instead of
* `useEsSearch` for any query targeting `synthetics-*` indices.
*/
export const useSyntheticsEsSearch = <
DocumentSource extends unknown,
TParams extends estypes.SearchRequest
>(
params: TParams,
fnDeps: any[],
options: { inspector?: IInspectorInfo; name: string }
) => {
return useEsSearch<DocumentSource, TParams>(
applyExcludedDataTiersToParams(params),
fnDeps,
options
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ import { FETCH_STATUS } from '@kbn/observability-shared-plugin/public';
import { getInspectResponse } from '@kbn/observability-shared-plugin/common';
import { kibanaService } from '../../../../utils/kibana_service';
import { apiService } from '../../../../utils/api_service';
import { applyExcludedDataTiersToParams } from '../../utils/excluded_data_tiers';

export const executeEsQueryAPI = async ({
params,
params: rawParams,
name,
}: {
params: estypes.SearchRequest;
name: string;
}) => {
const data = kibanaService.startPlugins.data;

// Inject the `observability:searchExcludedDataTiers` exclusion so redux-backed
// queries skip the same tiers as the server-side `SyntheticsEsClient`.
const params = applyExcludedDataTiersToParams(rawParams);

const addInspectorRequest = apiService.addInspectorRequest;

const response = new Promise<IKibanaSearchResponse>((resolve, reject) => {
Expand Down
Loading
Loading