Skip to content

Commit 974e497

Browse files
[9.2] [Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command (#239131) (#239172)
# Backport This will backport the following commits from `main` to `9.2`: - [[Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command (#239131)](#239131) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Miłosz Marcinkowski","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-15T14:57:21Z","message":"[Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command (#239131)\n\n## Summary\n\nCloses #239096\n\nDisable Metrics Experience when ESQL query contains WHERE command.\n\nBefore:<img width=\"1728\" height=\"971\" alt=\"Screenshot 2025-10-15 at 13\n57 46\"\nsrc=\"https://github.com/user-attachments/assets/6e888549-7522-43d2-be2d-b5d66dc06949\"\n/>\n\n\nAfter: <img width=\"1728\" height=\"967\" alt=\"Screenshot 2025-10-15 at 13\n57 10\"\nsrc=\"https://github.com/user-attachments/assets/3ac32981-3d1c-492f-a2ff-f20095bb1c4d\"\n/>\n\n## How to test\n- Clone https://github.com/simianhacker/simian-forge/tree/main\n- Run ` ./forge --dataset unique-metrics --count 50 --interval 30s`\n- Navigate to Discover page, select ESQL mode and search for metrics\nindex","sha":"c8b851534bffe80bd60008615fa5808368452fc8","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-infra_services","backport:version","v9.2.0","v9.3.0"],"title":"[Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command","number":239131,"url":"https://github.com/elastic/kibana/pull/239131","mergeCommit":{"message":"[Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command (#239131)\n\n## Summary\n\nCloses #239096\n\nDisable Metrics Experience when ESQL query contains WHERE command.\n\nBefore:<img width=\"1728\" height=\"971\" alt=\"Screenshot 2025-10-15 at 13\n57 46\"\nsrc=\"https://github.com/user-attachments/assets/6e888549-7522-43d2-be2d-b5d66dc06949\"\n/>\n\n\nAfter: <img width=\"1728\" height=\"967\" alt=\"Screenshot 2025-10-15 at 13\n57 10\"\nsrc=\"https://github.com/user-attachments/assets/3ac32981-3d1c-492f-a2ff-f20095bb1c4d\"\n/>\n\n## How to test\n- Clone https://github.com/simianhacker/simian-forge/tree/main\n- Run ` ./forge --dataset unique-metrics --count 50 --interval 30s`\n- Navigate to Discover page, select ESQL mode and search for metrics\nindex","sha":"c8b851534bffe80bd60008615fa5808368452fc8"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/239131","number":239131,"mergeCommit":{"message":"[Metrics][Discover] Disable Metrics Experience when ESQL query contains WHERE command (#239131)\n\n## Summary\n\nCloses #239096\n\nDisable Metrics Experience when ESQL query contains WHERE command.\n\nBefore:<img width=\"1728\" height=\"971\" alt=\"Screenshot 2025-10-15 at 13\n57 46\"\nsrc=\"https://github.com/user-attachments/assets/6e888549-7522-43d2-be2d-b5d66dc06949\"\n/>\n\n\nAfter: <img width=\"1728\" height=\"967\" alt=\"Screenshot 2025-10-15 at 13\n57 10\"\nsrc=\"https://github.com/user-attachments/assets/3ac32981-3d1c-492f-a2ff-f20095bb1c4d\"\n/>\n\n## How to test\n- Clone https://github.com/simianhacker/simian-forge/tree/main\n- Run ` ./forge --dataset unique-metrics --count 50 --interval 30s`\n- Navigate to Discover page, select ESQL mode and search for metrics\nindex","sha":"c8b851534bffe80bd60008615fa5808368452fc8"}}]}] BACKPORT--> Co-authored-by: Miłosz Marcinkowski <[email protected]>
1 parent 396abe3 commit 974e497

File tree

2 files changed

+9
-4
lines changed
  • src/platform/plugins/shared/discover/public/context_awareness/profile_providers/metrics_data_source_profile

2 files changed

+9
-4
lines changed

src/platform/plugins/shared/discover/public/context_awareness/profile_providers/metrics_data_source_profile/profile.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ describe('metricsDataSourceProfileProvider', () => {
7171
'TS metrics-*,',
7272
'FROM metrics-* | LIMIT 10',
7373
'FROM metrics-* | SORT @timestamp DESC',
74-
'FROM metrics-* | WHERE host.name="foo"',
7574
])('when query conatains supported commands %s', async (query) => {
7675
const result = await provider.resolve(
7776
createParams({
@@ -151,10 +150,16 @@ describe('metricsDataSourceProfileProvider', () => {
151150
expect(result).toEqual(RESOLUTION_MISMATCH);
152151
});
153152

154-
it('when query contains commands that are not supported', async () => {
153+
it.each([
154+
'FROM metrics-* | STATS count() BY @timestamp',
155+
'FROM metrics-* | WHERE host.name="foo"',
156+
])('when query contains commands that are not supported', async (query) => {
155157
const result = await provider.resolve(
156-
createParams({ query: { esql: 'FROM metrics-* | STATS count() BY @timestamp' } })
158+
createParams({
159+
query: { esql: query },
160+
})
157161
);
162+
158163
expect(result).toEqual(RESOLUTION_MISMATCH);
159164
});
160165
});

src/platform/plugins/shared/discover/public/context_awareness/profile_providers/metrics_data_source_profile/profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type MetricsExperienceDataSourceProfileProvider = DataSourceProfileProvid
2121

2222
export const METRICS_DATA_SOURCE_PROFILE_ID = 'metrics-data-source-profile';
2323
// FIXME: could kbn-esql-ast provide a union type with existing commands?
24-
const SUPPORTED_ESQL_COMMANDS = new Set(['from', 'ts', 'limit', 'sort', 'where']);
24+
const SUPPORTED_ESQL_COMMANDS = new Set(['from', 'ts', 'limit', 'sort']);
2525
export const createMetricsDataSourceProfileProvider = (
2626
services: ProfileProviderServices
2727
): MetricsExperienceDataSourceProfileProvider => ({

0 commit comments

Comments
 (0)