Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f618dce
[ES|QL] Supports timezone in Discover/Dashboards
stratoula Jan 6, 2026
f9baa05
Support timezone in run_query utilities
stratoula Jan 7, 2026
34dd1ac
Supports timezone in maps
stratoula Jan 7, 2026
354d806
Merge branch 'main' into timezone-support-esql
stratoula Jan 8, 2026
4292069
Merge branch 'main' into timezone-support-esql
stratoula Jan 12, 2026
6825a96
Merge branch 'main' into timezone-support-esql
stratoula Jan 13, 2026
a3a9ab9
Merge branch 'main' into timezone-support-esql
stratoula Jan 14, 2026
b6569ba
Merge branch 'main' into timezone-support-esql
stratoula Jan 19, 2026
b6939c7
Merge branch 'main' into timezone-support-esql
stratoula Jan 20, 2026
51f458d
Merge branch 'main' into timezone-support-esql
stratoula Jan 23, 2026
76143ee
Merge branch 'main' into timezone-support-esql
stratoula Jan 23, 2026
efac82f
Merge branch 'main' into timezone-support-esql
stratoula Jan 26, 2026
6bd59c2
Merge branch 'main' into timezone-support-esql
stratoula Jan 27, 2026
ee408f8
Merge branch 'main' into timezone-support-esql
stratoula Jan 27, 2026
5f27abd
Merge branch 'main' into timezone-support-esql
stratoula Jan 28, 2026
cf4d0b1
Update jest tests
stratoula Jan 28, 2026
f7c7684
Fixed remaining jest test
stratoula Jan 28, 2026
db705bd
Merge branch 'main' into timezone-support-esql
stratoula Jan 29, 2026
a1b03c3
Merge branch 'main' into timezone-support-esql
stratoula Jan 29, 2026
1bf9a37
Update limits
stratoula Jan 29, 2026
21cc9e8
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Jan 29, 2026
90196c9
Merge branch 'main' into timezone-support-esql
stratoula Jan 29, 2026
a029df3
Add try catch
stratoula Jan 30, 2026
28646a1
Revert security solution changes
stratoula Jan 30, 2026
8aa4678
Merge branch 'main' into timezone-support-esql
stratoula Jan 30, 2026
0ecd7f3
Merge branch 'main' into timezone-support-esql
stratoula Feb 2, 2026
f9c4c88
Merge branch 'main' into timezone-support-esql
stratoula Feb 4, 2026
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 @@ -317,7 +317,7 @@ describe('CsvESQLGenerator', () => {
);

expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '' } },
{ params: { filter: undefined, locale: 'en', query: '', time_zone: 'America/New_York' } },
{
strategy: 'esql',
transport: {
Expand Down Expand Up @@ -396,7 +396,7 @@ describe('CsvESQLGenerator', () => {
);

expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '' } },
{ params: { filter: undefined, locale: 'en', query: '', time_zone: 'America/New_York' } },
{
strategy: 'esql',
transport: {
Expand Down Expand Up @@ -494,6 +494,7 @@ describe('CsvESQLGenerator', () => {
},
locale: 'en',
query: 'FROM kibana_sample_data_logs | LIMIT 10 | LIMIT 500',
time_zone: 'America/New_York',
},
},
{
Expand Down Expand Up @@ -568,6 +569,7 @@ describe('CsvESQLGenerator', () => {
]),
locale: 'en',
query: `${query.esql} | LIMIT 500`,
time_zone: 'America/New_York',
},
},
{
Expand Down Expand Up @@ -607,6 +609,7 @@ describe('CsvESQLGenerator', () => {
filter: undefined,
locale: 'en',
query: 'FROM custom-metrics | LIMIT 500',
time_zone: 'America/New_York',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class CsvESQLGenerator {
let reportingError: undefined | ReportingError;
const warnings: string[] = [];

const { maxSizeBytes, maxRows, bom, escapeFormulaValues } = settings;
const { maxSizeBytes, maxRows, bom, escapeFormulaValues, timezone } = settings;
const builder = new MaxSizeStringBuilder(this.stream, byteSizeValueToNumber(maxSizeBytes), bom);

// it will return undefined if there are no _tstart, _tend named params in the query
Expand Down Expand Up @@ -130,10 +130,7 @@ export class CsvESQLGenerator {
// locale can be used for number/date formatting
locale: i18n.getLocale(),
...(params.length ? { params } : {}),
// TODO: time_zone support was temporarily removed from ES|QL,
// we will need to add it back in once it is supported again.
// https://github.com/elastic/elasticsearch/pull/102767
// timezone
time_zone: timezone,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/platform/packages/shared/kbn-es-query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export {
isDataViewFieldSubtypeMulti,
isDataViewFieldSubtypeNested,
isCCSRemoteIndexName,
getTimeZoneFromSettings,
} from './src/utils';

export type { ExecutionContextSearch } from './src/expressions/types';
5 changes: 1 addition & 4 deletions src/platform/packages/shared/kbn-es-types/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,7 @@ export interface ESQLSearchResponse {
}

export interface ESQLSearchParams {
// TODO: time_zone support was temporarily removed from ES|QL,
// we will need to add it back in once it is supported again.
// https://github.com/elastic/elasticsearch/pull/102767
// time_zone?: string;
time_zone?: string;
query: string;
filter?: unknown;
project_routing?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import dateMath from '@kbn/datemath';
import type { DatatableColumn } from '@kbn/expressions-plugin/common';
import type { ISearchGeneric } from '@kbn/search-types';
import type { TimeRange } from '@kbn/es-query';
import { getTimeZoneFromSettings } from '@kbn/es-query';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import type { ESQLColumn, ESQLSearchResponse, ESQLSearchParams } from '@kbn/es-types';
import { lastValueFrom } from 'rxjs';
Expand Down Expand Up @@ -177,6 +178,7 @@ export async function getESQLResults({
dropNullColumns,
timeRange,
variables,
timezone,
}: {
esqlQuery: string;
search: ISearchGeneric;
Expand All @@ -185,6 +187,7 @@ export async function getESQLResults({
dropNullColumns?: boolean;
timeRange?: TimeRange;
variables?: ESQLControlVariable[];
timezone?: string;
}): Promise<{
response: ESQLSearchResponse;
params: ESQLSearchParams;
Expand All @@ -198,6 +201,7 @@ export async function getESQLResults({
query: esqlQuery,
...(dropNullColumns ? { dropNullColumns: true } : {}),
...(namedParams.length ? { params: namedParams } : {}),
...(timezone ? { time_zone: getTimeZoneFromSettings(timezone) } : {}),
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import type { ISearchGeneric } from '@kbn/search-types';
import type { TimeRange } from '@kbn/es-query';
import { getESQLResults } from '@kbn/esql-utils';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import type { ESQLControlVariable } from '@kbn/esql-types';
import { coreServices } from '../../../services/kibana_services';

export interface GetESQLSingleColumnValuesSuccess {
values: string[];
Expand All @@ -35,13 +37,15 @@ export const getESQLSingleColumnValues = async ({
GetESQLSingleColumnValuesSuccess | GetESQLSingleColumnValuesFailure
> => {
try {
const timezone = coreServices.uiSettings?.get<'Browser' | string>(UI_SETTINGS.DATEFORMAT_TZ);
const results = await getESQLResults({
esqlQuery: query,
search,
signal: undefined,
filter: undefined,
dropNullColumns: true,
timeRange,
timezone,
variables: esqlVariables,
});
const columns = results.response.columns.map((col) => col.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ describe('getEsqlFn', () => {
const esqlFn = getEsqlFn({
getStartDependencies: async () => ({
search: mockSearch,
uiSettings: {} as UiSettingsCommon,
uiSettings: {
get: jest.fn((key: string) => {
if (key === 'dateFormat:tz') return 'UTC';
return undefined;
}),
} as unknown as UiSettingsCommon,
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import { zipObject } from 'lodash';
import type { Observable } from 'rxjs';
import { catchError, defer, map, switchMap, tap, throwError } from 'rxjs';
import { buildEsQuery, type Filter } from '@kbn/es-query';
import { buildEsQuery, type Filter, getTimeZoneFromSettings } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchResponse } from '@kbn/es-types';
import DateMath from '@kbn/datemath';
import { getEsQueryConfig } from '../../es_query';
Expand Down Expand Up @@ -60,10 +60,6 @@ type Output = Observable<Datatable>;

interface Arguments {
query: string;
// TODO: time_zone support was temporarily removed from ES|QL,
// we will need to add it back in once it is supported again.
// https://github.com/elastic/elasticsearch/pull/102767
// timezone?: string;
timeField?: string;
locale?: string;

Expand Down Expand Up @@ -117,15 +113,6 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
defaultMessage: 'An ES|QL query.',
}),
},
// timezone: {
// aliases: ['tz'],
// types: ['string'],
// default: 'UTC',
// help: i18n.translate('data.search.esql.timezone.help', {
// defaultMessage:
// 'The timezone to use for date operations. Valid ISO8601 formats and UTC offsets both work.',
// }),
// },
timeField: {
aliases: ['timeField'],
types: ['string'],
Expand Down Expand Up @@ -169,14 +156,7 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
},
fn(
input,
{
query,
/* timezone, */ timeField,
locale,
titleForInspector,
descriptionForInspector,
ignoreGlobalFilters,
},
{ query, timeField, locale, titleForInspector, descriptionForInspector, ignoreGlobalFilters },
{ abortSignal, inspectorAdapters, getKibanaRequest, getSearchSessionId }
) {
return defer(() =>
Expand All @@ -197,17 +177,18 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
// and the query is not set with ?? in the query, we should set it
// https://github.com/elastic/elasticsearch/pull/122459
const fixedQuery = fixESQLQueryWithVariables(query, input?.esqlVariables ?? []);
const esQueryConfigs = getEsQueryConfig(
uiSettings as Parameters<typeof getEsQueryConfig>[0]
);
const params: ESQLSearchParams = {
query: fixedQuery,
// time_zone: timezone,
time_zone: esQueryConfigs.dateFormatTZ
? getTimeZoneFromSettings(esQueryConfigs.dateFormatTZ)
: 'UTC',
locale,
include_execution_metadata: true,
};
if (input) {
const esQueryConfigs = getEsQueryConfig(
uiSettings as Parameters<typeof getEsQueryConfig>[0]
);

const namedParams = getNamedParams(fixedQuery, input.timeRange, input.esqlVariables);

if (namedParams.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ export function ESQLControlsFlyout({
search={search}
valuesRetrieval={valuesField}
timeRange={timeRange}
currentApp={currentApp}
Copy link
Copy Markdown
Contributor Author

@stratoula stratoula Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrelevant with this change, but it is not been used so I decided to clean it up here

esqlVariables={esqlVariables}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { ISearchGeneric } from '@kbn/search-types';
import { isEqual } from 'lodash';
import React, { useCallback, useEffect, useState } from 'react';
import useMountedState from 'react-use/lib/useMountedState';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import { ESQLLangEditor } from '../../../create_editor';
import type { ServiceDeps } from '../../../kibana_services';
import { ChooseColumnPopover } from './choose_column_popover';
Expand All @@ -45,7 +46,6 @@ interface ValueControlFormProps {
initialState?: ESQLControlState;
valuesRetrieval?: string;
timeRange?: TimeRange;
currentApp?: string;
esqlVariables: ESQLControlVariable[];
}

Expand All @@ -67,7 +67,6 @@ export function ValueControlForm({
setControlState,
valuesRetrieval,
timeRange,
currentApp,
esqlVariables,
}: ValueControlFormProps) {
const isMounted = useMountedState();
Expand Down Expand Up @@ -158,13 +157,15 @@ export function ValueControlForm({
const onValuesQuerySubmit = useCallback(
async (query: string) => {
try {
const timezone = core.uiSettings.get<'Browser' | string>(UI_SETTINGS.DATEFORMAT_TZ);
getESQLResults({
esqlQuery: query,
search,
signal: undefined,
filter: undefined,
dropNullColumns: true,
timeRange,
timezone,
variables: esqlVariables,
}).then((results) => {
if (!isMounted()) {
Expand Down Expand Up @@ -195,7 +196,7 @@ export function ValueControlForm({
setEsqlQueryErrors([e]);
}
},
[isMounted, search, timeRange, esqlVariables]
[isMounted, search, timeRange, esqlVariables, core.uiSettings]
);

const setSuggestedQuery = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@kbn/esql-utils';
import { type AggregateQuery, buildEsQuery } from '@kbn/es-query';
import type { CoreStart, IUiSettingsClient } from '@kbn/core/public';
import { getEsQueryConfig } from '@kbn/data-plugin/public';
import { getEsQueryConfig, UI_SETTINGS } from '@kbn/data-plugin/public';
import type { ESQLControlVariable } from '@kbn/esql-types';
import type { ESQLRow } from '@kbn/es-types';
import { getLensAttributesFromSuggestion, mapVisToChartType } from '@kbn/visualization-utils';
Expand Down Expand Up @@ -79,7 +79,7 @@ export const getGridAttrs = async (
});

const filter = getDSLFilter(data.query, uiSettings, dataView.timeFieldName);

const timezone = uiSettings.get<'Browser' | string>(UI_SETTINGS.DATEFORMAT_TZ);
const results = await getESQLResults({
esqlQuery: query.esql,
search: data.search.search,
Expand All @@ -88,6 +88,7 @@ export const getGridAttrs = async (
dropNullColumns: true,
timeRange: data.query.timefilter.timefilter.getAbsoluteTime(),
variables: esqlVariables,
timezone,
});

let queryColumns = results.response.columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
getStartEndParams,
hasStartEndParams,
} from '@kbn/esql-utils';
import { buildEsQuery } from '@kbn/es-query';
import { buildEsQuery, getTimeZoneFromSettings } from '@kbn/es-query';
import type { Filter, Query } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchResponse } from '@kbn/es-types';
import { getEsQueryConfig } from '@kbn/data-service/src/es_query';
Expand Down Expand Up @@ -262,7 +262,12 @@ export class ESQLSource
params.params = namedParams;
}

params.filter = buildEsQuery(undefined, query, filters, getEsQueryConfig(getUiSettings()));
const esQueryConfigs = getEsQueryConfig(getUiSettings());

params.filter = buildEsQuery(undefined, query, filters, esQueryConfigs);
params.time_zone = esQueryConfigs.dateFormatTZ
? getTimeZoneFromSettings(esQueryConfigs.dateFormatTZ)
: 'UTC';

const requestResponder = inspectorAdapters.requests!.start(
getLayerFeaturesRequestName(layerName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
} from '@kbn/triggers-actions-ui-plugin/public/common';
import { EsqlQuery } from '@kbn/esql-language';
import useDebounce from 'react-use/lib/useDebounce';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import type { EsQueryRuleParams, EsQueryRuleMetaData } from '../types';
import { SearchType } from '../types';
import { DEFAULT_VALUES, SERVERLESS_DEFAULT_VALUES } from '../constants';
Expand Down Expand Up @@ -112,7 +113,7 @@ const keepRecommendedWarning = i18n.translate(
export const EsqlQueryExpression: React.FC<
RuleTypeParamsExpressionProps<EsQueryRuleParams<SearchType.esqlQuery>, EsQueryRuleMetaData>
> = ({ ruleParams, metadata, setRuleParams, setRuleProperty, errors, data }) => {
const { http, isServerless, dataViews } = useTriggerUiActionServices();
const { http, isServerless, dataViews, uiSettings } = useTriggerUiActionServices();
const { esqlQuery, timeWindowSize, timeWindowUnit, timeField, groupBy } = ruleParams;
const isEdit = !!metadata?.isEdit;

Expand Down Expand Up @@ -212,11 +213,14 @@ export const EsqlQueryExpression: React.FC<
}
setIsLoading(true);
const { timeFilter, timeRange } = getTimeFilter(timeField, window);
const timezone = uiSettings?.get<'Browser' | string>(UI_SETTINGS.DATEFORMAT_TZ);

const table = await getESQLResults({
esqlQuery: esqlQuery.esql,
search: data.search.search,
dropNullColumns: true,
timeRange,
timezone,
filter: timeFilter,
});
if (table.response) {
Expand Down Expand Up @@ -254,6 +258,7 @@ export const EsqlQueryExpression: React.FC<
currentRuleParams,
esqlQuery,
data.search.search,
uiSettings,
timeField,
isServerless,
groupBy,
Expand Down
Loading
Loading