Skip to content

Conversation

@shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Mar 4, 2025

Summary

Allow slo query wild card filters when kql filter and dsl filter both are used.

For KQL filter, allowLeadingWildcards was true by default. introduces the ability to use wildcard filters in SLO queries when DSL filters are also used.

Changes Made

  1. Updated getElasticsearchQueryOrThrow function:

    • Added support for dataView parameter in the toElasticsearchQuery function.
    • Included additional options for allowLeadingWildcards.
    • Enhanced error handling to differentiate between invalid KQL and KQL queries with invalid filters.
  2. Test Coverage:

    • Added new test cases to cover scenarios with wildcard queries and filters.

@shahzad31 shahzad31 marked this pull request as ready for review March 4, 2025 15:12
@shahzad31 shahzad31 requested a review from a team as a code owner March 4, 2025 15:12
try {
if (kqlQuerySchema.is(kuery)) {
return toElasticsearchQuery(fromKueryExpression(kuery));
return toElasticsearchQuery(fromKueryExpression(kuery), dataView);
Copy link
Contributor

Choose a reason for hiding this comment

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

As we talked during our meeting, do you think it makes sense to use only buildEsQuery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdelemme done !!

@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Mar 4, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@shahzad31 shahzad31 added release_note:fix and removed Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. labels Mar 5, 2025
@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Mar 5, 2025
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

LGTM! Appreciate the added tests and the simplification of the code path

@elasticmachine
Copy link
Contributor

elasticmachine commented Mar 5, 2025

💔 Build Failed

Failed CI Steps

Metrics [docs]

✅ unchanged

History

@shahzad31 shahzad31 requested a review from kdelemme March 6, 2025 16:18
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

snaps update looks fine

@shahzad31 shahzad31 merged commit 33f51f6 into elastic:main Mar 6, 2025
9 checks passed
@shahzad31 shahzad31 deleted the slo-kuery-wildcard branch March 6, 2025 16:45
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16, 8.17, 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/13703769981

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 6, 2025
## Summary

Allow slo query wild card filters when kql filter and dsl filter both
are used.

For KQL filter, allowLeadingWildcards was true by default. introduces
the ability to use wildcard filters in SLO queries when DSL filters are
also used.

### Changes Made
1. **Updated `getElasticsearchQueryOrThrow` function:**
- Added support for `dataView` parameter in the `toElasticsearchQuery`
function.
   - Included additional options for `allowLeadingWildcards`.
- Enhanced error handling to differentiate between invalid KQL and KQL
queries with invalid filters.

2. **Test Coverage:**
- Added new test cases to cover scenarios with wildcard queries and
filters.

(cherry picked from commit 33f51f6)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.16 Backport failed because of merge conflicts
8.17 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.17:
- [Performance][Security Solution] - Improve cell renderer performance (#212982)
- [SecuritySolution] Fix Risk score Insufficient privileges warning missing cluster privileges (#212405)
8.18 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.18:
- [Security Solution] Allow prebuilt rules import and export (#212509)
- [Performance][Security Solution] - Improve cell renderer performance (#212982)
- [SecuritySolution] Fix Risk score Insufficient privileges warning missing cluster privileges (#212405)
- [Siem Migrations] Translated Rules Upsell Page (#212777)
8.x Backport failed because of merge conflicts

You might need to backport the following PRs to 8.x:
- [Security Solution] Allow prebuilt rules import and export (#212509)
- [Dev Docs] Add VS Code configurations to Dev Docs Debugging Tutorial (#212807)
- [ML] File upload lite UI customizations (#213275)
- [ES|QL] Fixes the wrong validation when a named param is used as function (#213355)
- [SecuritySolution] Fix Risk score Insufficient privileges warning missing cluster privileges (#212405)
- [Unified search] Change codeowners to presentation team (#212855)
- [Case Observables] Implement server side validation (#209706)
- [Siem Migrations] Translated Rules Upsell Page (#212777)
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 213119

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Mar 6, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [[SLOs] Allow slo query wild card filters !!
(#213119)](#213119)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-06T16:45:23Z","message":"[SLOs]
Allow slo query wild card filters !! (#213119)\n\n## Summary\n\nAllow
slo query wild card filters when kql filter and dsl filter both\nare
used.\n\nFor KQL filter, allowLeadingWildcards was true by default.
introduces\nthe ability to use wildcard filters in SLO queries when DSL
filters are\nalso used.\n\n### Changes Made\n1. **Updated
`getElasticsearchQueryOrThrow` function:**\n- Added support for
`dataView` parameter in the `toElasticsearchQuery`\nfunction.\n -
Included additional options for `allowLeadingWildcards`.\n- Enhanced
error handling to differentiate between invalid KQL and KQL\nqueries
with invalid filters.\n\n2. **Test Coverage:**\n- Added new test cases
to cover scenarios with wildcard queries
and\nfilters.","sha":"33f51f6d6e01638116b6201215f5f2589fc291c6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","backport:prev-major","Team:obs-ux-management","v9.1.0"],"title":"[SLOs]
Allow slo query wild card filters
!!","number":213119,"url":"https://github.com/elastic/kibana/pull/213119","mergeCommit":{"message":"[SLOs]
Allow slo query wild card filters !! (#213119)\n\n## Summary\n\nAllow
slo query wild card filters when kql filter and dsl filter both\nare
used.\n\nFor KQL filter, allowLeadingWildcards was true by default.
introduces\nthe ability to use wildcard filters in SLO queries when DSL
filters are\nalso used.\n\n### Changes Made\n1. **Updated
`getElasticsearchQueryOrThrow` function:**\n- Added support for
`dataView` parameter in the `toElasticsearchQuery`\nfunction.\n -
Included additional options for `allowLeadingWildcards`.\n- Enhanced
error handling to differentiate between invalid KQL and KQL\nqueries
with invalid filters.\n\n2. **Test Coverage:**\n- Added new test cases
to cover scenarios with wildcard queries
and\nfilters.","sha":"33f51f6d6e01638116b6201215f5f2589fc291c6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213119","number":213119,"mergeCommit":{"message":"[SLOs]
Allow slo query wild card filters !! (#213119)\n\n## Summary\n\nAllow
slo query wild card filters when kql filter and dsl filter both\nare
used.\n\nFor KQL filter, allowLeadingWildcards was true by default.
introduces\nthe ability to use wildcard filters in SLO queries when DSL
filters are\nalso used.\n\n### Changes Made\n1. **Updated
`getElasticsearchQueryOrThrow` function:**\n- Added support for
`dataView` parameter in the `toElasticsearchQuery`\nfunction.\n -
Included additional options for `allowLeadingWildcards`.\n- Enhanced
error handling to differentiate between invalid KQL and KQL\nqueries
with invalid filters.\n\n2. **Test Coverage:**\n- Added new test cases
to cover scenarios with wildcard queries
and\nfilters.","sha":"33f51f6d6e01638116b6201215f5f2589fc291c6"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
## Summary

Allow slo query wild card filters when kql filter and dsl filter both
are used.

For KQL filter, allowLeadingWildcards was true by default. introduces
the ability to use wildcard filters in SLO queries when DSL filters are
also used.

### Changes Made
1. **Updated `getElasticsearchQueryOrThrow` function:**
- Added support for `dataView` parameter in the `toElasticsearchQuery`
function.
   - Included additional options for `allowLeadingWildcards`.
- Enhanced error handling to differentiate between invalid KQL and KQL
queries with invalid filters.

2. **Test Coverage:**
- Added new test cases to cover scenarios with wildcard queries and
filters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:fix Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants