Repository navigation
feat: Show PPL queries in Live Queries - #612
KishoreKicha14 wants to merge 7 commits into
Conversation
PR Reviewer Guide 🔍(Review updated until commit abcdec0)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to abcdec0 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit af39bdf
Suggestions up to commit 72dda61
Suggestions up to commit 33befc9
Suggestions up to commit 8ad092f
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #612 +/- ##
==========================================
+ Coverage 75.07% 75.70% +0.63%
==========================================
Files 47 48 +1
Lines 4128 4264 +136
Branches 1132 1223 +91
==========================================
+ Hits 3099 3228 +129
- Misses 682 687 +5
- Partials 347 349 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 33befc9 |
|
Persistent review updated to latest commit 72dda61 |
| '', | ||
| 'Timestamp', | ||
| 'Task ID', | ||
| 'Query source', |
There was a problem hiding this comment.
The release integration tests run a copy of this spec that lives in the functional test repo (opensearch-dashboards-functional-test, file cypress/integration/plugins/query-insights-dashboards/5_live_queries_spec.js), not this file.
That copy still expects 12 headers with Index right after Task ID. Once this merges, the new Query source column will make it fail. Could you open a matching PR there so both land together?
|
|
||
| // A PPL query names its indices in `source=`, which can only start the query or a subsearch | ||
| // (`[ source=... ]`). Anchoring there keeps a field called `source` in a `where` from matching. | ||
| const PPL_SOURCE = /(?:^|\[)\s*(?:search\s+)?source\s*=\s*([^\s|\],]+(?:\s*,\s*[^\s|\],]+)*)/gi; |
There was a problem hiding this comment.
The Index column relies on this regex most of the time. A few valid PPL queries come out wrong. Could you handle these and add tests?
| Query | Index shown |
|---|---|
index=logs | head 5 |
N/A |
| source=logs |
N/A |
/* note */ source=logs |
N/A |
search status=500 source=logs |
N/A |
source=[ source=logs | where a > 1 ] as t |
[ |
| * stable while the query is between searches; the indices of its running searches add any the | ||
| * text doesn't name with `source=`, such as a join's right side. | ||
| */ | ||
| export const pplIndices = ( |
There was a problem hiding this comment.
As a follow up, could you instrument the SQL plugin to provide indices concretely? Then the regex is not needed.
SQL already parses the query and knows every index it reads. It could expose them on the PPL task, either in the task status or as indices[...] in the task description like DSL searches have. The query insights backend could then return them, and this page could show them directly.
There was a problem hiding this comment.
will add an issue
|
Persistent review updated to latest commit af39bdf |
Query Insights reports a running PPL query as one Live Queries row whose coordinator task is the PPL task, with the searches it runs and their shard tasks as child tasks. The page read every row as a DSL search: the index and search type came out as N/A, the query text was shown nowhere, and the child searches were listed as a phase named indices:data/read/search. Add a Query Source column with a PPL or DSL badge, and a query_source search field. A PPL row's badge shows the query text on hover, and its index comes from the source= clauses in that text, plus any other index its running searches target. The text keeps the index stable while the query is between searches. In the flyout, a PPL row shows its query text under PPL Query, lists its tasks as Child Tasks, and labels its searches as Search. The tests render Live Queries responses captured from a cluster running a PPL join beside a DSL search. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
A PPL query's flyout listed the searches it runs and their shard tasks in one Child Tasks table, with each search as a row whose phase read Search. List the searches under Child Search Tasks, with the indices each one reads, and their shard tasks under Shard Tasks, with the shard and phase columns a DSL search shows. The flyout tells the two apart by action, so the Live Queries response doesn't change. A DSL search's flyout is unchanged. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
The Live Queries Cypress suite checks the table's column headers in order, so it failed once the Query source column was added after Task ID. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
Live Queries leaves wlm_group_id off PPL rows as of opensearch-project/query-insights#699: WLM manages the searches a PPL query runs, not the query, so a PPL row has no group of its own. Remove it from the PPL row in stub_live_queries_ppl.json so the fixture matches what the API returns. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
The Index column read a PPL query's indices with a regex anchored at the start of the query or a subsearch. It missed index=, a leading pipe, a leading comment and search expressions before source=, and showed "[" for a subsearch used as the source. Tokenize the text instead, dropping comments and quoted strings, and read the source= or index= of the command that starts the query and each subsearch, wherever it sits in that command. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
Every [ was read as the start of a subsearch. The brackets of appendcol, appendpipe, append and foreach hold commands over the results so far, so a field could come out as an index: source=logs | appendcol [ eval index = 1 ] read logs and 1. A bracket's first command now names indices only when it's a search, not one of the PPL grammar's other commands. Also: - A partly backticked name, such as logs.`2024`, was cut at the backtick. Parts with nothing between them now make one name. - A queryId containing ] left the whole task description as the query text. The prefix now ends at the first ]: . Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
A PPL row joined its indices with ", ", while a search's row shows its indices[...] as written, "a,b". The same indices then counted as two keys in the index chart. Join a PPL row's the same way. Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
af39bdf to
abcdec0
Compare
|
Persistent review updated to latest commit abcdec0 |
Description
With opensearch-project/query-insights/pull/699 Live Queries reports a running PPL query as one row: its coordinator task is the PPL task, and its
shard_tasksholds the searches it runs and their shard tasks. This page read every row as a DSL search, so a PPL row showed N/A for its index and search type, its query text appeared nowhere, and its searches were listed as shard tasks with the phaseindices:data/read/search.Changes:
query_sourceis also a search field.source=clauses, plus any other index its running searches read, so it stays the same while the query is between searches.Testing
cypress/fixtures/stub_live_queries_ppl.json).Issues Resolved
Related: #577 also adds a query source to Live Queries, based on labels from an earlier backend design. This PR reads the PPL task instead, so the two overlap in
InflightQueries.tsxandTaskDetailFlyout.tsx.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.